blob: 6141324d24fd01f7220b59f236472c507d3086ab (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
<div xmlns:py="http://purl.org/kid/ns#">
<?python
from ipagui.helpers import ipahelper
#
# This file is used to render the results from an AJAX search onto a page.
# It has many expectations of the page being rendered into:
# - Source page must have included dynamicedit.js and followed all of its
# requirements
#
?>
<div id="search-results-count">
</div>
<?python
criteria_esc = ipahelper.javascript_string_escape(criteria)
?>
<script type="text/javascript">
search_string = "${criteria_esc}";
results_counter = 0;
</script>
<?python search_div_counter = 1 ?>
<div py:for="entities in (users, groups)">
<div py:if='(entities != None) and (len(entities) > 0)'>
<div py:for="entity in entities" id="search-${search_div_counter}">
<?python
ent_dn_esc = ipahelper.javascript_string_escape(entity.dn)
ent_uid = entity.uid
if ent_uid:
ent_name = "%s %s" % (entity.getValue('givenName', ''),
entity.getValue('sn', ''))
ent_descr = "(%s)" % entity.uid
ent_type = "user"
else:
ent_name = entity.cn
ent_descr = "[group]"
ent_type = "group"
ent_name_esc = ipahelper.javascript_string_escape(ent_name)
ent_descr_esc = ipahelper.javascript_string_escape(ent_descr)
ent_type_esc = ipahelper.javascript_string_escape(ent_type)
?>
<span id="search-info-${search_div_counter}"></span>
<script type="text/javascript">
if ((added_hash["${ent_dn_esc}"] == 1) ||
(member_hash["${ent_dn_esc}"] == 1)) {
$("search-${search_div_counter}").style.display = 'none';
} else {
results_counter = results_counter + 1;
}
renderMemberInfo($('search-info-${search_div_counter}'),
new MemberDisplayInfo('${ent_name_esc}',
'${ent_descr_esc}',
'${ent_type_esc}'));
</script>
<a href=""
onclick="addmemberHandler(this, '${ent_dn_esc}',
new MemberDisplayInfo('${ent_name_esc}',
'${ent_descr_esc}',
'${ent_type_esc}'));
return false;"
>add</a>
<?python
search_div_counter = search_div_counter + 1
?>
</div>
</div>
</div>
<script type="text/javascript">
if (results_counter == 0) {
var message = "No results found for '" + search_string + "'";
} else {
var message = results_counter + " results found:";
}
$('search-results-count').appendChild(document.createTextNode(message));
</script>
<script py:if="counter < 0">
$('search-results-count').appendChild(document.createTextNode(
" (truncated)"));
</script>
</div>
|