1 | //Funcoes |
---|
2 | |
---|
3 | function remUser(){ |
---|
4 | primary_group = self.document.getElementById('primary_group_list'); |
---|
5 | select = self.document.getElementById('user_list'); |
---|
6 | |
---|
7 | for(var i = 0;i < select.options.length; i++) { |
---|
8 | if(select.options[i].selected) { |
---|
9 | if(primary_group != null) { |
---|
10 | for(var j = 0;j < primary_group.options.length; j++) { |
---|
11 | if(primary_group.options[j].value == select.options[i].value) { |
---|
12 | primary_group.options[j] = null; |
---|
13 | if(primary_group.options.length > 0) |
---|
14 | primary_group.options[0].selected = true; |
---|
15 | |
---|
16 | break; |
---|
17 | } |
---|
18 | } |
---|
19 | } |
---|
20 | select.options[i--] = null; |
---|
21 | } |
---|
22 | } |
---|
23 | |
---|
24 | if(select.options.length) |
---|
25 | select.options[0].selected = true; |
---|
26 | } |
---|
27 | |
---|
28 | function remUserAcl(){ |
---|
29 | select = self.document.getElementById('user_list'); |
---|
30 | for(var i = 0;i < select.options.length; i++) |
---|
31 | if(select.options[i].selected){ |
---|
32 | ids = getIds(select.options[i].value); |
---|
33 | for(j = 0; j < ids.length; j++) |
---|
34 | document.getElementById(ids[j]).disabled = true; |
---|
35 | |
---|
36 | select.options[i--] = null; |
---|
37 | } |
---|
38 | |
---|
39 | if(select.options.length) |
---|
40 | select.options[0].selected = true; |
---|
41 | |
---|
42 | execAction('LOAD'); |
---|
43 | } |
---|
44 | |
---|
45 | function openListUsers(newWidth,newHeight,currentApp,type){ |
---|
46 | |
---|
47 | newScreenX = screen.width - newWidth; |
---|
48 | newScreenY = 0; |
---|
49 | |
---|
50 | window.open('phpgwapi/templates/classic/listUsers.php?'+(type == 'g' ? 'type=g&' : '')+'currentApp='+currentApp,"","width="+newWidth+",height="+newHeight+",screenX="+newScreenX+",left="+newScreenX+",screenY="+newScreenY+",top="+newScreenY+",status=1,toolbar=no,scrollbars=yes,resizable=no"); |
---|
51 | |
---|
52 | } |
---|
53 | |
---|
54 | function execAction(action){ |
---|
55 | |
---|
56 | if(!window.opener) |
---|
57 | doc = window.document; |
---|
58 | else |
---|
59 | doc = window.opener.document; |
---|
60 | |
---|
61 | select = doc.getElementById('user_list'); |
---|
62 | checkAttr = doc.formAcl.checkAttr; |
---|
63 | for(i = 0; i < select.length; i++) { |
---|
64 | if(select.options[i].selected){ |
---|
65 | ids = getIds(select.options[i].value); |
---|
66 | |
---|
67 | for(j = 0; j < ids.length; j++){ |
---|
68 | |
---|
69 | if(action == 'SAVE') { |
---|
70 | doc.getElementById(ids[j]).disabled = !checkAttr[j].checked; |
---|
71 | } |
---|
72 | if(action == 'LOAD') { |
---|
73 | |
---|
74 | checkAttr[j].checked = !doc.getElementById(ids[j]).disabled; |
---|
75 | } |
---|
76 | } |
---|
77 | } |
---|
78 | } |
---|
79 | |
---|
80 | if(!select.length) |
---|
81 | for(j = 0; j < checkAttr.length; j++) |
---|
82 | checkAttr[j].disabled = true; |
---|
83 | |
---|
84 | else |
---|
85 | for(j = 0; j < checkAttr.length; j++) |
---|
86 | checkAttr[j].disabled = false; |
---|
87 | |
---|
88 | } |
---|
89 | |
---|
90 | function getIds(value){ |
---|
91 | |
---|
92 | ids = new Array(); |
---|
93 | ids[0] = value + '_1]' ; |
---|
94 | ids[1] = value + '_2]' ; |
---|
95 | ids[2] = value + '_4]' ; |
---|
96 | ids[3] = value + '_8]' ; |
---|
97 | ids[4] = value + '_16]'; |
---|
98 | |
---|
99 | return ids; |
---|
100 | } |
---|
101 | |
---|
102 | |
---|
103 | function optionFinder(oText) { |
---|
104 | |
---|
105 | for(var i = 0;i < select.options.length; i++) |
---|
106 | select.options[i--] = null; |
---|
107 | |
---|
108 | for(i = 0; i < users.length; i++) |
---|
109 | |
---|
110 | if(users[i].text.substring(0 ,oText.value.length).toUpperCase() == oText.value.toUpperCase() || |
---|
111 | (users[i].text.substring(0 ,3) == '(G)' && |
---|
112 | users[i].text.substring(4 ,4+oText.value.length).toUpperCase() == oText.value.toUpperCase())) { |
---|
113 | sel = select.options; |
---|
114 | option = new Option(users[i].text,users[i].value); |
---|
115 | option.onclick = users[i].onclick; |
---|
116 | sel[sel.length] = option; |
---|
117 | |
---|
118 | } |
---|
119 | } |
---|
120 | |
---|
121 | |
---|
122 | function addUser() { |
---|
123 | var select = window.document.getElementById('user_list_in'); |
---|
124 | var selectOpener = window.opener.document.getElementById('user_list'); |
---|
125 | |
---|
126 | var primary_group = window.opener.document.getElementById('primary_group_list'); |
---|
127 | |
---|
128 | if(document.all) |
---|
129 | primary_group = window.opener.document.all['primary_group_list']; |
---|
130 | |
---|
131 | for (i = 0 ; i < select.length ; i++) { |
---|
132 | |
---|
133 | if (select.options[i].selected) { |
---|
134 | isSelected = false; |
---|
135 | |
---|
136 | for(var j = 0;j < selectOpener.options.length; j++) { |
---|
137 | if(selectOpener.options[j].value == select.options[i].value){ |
---|
138 | isSelected = true; |
---|
139 | break; |
---|
140 | } |
---|
141 | } |
---|
142 | |
---|
143 | if(!isSelected){ |
---|
144 | |
---|
145 | option = window.opener.document.createElement('option'); |
---|
146 | option.value =select.options[i].value; |
---|
147 | option.text = select.options[i].text; |
---|
148 | selectOpener.options[selectOpener.options.length] = option; |
---|
149 | if(primary_group != null) { |
---|
150 | primary_group.options[primary_group.options.length] = window.opener.document.createElement('option'); |
---|
151 | primary_group.options[primary_group.options.length - 1].value =select.options[i].value; |
---|
152 | primary_group.options[primary_group.options.length - 1].text = select.options[i].text; |
---|
153 | } |
---|
154 | |
---|
155 | } |
---|
156 | |
---|
157 | } |
---|
158 | } |
---|
159 | |
---|
160 | selectOpener.options[selectOpener.options.length-1].selected = true; |
---|
161 | } |
---|
162 | |
---|
163 | function addUserAcl() { |
---|
164 | var select = window.document.getElementById('user_list_in'); |
---|
165 | var selectOpener = window.opener.document.getElementById('user_list'); |
---|
166 | for (i = 0 ; i < select.length ; i++) { |
---|
167 | |
---|
168 | if (select.options[i].selected) { |
---|
169 | isSelected = false; |
---|
170 | |
---|
171 | for(var j = 0;j < selectOpener.options.length; j++) { |
---|
172 | if(selectOpener.options[j].value == select.options[i].value){ |
---|
173 | isSelected = true; |
---|
174 | break; |
---|
175 | } |
---|
176 | } |
---|
177 | |
---|
178 | if(!isSelected){ |
---|
179 | |
---|
180 | option = window.opener.document.createElement('option'); |
---|
181 | option.value =select.options[i].value; |
---|
182 | option.text = select.options[i].text; |
---|
183 | if( option.value.charAt(0) == 'g' ) |
---|
184 | option.text = "(G) "+option.text; |
---|
185 | selectOpener.options[selectOpener.options.length] = option; |
---|
186 | |
---|
187 | ids = getIds(select.options[i].value); |
---|
188 | for(k = 0; k < ids.length; k++) { |
---|
189 | el = window.opener.document.createElement('input'); |
---|
190 | el.type='hidden'; |
---|
191 | el.value ='Y'; |
---|
192 | el.name = ids[k]; |
---|
193 | el.disabled = true; |
---|
194 | el.id = ids[k]; |
---|
195 | window.opener.document.getElementById("tdHiddens").appendChild(el); |
---|
196 | } |
---|
197 | } |
---|
198 | |
---|
199 | } |
---|
200 | } |
---|
201 | selectOpener.options[selectOpener.options.length-1].selected = true; |
---|
202 | execAction('LOAD'); |
---|
203 | } |
---|