4 var aclPermList = false; |
4 var aclPermList = false; |
5 var aclDataCache = false; |
5 var aclDataCache = false; |
6 |
6 |
7 function ajaxOpenACLManager(page_id, namespace) |
7 function ajaxOpenACLManager(page_id, namespace) |
8 { |
8 { |
9 // touch these to make them available to child functions |
9 // touch these to make them available to child functions |
10 void(page_id); |
10 void(page_id); |
11 void(namespace); |
11 void(namespace); |
12 |
12 |
13 // require re-auth |
13 // require re-auth |
14 if ( auth_level <= USER_LEVEL_MEMBER ) |
14 if ( auth_level <= USER_LEVEL_MEMBER ) |
15 { |
15 { |
16 load_component(['login', 'fadefilter', 'flyin', 'jquery', 'jquery-ui', 'crypto', 'messagebox']); |
16 load_component(['login', 'fadefilter', 'flyin', 'jquery', 'jquery-ui', 'crypto', 'messagebox']); |
17 ajaxDynamicReauth(function(key) |
17 ajaxDynamicReauth(function(key) |
18 { |
18 { |
19 ajaxOpenACLManager(page_id, namespace); |
19 ajaxOpenACLManager(page_id, namespace); |
20 }, user_level); |
20 }, user_level); |
21 |
21 |
22 return false; |
22 return false; |
23 } |
23 } |
24 |
24 |
25 load_component(['l10n', 'messagebox', 'fadefilter', 'template-compiler', 'jquery', 'jquery-ui', 'autofill']); |
25 load_component(['l10n', 'messagebox', 'fadefilter', 'template-compiler', 'jquery', 'jquery-ui', 'autofill']); |
26 |
26 |
27 if(!page_id || !namespace) |
27 if(!page_id || !namespace) |
28 { |
28 { |
29 var data = strToPageID(title); |
29 var data = strToPageID(title); |
30 var page_id = data[0]; |
30 var page_id = data[0]; |
31 var namespace = data[1]; |
31 var namespace = data[1]; |
32 } |
32 } |
33 var params = { |
33 var params = { |
34 'mode' : 'listgroups', |
34 'mode' : 'listgroups', |
35 'page_id' : page_id, |
35 'page_id' : page_id, |
36 'namespace' : namespace |
36 'namespace' : namespace |
37 }; |
37 }; |
38 params = toJSONString(params); |
38 params = toJSONString(params); |
39 params = ajaxEscape(params); |
39 params = ajaxEscape(params); |
40 ajaxPost(stdAjaxPrefix+'&_mode=acljson', 'acl_params='+params, function(ajax) { |
40 ajaxPost(stdAjaxPrefix+'&_mode=acljson', 'acl_params='+params, function(ajax) { |
41 if ( ajax.readyState == 4 && ajax.status == 200 ) |
41 if ( ajax.readyState == 4 && ajax.status == 200 ) |
42 { |
42 { |
43 var response = String(ajax.responseText + ''); |
43 var response = String(ajax.responseText + ''); |
44 if ( !check_json_response(response) ) |
44 if ( !check_json_response(response) ) |
45 { |
45 { |
46 handle_invalid_json(ajax.responseText); |
46 handle_invalid_json(ajax.responseText); |
47 return false; |
47 return false; |
48 } |
48 } |
49 try { |
49 try { |
50 var groups = parseJSON(ajax.responseText); |
50 var groups = parseJSON(ajax.responseText); |
51 } catch(e) { |
51 } catch(e) { |
52 handle_invalid_json(ajax.responseText); |
52 handle_invalid_json(ajax.responseText); |
53 } |
53 } |
54 __aclBuildWizardWindow(); |
54 __aclBuildWizardWindow(); |
55 if ( groups.mode == 'error' ) |
55 if ( groups.mode == 'error' ) |
56 { |
56 { |
57 alert(groups.error); |
57 alert(groups.error); |
58 killACLManager(); |
58 killACLManager(); |
59 return false; |
59 return false; |
60 } |
60 } |
61 aclDataCache = groups; |
61 aclDataCache = groups; |
62 __aclBuildSelector(groups); |
62 __aclBuildSelector(groups); |
63 } |
63 } |
64 }, true); |
64 }, true); |
65 return false; |
65 return false; |
66 } |
66 } |
67 |
67 |
68 function ajaxOpenDirectACLRule(rule_id) |
68 function ajaxOpenDirectACLRule(rule_id) |
69 { |
69 { |
70 load_component(['l10n', 'messagebox', 'fadefilter', 'template-compiler', 'autofill']); |
70 load_component(['l10n', 'messagebox', 'fadefilter', 'template-compiler', 'autofill']); |
71 |
71 |
72 var params = { |
72 var params = { |
73 target_id: rule_id, |
73 target_id: rule_id, |
74 mode: 'seltarget_id' |
74 mode: 'seltarget_id' |
75 }; |
75 }; |
76 params = ajaxEscape(toJSONString(params)); |
76 params = ajaxEscape(toJSONString(params)); |
77 ajaxPost(stdAjaxPrefix+'&_mode=acljson', 'acl_params='+params, function(ajax) { |
77 ajaxPost(stdAjaxPrefix+'&_mode=acljson', 'acl_params='+params, function(ajax) { |
78 if ( ajax.readyState == 4 && ajax.status == 200 ) |
78 if ( ajax.readyState == 4 && ajax.status == 200 ) |
79 { |
79 { |
80 var response = String(ajax.responseText + ''); |
80 var response = String(ajax.responseText + ''); |
81 if ( !check_json_response(response) ) |
81 if ( !check_json_response(response) ) |
82 { |
82 { |
83 handle_invalid_json(ajax.responseText); |
83 handle_invalid_json(ajax.responseText); |
84 return false; |
84 return false; |
85 } |
85 } |
86 try |
86 try |
87 { |
87 { |
88 response = parseJSON(response); |
88 response = parseJSON(response); |
89 } |
89 } |
90 catch(e) |
90 catch(e) |
91 { |
91 { |
92 handle_invalid_json(response); |
92 handle_invalid_json(response); |
93 } |
93 } |
94 if ( !document.getElementById(aclManagerID) ) |
94 if ( !document.getElementById(aclManagerID) ) |
95 { |
95 { |
96 __aclBuildWizardWindow(); |
96 __aclBuildWizardWindow(); |
97 var main = document.getElementById(aclManagerID + '_main'); |
97 var main = document.getElementById(aclManagerID + '_main'); |
98 main.style.padding = '10px'; |
98 main.style.padding = '10px'; |
99 } |
99 } |
100 else |
100 else |
101 { |
101 { |
102 var main = document.getElementById(aclManagerID + '_main'); |
102 var main = document.getElementById(aclManagerID + '_main'); |
103 main.style.backgroundImage = 'none'; |
103 main.style.backgroundImage = 'none'; |
104 } |
104 } |
105 if ( response.mode == 'error' ) |
105 if ( response.mode == 'error' ) |
106 { |
106 { |
107 alert(response.error); |
107 alert(response.error); |
108 killACLManager(); |
108 killACLManager(); |
109 return false; |
109 return false; |
110 } |
110 } |
111 aclDataCache = response; |
111 aclDataCache = response; |
112 aclBuildRuleEditor(response, true); |
112 aclBuildRuleEditor(response, true); |
113 } |
113 } |
114 }, true); |
114 }, true); |
115 } |
115 } |
116 |
116 |
117 function ajaxACLSwitchToSelector() |
117 function ajaxACLSwitchToSelector() |
118 { |
118 { |
119 params = { |
119 params = { |
120 'mode' : 'listgroups' |
120 'mode' : 'listgroups' |
121 }; |
121 }; |
122 if ( aclDataCache.page_id && aclDataCache.namespace ) |
122 if ( aclDataCache.page_id && aclDataCache.namespace ) |
123 { |
123 { |
124 params.page_id = aclDataCache.page_id; |
124 params.page_id = aclDataCache.page_id; |
125 params.namespace = aclDataCache.namespace; |
125 params.namespace = aclDataCache.namespace; |
126 } |
126 } |
127 params = toJSONString(params); |
127 params = toJSONString(params); |
128 params = ajaxEscape(params); |
128 params = ajaxEscape(params); |
129 ajaxPost(stdAjaxPrefix+'&_mode=acljson', 'acl_params='+params, function(ajax) { |
129 ajaxPost(stdAjaxPrefix+'&_mode=acljson', 'acl_params='+params, function(ajax) { |
130 if ( ajax.readyState == 4 && ajax.status == 200 ) |
130 if ( ajax.readyState == 4 && ajax.status == 200 ) |
131 { |
131 { |
132 document.getElementById(aclManagerID+'_main').innerHTML = ''; |
132 document.getElementById(aclManagerID+'_main').innerHTML = ''; |
133 document.getElementById(aclManagerID + '_back').style.display = 'none'; |
133 document.getElementById(aclManagerID + '_back').style.display = 'none'; |
134 document.getElementById(aclManagerID + '_next').value = $lang.get('etc_wizard_next'); |
134 document.getElementById(aclManagerID + '_next').value = $lang.get('etc_wizard_next'); |
135 var groups = parseJSON(ajax.responseText); |
135 var groups = parseJSON(ajax.responseText); |
136 if ( groups.mode == 'error' ) |
136 if ( groups.mode == 'error' ) |
137 { |
137 { |
138 alert(groups.error); |
138 alert(groups.error); |
139 killACLManager(); |
139 killACLManager(); |
140 return false; |
140 return false; |
141 } |
141 } |
142 aclDataCache = groups; |
142 aclDataCache = groups; |
143 thispage = strToPageID(title); |
143 thispage = strToPageID(title); |
144 groups.page_id = thispage[0]; |
144 groups.page_id = thispage[0]; |
145 groups.namespace = thispage[1]; |
145 groups.namespace = thispage[1]; |
146 __aclBuildSelector(groups); |
146 __aclBuildSelector(groups); |
147 } |
147 } |
148 }, true); |
148 }, true); |
149 } |
149 } |
150 |
150 |
151 function __aclBuildSelector(groups) |
151 function __aclBuildSelector(groups) |
152 { |
152 { |
153 thispage = strToPageID(title); |
153 thispage = strToPageID(title); |
154 do_scopesel = ( thispage[0] == groups.page_id && thispage[1] == groups.namespace ); |
154 do_scopesel = ( thispage[0] == groups.page_id && thispage[1] == groups.namespace ); |
155 |
155 |
156 document.getElementById(aclManagerID + '_next').style.display = 'inline'; |
156 document.getElementById(aclManagerID + '_next').style.display = 'inline'; |
157 |
157 |
158 seed = Math.floor(Math.random() * 1000000); |
158 seed = Math.floor(Math.random() * 1000000); |
159 |
159 |
160 main = document.getElementById(aclManagerID + '_main'); |
160 main = document.getElementById(aclManagerID + '_main'); |
161 main.style.padding = '10px'; |
161 main.style.padding = '10px'; |
162 main.style.backgroundImage = 'none'; |
162 main.style.backgroundImage = 'none'; |
163 |
163 |
164 // the "edit existing" button |
164 // the "edit existing" button |
165 var editbtn_wrapper = document.createElement('div'); |
165 var editbtn_wrapper = document.createElement('div'); |
166 editbtn_wrapper.style.styleFloat = 'right'; |
166 editbtn_wrapper.style.styleFloat = 'right'; |
167 editbtn_wrapper.style.cssFloat = 'right'; |
167 editbtn_wrapper.style.cssFloat = 'right'; |
168 editbtn_wrapper.style.fontSize = 'smaller'; |
168 editbtn_wrapper.style.fontSize = 'smaller'; |
169 var editbtn = document.createElement('a'); |
169 var editbtn = document.createElement('a'); |
170 editbtn.href = '#'; |
170 editbtn.href = '#'; |
171 editbtn.innerHTML = $lang.get('acl_btn_show_existing'); |
171 editbtn.innerHTML = $lang.get('acl_btn_show_existing'); |
172 editbtn_wrapper.appendChild(editbtn); |
172 editbtn_wrapper.appendChild(editbtn); |
173 |
173 |
174 // tracer button |
174 // tracer button |
175 var tracebtn = document.createElement('a'); |
175 var tracebtn = document.createElement('a'); |
176 tracebtn.href = '#'; |
176 tracebtn.href = '#'; |
177 tracebtn.innerHTML = $lang.get('acl_btn_view_effective'); |
177 tracebtn.innerHTML = $lang.get('acl_btn_view_effective'); |
178 editbtn_wrapper.appendChild(document.createElement('br')); |
178 editbtn_wrapper.appendChild(document.createElement('br')); |
179 editbtn_wrapper.appendChild(tracebtn); |
179 editbtn_wrapper.appendChild(tracebtn); |
180 |
180 |
181 main.appendChild(editbtn_wrapper); |
181 main.appendChild(editbtn_wrapper); |
182 |
182 |
183 editbtn.onclick = function() |
183 editbtn.onclick = function() |
184 { |
184 { |
185 aclSetViewListExisting(); |
185 aclSetViewListExisting(); |
186 return false; |
186 return false; |
187 } |
187 } |
188 |
188 |
189 tracebtn.onclick = function() |
189 tracebtn.onclick = function() |
190 { |
190 { |
191 aclSetViewDebugTools(); |
191 aclSetViewDebugTools(); |
192 return false; |
192 return false; |
193 } |
193 } |
194 |
194 |
195 selector = document.createElement('div'); |
195 selector = document.createElement('div'); |
196 |
196 |
197 var grpsel = __aclBuildGroupsHTML(groups); |
197 var grpsel = __aclBuildGroupsHTML(groups); |
198 grpsel.name = 'group_id'; |
198 grpsel.name = 'group_id'; |
199 |
199 |
200 span = document.createElement('div'); |
200 span = document.createElement('div'); |
201 span.id = "enACL_grpbox_"+seed+""; |
201 span.id = "enACL_grpbox_"+seed+""; |
202 |
202 |
203 // Build the selector |
203 // Build the selector |
204 grpb = document.createElement('input'); |
204 grpb = document.createElement('input'); |
205 grpb.type = 'radio'; |
205 grpb.type = 'radio'; |
206 grpb.name = 'target_type'; |
206 grpb.name = 'target_type'; |
207 grpb.value = '1'; // ACL_TYPE_GROUP |
207 grpb.value = '1'; // ACL_TYPE_GROUP |
208 grpb.checked = 'checked'; |
208 grpb.checked = 'checked'; |
209 grpb.className = seed; |
209 grpb.className = seed; |
210 grpb.onclick = function() { seed = this.className; document.getElementById('enACL_grpbox_'+seed).style.display = 'block'; document.getElementById('enACL_usrbox_'+seed).style.display = 'none'; }; |
210 grpb.onclick = function() { seed = this.className; document.getElementById('enACL_grpbox_'+seed).style.display = 'block'; document.getElementById('enACL_usrbox_'+seed).style.display = 'none'; }; |
211 lbl = document.createElement('label'); |
211 lbl = document.createElement('label'); |
212 lbl.appendChild(grpb); |
212 lbl.appendChild(grpb); |
213 lbl.appendChild(document.createTextNode($lang.get('acl_radio_usergroup'))); |
213 lbl.appendChild(document.createTextNode($lang.get('acl_radio_usergroup'))); |
214 lbl.style.display = 'block'; |
214 lbl.style.display = 'block'; |
215 span.appendChild(grpsel); |
215 span.appendChild(grpsel); |
216 |
216 |
217 anoninfo = document.createElement('div'); |
217 anoninfo = document.createElement('div'); |
218 anoninfo.className = 'info-box-mini'; |
218 anoninfo.className = 'info-box-mini'; |
219 anoninfo.appendChild(document.createTextNode($lang.get('acl_msg_guest_howto'))); |
219 anoninfo.appendChild(document.createTextNode($lang.get('acl_msg_guest_howto'))); |
220 span.appendChild(document.createElement('br')); |
220 span.appendChild(document.createElement('br')); |
221 span.appendChild(anoninfo); |
221 span.appendChild(anoninfo); |
222 |
222 |
223 usrb = document.createElement('input'); |
223 usrb = document.createElement('input'); |
224 usrb.type = 'radio'; |
224 usrb.type = 'radio'; |
225 usrb.name = 'target_type'; |
225 usrb.name = 'target_type'; |
226 usrb.value = '2'; // ACL_TYPE_USER |
226 usrb.value = '2'; // ACL_TYPE_USER |
227 usrb.className = seed; |
227 usrb.className = seed; |
228 usrb.onclick = function() { seed = this.className; document.getElementById('enACL_grpbox_'+seed).style.display = 'none'; document.getElementById('enACL_usrbox_'+seed).style.display = 'block'; }; |
228 usrb.onclick = function() { seed = this.className; document.getElementById('enACL_grpbox_'+seed).style.display = 'none'; document.getElementById('enACL_usrbox_'+seed).style.display = 'block'; }; |
229 lbl2 = document.createElement('label'); |
229 lbl2 = document.createElement('label'); |
230 lbl2.appendChild(usrb); |
230 lbl2.appendChild(usrb); |
231 lbl2.appendChild(document.createTextNode($lang.get('acl_radio_user'))); |
231 lbl2.appendChild(document.createTextNode($lang.get('acl_radio_user'))); |
232 lbl2.style.display = 'block'; |
232 lbl2.style.display = 'block'; |
233 |
233 |
234 usrsel = document.createElement('input'); |
234 usrsel = document.createElement('input'); |
235 usrsel.type = 'text'; |
235 usrsel.type = 'text'; |
236 usrsel.name = 'username'; |
236 usrsel.name = 'username'; |
237 usrsel.className = 'autofill username'; |
237 usrsel.className = 'autofill username'; |
238 usrsel.id = 'userfield_' + aclManagerID; |
238 usrsel.id = 'userfield_' + aclManagerID; |
239 try { |
239 try { |
240 usrsel.setAttribute("autocomplete","off"); |
240 usrsel.setAttribute("autocomplete","off"); |
241 } catch(e) {}; |
241 } catch(e) {}; |
242 |
242 |
243 span2 = document.createElement('div'); |
243 span2 = document.createElement('div'); |
244 span2.id = "enACL_usrbox_"+seed+""; |
244 span2.id = "enACL_usrbox_"+seed+""; |
245 span2.style.display = 'none'; |
245 span2.style.display = 'none'; |
246 span2.appendChild(usrsel); |
246 span2.appendChild(usrsel); |
247 |
247 |
248 // Scope selector |
248 // Scope selector |
249 if(do_scopesel) |
249 if(do_scopesel) |
250 { |
250 { |
251 scopediv1 = document.createElement('div'); |
251 scopediv1 = document.createElement('div'); |
252 scopediv2 = document.createElement('div'); |
252 scopediv2 = document.createElement('div'); |
253 scopediv3 = document.createElement('div'); |
253 scopediv3 = document.createElement('div'); |
254 scopeRadioPage = document.createElement('input'); |
254 scopeRadioPage = document.createElement('input'); |
255 scopeRadioPage.type = 'radio'; |
255 scopeRadioPage.type = 'radio'; |
256 scopeRadioPage.name = 'scope'; |
256 scopeRadioPage.name = 'scope'; |
257 scopeRadioPage.value = 'page'; |
257 scopeRadioPage.value = 'page'; |
258 scopeRadioPage.checked = 'checked'; |
258 scopeRadioPage.checked = 'checked'; |
259 scopeRadioPage.className = '1048576'; |
259 scopeRadioPage.className = '1048576'; |
260 if ( groups.page_groups.length > 0 ) scopeRadioPage.onclick = function() { var id = 'enACL_pgsel_' + this.className; document.getElementById(id).style.display = 'none'; }; |
260 if ( groups.page_groups.length > 0 ) scopeRadioPage.onclick = function() { var id = 'enACL_pgsel_' + this.className; document.getElementById(id).style.display = 'none'; }; |
261 scopeRadioGlobal = document.createElement('input'); |
261 scopeRadioGlobal = document.createElement('input'); |
262 scopeRadioGlobal.type = 'radio'; |
262 scopeRadioGlobal.type = 'radio'; |
263 scopeRadioGlobal.name = 'scope'; |
263 scopeRadioGlobal.name = 'scope'; |
264 scopeRadioGlobal.value = 'global'; |
264 scopeRadioGlobal.value = 'global'; |
265 scopeRadioGlobal.className = '1048576'; |
265 scopeRadioGlobal.className = '1048576'; |
266 if ( groups.page_groups.length > 0 ) scopeRadioGlobal.onclick = function() { var id = 'enACL_pgsel_' + this.className; document.getElementById(id).style.display = 'none'; }; |
266 if ( groups.page_groups.length > 0 ) scopeRadioGlobal.onclick = function() { var id = 'enACL_pgsel_' + this.className; document.getElementById(id).style.display = 'none'; }; |
267 scopeRadioGroup = document.createElement('input'); |
267 scopeRadioGroup = document.createElement('input'); |
268 scopeRadioGroup.type = 'radio'; |
268 scopeRadioGroup.type = 'radio'; |
269 scopeRadioGroup.name = 'scope'; |
269 scopeRadioGroup.name = 'scope'; |
270 scopeRadioGroup.value = 'group'; |
270 scopeRadioGroup.value = 'group'; |
271 scopeRadioGroup.className = '1048576'; |
271 scopeRadioGroup.className = '1048576'; |
272 if ( groups.page_groups.length > 0 ) scopeRadioGroup.onclick = function() { var id = 'enACL_pgsel_' + this.className; document.getElementById(id).style.display = 'block'; }; |
272 if ( groups.page_groups.length > 0 ) scopeRadioGroup.onclick = function() { var id = 'enACL_pgsel_' + this.className; document.getElementById(id).style.display = 'block'; }; |
273 lblPage = document.createElement('label'); |
273 lblPage = document.createElement('label'); |
274 lblPage.style.display = 'block'; |
274 lblPage.style.display = 'block'; |
275 lblPage.appendChild(scopeRadioPage); |
275 lblPage.appendChild(scopeRadioPage); |
276 lblPage.appendChild(document.createTextNode($lang.get('acl_radio_scope_thispage'))); |
276 lblPage.appendChild(document.createTextNode($lang.get('acl_radio_scope_thispage'))); |
277 lblGlobal = document.createElement('label'); |
277 lblGlobal = document.createElement('label'); |
278 lblGlobal.style.display = 'block'; |
278 lblGlobal.style.display = 'block'; |
279 lblGlobal.appendChild(scopeRadioGlobal); |
279 lblGlobal.appendChild(scopeRadioGlobal); |
280 lblGlobal.appendChild(document.createTextNode($lang.get('acl_radio_scope_wholesite'))); |
280 lblGlobal.appendChild(document.createTextNode($lang.get('acl_radio_scope_wholesite'))); |
281 lblGroup = document.createElement('label'); |
281 lblGroup = document.createElement('label'); |
282 lblGroup.style.display = 'block'; |
282 lblGroup.style.display = 'block'; |
283 lblGroup.appendChild(scopeRadioGroup); |
283 lblGroup.appendChild(scopeRadioGroup); |
284 lblGroup.appendChild(document.createTextNode($lang.get('acl_radio_scope_pagegroup'))); |
284 lblGroup.appendChild(document.createTextNode($lang.get('acl_radio_scope_pagegroup'))); |
285 scopediv1.appendChild(lblPage); |
285 scopediv1.appendChild(lblPage); |
286 scopediv2.appendChild(lblGroup); |
286 scopediv2.appendChild(lblGroup); |
287 scopediv3.appendChild(lblGlobal); |
287 scopediv3.appendChild(lblGlobal); |
288 |
288 |
289 scopedesc = document.createElement('p'); |
289 scopedesc = document.createElement('p'); |
290 scopedesc.appendChild(document.createTextNode($lang.get('acl_lbl_scope'))); |
290 scopedesc.appendChild(document.createTextNode($lang.get('acl_lbl_scope'))); |
291 |
291 |
292 scopePGrp = document.createElement('select'); |
292 scopePGrp = document.createElement('select'); |
293 scopePGrp.style.marginLeft = '13px'; |
293 scopePGrp.style.marginLeft = '13px'; |
294 scopePGrp.style.display = 'none'; |
294 scopePGrp.style.display = 'none'; |
295 scopePGrp.id = "enACL_pgsel_1048576"; |
295 scopePGrp.id = "enACL_pgsel_1048576"; |
296 |
296 |
297 var opt; |
297 var opt; |
298 for ( var i = 0; i < groups.page_groups.length; i++ ) |
298 for ( var i = 0; i < groups.page_groups.length; i++ ) |
299 { |
299 { |
300 opt = document.createElement('option'); |
300 opt = document.createElement('option'); |
301 opt.value = groups.page_groups[i].id; |
301 opt.value = groups.page_groups[i].id; |
302 opt.appendChild(document.createTextNode(groups.page_groups[i].name)); |
302 opt.appendChild(document.createTextNode(groups.page_groups[i].name)); |
303 scopePGrp.appendChild(opt); |
303 scopePGrp.appendChild(opt); |
304 } |
304 } |
305 |
305 |
306 scopediv2.appendChild(scopePGrp); |
306 scopediv2.appendChild(scopePGrp); |
307 |
307 |
308 } |
308 } |
309 |
309 |
310 // Styles |
310 // Styles |
311 span.style.marginLeft = '13px'; |
311 span.style.marginLeft = '13px'; |
312 span.style.padding = '5px 0'; |
312 span.style.padding = '5px 0'; |
313 span2.style.marginLeft = '13px'; |
313 span2.style.marginLeft = '13px'; |
314 span2.style.padding = '5px 0'; |
314 span2.style.padding = '5px 0'; |
315 |
315 |
316 selector.appendChild(lbl); |
316 selector.appendChild(lbl); |
317 selector.appendChild(span); |
317 selector.appendChild(span); |
318 |
318 |
319 selector.appendChild(lbl2); |
319 selector.appendChild(lbl2); |
320 selector.appendChild(span2); |
320 selector.appendChild(span2); |
321 |
321 |
322 container = document.createElement('div'); |
322 container = document.createElement('div'); |
323 container.style.margin = 'auto'; |
323 container.style.margin = 'auto'; |
324 container.style.width = '360px'; |
324 container.style.width = '360px'; |
325 container.style.paddingTop = '50px'; |
325 container.style.paddingTop = '50px'; |
326 |
326 |
327 head = document.createElement('h2'); |
327 head = document.createElement('h2'); |
328 head.appendChild(document.createTextNode($lang.get('acl_lbl_welcome_title'))); |
328 head.appendChild(document.createTextNode($lang.get('acl_lbl_welcome_title'))); |
329 |
329 |
330 desc = document.createElement('p'); |
330 desc = document.createElement('p'); |
331 desc.appendChild(document.createTextNode($lang.get('acl_lbl_welcome_body'))); |
331 desc.appendChild(document.createTextNode($lang.get('acl_lbl_welcome_body'))); |
332 |
332 |
333 container.appendChild(head); |
333 container.appendChild(head); |
334 container.appendChild(desc); |
334 container.appendChild(desc); |
335 container.appendChild(selector); |
335 container.appendChild(selector); |
336 |
336 |
337 if(do_scopesel) |
337 if(do_scopesel) |
338 { |
338 { |
339 container.appendChild(scopedesc); |
339 container.appendChild(scopedesc); |
340 container.appendChild(scopediv1); |
340 container.appendChild(scopediv1); |
341 if ( groups.page_groups.length > 0 ) |
341 if ( groups.page_groups.length > 0 ) |
342 { |
342 { |
343 container.appendChild(scopediv2); |
343 container.appendChild(scopediv2); |
344 } |
344 } |
345 container.appendChild(scopediv3); |
345 container.appendChild(scopediv3); |
346 } |
346 } |
347 |
347 |
348 main.appendChild(container); |
348 main.appendChild(container); |
349 |
349 |
350 var mode = document.createElement('input'); |
350 var mode = document.createElement('input'); |
351 mode.name = 'mode'; |
351 mode.name = 'mode'; |
352 mode.type = 'hidden'; |
352 mode.type = 'hidden'; |
353 mode.id = aclManagerID + '_mode'; |
353 mode.id = aclManagerID + '_mode'; |
354 mode.value = 'seltarget'; |
354 mode.value = 'seltarget'; |
355 |
355 |
356 var theform = document.getElementById(aclManagerID + '_formobj_id'); |
356 var theform = document.getElementById(aclManagerID + '_formobj_id'); |
357 if ( !theform.mode ) |
357 if ( !theform.mode ) |
358 { |
358 { |
359 theform.appendChild(mode); |
359 theform.appendChild(mode); |
360 } |
360 } |
361 else |
361 else |
362 { |
362 { |
363 theform.removeChild(theform.mode); |
363 theform.removeChild(theform.mode); |
364 theform.appendChild(mode); |
364 theform.appendChild(mode); |
365 } |
365 } |
366 |
366 |
367 autofill_init_element(usrsel, { |
367 autofill_init_element(usrsel, { |
368 allow_anon: true |
368 allow_anon: true |
369 }); |
369 }); |
370 } |
370 } |
371 |
371 |
372 var aclDebugWin = false; |
372 var aclDebugWin = false; |
373 |
373 |
374 function aclDebug(text) |
374 function aclDebug(text) |
375 { |
375 { |
376 if(!aclDebugWin) |
376 if(!aclDebugWin) |
377 aclDebugWin = pseudoWindowOpen("data:text/html;plain,<html><head><title>debug win</title></head><body><h1>Debug window</h1></body></html>", "aclDebugWin"); |
377 aclDebugWin = pseudoWindowOpen("data:text/html;plain,<html><head><title>debug win</title></head><body><h1>Debug window</h1></body></html>", "aclDebugWin"); |
378 setTimeout(function() { |
378 setTimeout(function() { |
379 aclDebugWin.pre = aclDebugWin.document.createElement('pre'); |
379 aclDebugWin.pre = aclDebugWin.document.createElement('pre'); |
380 aclDebugWin.pre.appendChild(aclDebugWin.document.createTextNode(text)); |
380 aclDebugWin.pre.appendChild(aclDebugWin.document.createTextNode(text)); |
381 aclDebugWin.b = aclDebugWin.document.getElementsByTagName('body')[0]; |
381 aclDebugWin.b = aclDebugWin.document.getElementsByTagName('body')[0]; |
382 aclDebugWin.b.appendChild(aclDebugWin.pre);}, 1000); |
382 aclDebugWin.b.appendChild(aclDebugWin.pre);}, 1000); |
383 } |
383 } |
384 |
384 |
385 var pseudoWindows = new Object(); |
385 var pseudoWindows = new Object(); |
386 |
386 |
387 function pseudoWindowOpen(url, id) |
387 function pseudoWindowOpen(url, id) |
388 { |
388 { |
389 if(pseudoWindows[id]) |
389 if(pseudoWindows[id]) |
390 { |
390 { |
391 document.getElementById('pseudowin_ifr_'+id).src = url; |
391 document.getElementById('pseudowin_ifr_'+id).src = url; |
392 } |
392 } |
393 else |
393 else |
394 { |
394 { |
395 win = document.createElement('iframe'); |
395 win = document.createElement('iframe'); |
396 win.style.position='fixed'; |
396 win.style.position='fixed'; |
397 win.style.width = '640px'; |
397 win.style.width = '640px'; |
398 win.style.height = '480px'; |
398 win.style.height = '480px'; |
399 win.style.top = '0px'; |
399 win.style.top = '0px'; |
400 win.style.left = '0px'; |
400 win.style.left = '0px'; |
401 win.style.zIndex = getHighestZ() + 1; |
401 win.style.zIndex = getHighestZ() + 1; |
402 win.style.backgroundColor = '#FFFFFF'; |
402 win.style.backgroundColor = '#FFFFFF'; |
403 win.name = 'pseudo_ifr_'+id; |
403 win.name = 'pseudo_ifr_'+id; |
404 win.id = 'pseudowindow_ifr_'+id; |
404 win.id = 'pseudowindow_ifr_'+id; |
405 win.src = url; |
405 win.src = url; |
406 body = document.getElementsByTagName('body')[0]; |
406 body = document.getElementsByTagName('body')[0]; |
407 body.appendChild(win); |
407 body.appendChild(win); |
408 } |
408 } |
409 win_obj = eval("( pseudo_ifr_"+id+" )"); |
409 win_obj = eval("( pseudo_ifr_"+id+" )"); |
410 return win_obj; |
410 return win_obj; |
411 } |
411 } |
412 |
412 |
413 function __aclJSONSubmitAjaxHandler(params) |
413 function __aclJSONSubmitAjaxHandler(params) |
414 { |
414 { |
415 params = toJSONString(params); |
415 params = toJSONString(params); |
416 params = ajaxEscape(params); |
416 params = ajaxEscape(params); |
417 ajaxPost(stdAjaxPrefix+'&_mode=acljson', 'acl_params='+params, function(ajax) { |
417 ajaxPost(stdAjaxPrefix+'&_mode=acljson', 'acl_params='+params, function(ajax) { |
418 if ( ajax.readyState == 4 && ajax.status == 200 ) |
418 if ( ajax.readyState == 4 && ajax.status == 200 ) |
419 { |
419 { |
420 var response = String(ajax.responseText + ''); |
420 var response = String(ajax.responseText + ''); |
421 if ( !check_json_response(response) ) |
421 if ( !check_json_response(response) ) |
422 { |
422 { |
423 handle_invalid_json(ajax.responseText); |
423 handle_invalid_json(ajax.responseText); |
424 return false; |
424 return false; |
425 } |
425 } |
426 try |
426 try |
427 { |
427 { |
428 var data = parseJSON(ajax.responseText); |
428 var data = parseJSON(ajax.responseText); |
429 } |
429 } |
430 catch(e) |
430 catch(e) |
431 { |
431 { |
432 handle_invalid_json(ajax.responseText); |
432 handle_invalid_json(ajax.responseText); |
433 return false; |
433 return false; |
434 } |
434 } |
435 aclDataCache = data; |
435 aclDataCache = data; |
436 switch(data.mode) |
436 switch(data.mode) |
437 { |
437 { |
438 case 'seltarget': |
438 case 'seltarget': |
439 |
439 |
440 // Build the ACL edit form |
440 // Build the ACL edit form |
441 aclBuildRuleEditor(data); |
441 aclBuildRuleEditor(data); |
442 |
442 |
443 break; |
443 break; |
444 case 'success': |
444 case 'success': |
445 var note = document.createElement('div'); |
445 var note = document.createElement('div'); |
446 note.className = 'info-box'; |
446 note.className = 'info-box'; |
447 note.style.marginLeft = '0'; |
447 note.style.marginLeft = '0'; |
448 var b = document.createElement('b'); |
448 var b = document.createElement('b'); |
449 b.appendChild(document.createTextNode($lang.get('acl_lbl_save_success_title'))); |
449 b.appendChild(document.createTextNode($lang.get('acl_lbl_save_success_title'))); |
450 note.appendChild(b); |
450 note.appendChild(b); |
451 note.appendChild(document.createElement('br')); |
451 note.appendChild(document.createElement('br')); |
452 note.appendChild(document.createTextNode($lang.get('acl_lbl_save_success_body', { target_name: data.target_name }))); |
452 note.appendChild(document.createTextNode($lang.get('acl_lbl_save_success_body', { target_name: data.target_name }))); |
453 note.appendChild(document.createElement('br')); |
453 note.appendChild(document.createElement('br')); |
454 |
454 |
455 /* |
455 /* |
456 var a = document.createElement('a'); |
456 var a = document.createElement('a'); |
457 a.href = '#'; |
457 a.href = '#'; |
458 a.id = aclManagerID + '_btn_dismiss'; |
458 a.id = aclManagerID + '_btn_dismiss'; |
459 a.appendChild(document.createTextNode('[ ' + $lang.get('acl_btn_success_dismiss') + ' :')); |
459 a.appendChild(document.createTextNode('[ ' + $lang.get('acl_btn_success_dismiss') + ' :')); |
460 note.appendChild(a); |
460 note.appendChild(a); |
461 var a2 = document.createElement('a'); |
461 var a2 = document.createElement('a'); |
462 a2.href = '#'; |
462 a2.href = '#'; |
463 a.id = aclManagerID + '_btn_close'; |
463 a.id = aclManagerID + '_btn_close'; |
464 a2.appendChild(document.createTextNode(': ' + $lang.get('acl_btn_success_close') + ' ]')); |
464 a2.appendChild(document.createTextNode(': ' + $lang.get('acl_btn_success_close') + ' ]')); |
465 note.appendChild(a2); |
465 note.appendChild(a2); |
466 */ |
466 */ |
467 |
467 |
468 var a_dismiss = document.createElement('a'); |
468 var a_dismiss = document.createElement('a'); |
469 a_dismiss.href = '#'; |
469 a_dismiss.href = '#'; |
470 a_dismiss.appendChild(document.createTextNode('[ ' + $lang.get('acl_btn_success_dismiss') + ' :')); |
470 a_dismiss.appendChild(document.createTextNode('[ ' + $lang.get('acl_btn_success_dismiss') + ' :')); |
471 note.appendChild(a_dismiss); |
471 note.appendChild(a_dismiss); |
472 |
472 |
473 var a_close = document.createElement('a'); |
473 var a_close = document.createElement('a'); |
474 a_close.href = '#'; |
474 a_close.href = '#'; |
475 a_close.appendChild(document.createTextNode(': ' + $lang.get('acl_btn_success_close') + ' ]')); |
475 a_close.appendChild(document.createTextNode(': ' + $lang.get('acl_btn_success_close') + ' ]')); |
476 note.appendChild(a_close); |
476 note.appendChild(a_close); |
477 |
477 |
478 document.getElementById(aclManagerID + '_main').insertBefore(note, document.getElementById(aclManagerID + '_main').firstChild); |
478 document.getElementById(aclManagerID + '_main').insertBefore(note, document.getElementById(aclManagerID + '_main').firstChild); |
479 |
479 |
480 a_dismiss.setAttribute('onclick', 'var parent = this.parentNode.parentNode; parent.removeChild(this.parentNode); return false;'); |
480 a_dismiss.setAttribute('onclick', 'var parent = this.parentNode.parentNode; parent.removeChild(this.parentNode); return false;'); |
481 a_close.setAttribute('onclick', 'killACLManager(); return false;'); |
481 a_close.setAttribute('onclick', 'killACLManager(); return false;'); |
482 |
482 |
483 if ( !document.getElementById(aclManagerID+'_deletelnk') ) |
483 if ( !document.getElementById(aclManagerID+'_deletelnk') ) |
484 { |
484 { |
485 var p = document.createElement('p'); |
485 var p = document.createElement('p'); |
486 p.innerHTML = '<a href="#delete_acl_rule" onclick="if(confirm(\'' + $lang.get('acl_msg_deleterule_confirm') + '\')) __aclDeleteRule(); return false;" style="color: red;">' + $lang.get('acl_lbl_deleterule') + '</a>'; |
486 p.innerHTML = '<a href="#delete_acl_rule" onclick="if(confirm(\'' + $lang.get('acl_msg_deleterule_confirm') + '\')) __aclDeleteRule(); return false;" style="color: red;">' + $lang.get('acl_lbl_deleterule') + '</a>'; |
487 p.id = aclManagerID + '_deletelnk'; |
487 p.id = aclManagerID + '_deletelnk'; |
488 p.style.textAlign = 'right'; |
488 p.style.textAlign = 'right'; |
489 |
489 |
490 document.getElementById(aclManagerID + '_main').appendChild(p); |
490 document.getElementById(aclManagerID + '_main').appendChild(p); |
491 } |
491 } |
492 |
492 |
493 document.getElementById(aclManagerID+'_main').scrollTop = 0; |
493 document.getElementById(aclManagerID+'_main').scrollTop = 0; |
494 document.getElementById(aclManagerID+'_main').style.backgroundImage = 'none'; |
494 document.getElementById(aclManagerID+'_main').style.backgroundImage = 'none'; |
495 |
495 |
496 aclDataCache.mode = 'save_edit'; |
496 aclDataCache.mode = 'save_edit'; |
497 break; |
497 break; |
498 case 'delete': |
498 case 'delete': |
499 |
499 |
500 params = { |
500 params = { |
501 'mode' : 'listgroups' |
501 'mode' : 'listgroups' |
502 }; |
502 }; |
503 params = toJSONString(params); |
503 params = toJSONString(params); |
504 params = ajaxEscape(params); |
504 params = ajaxEscape(params); |
505 ajaxPost(stdAjaxPrefix+'&_mode=acljson', 'acl_params='+params, function(ajax) { |
505 ajaxPost(stdAjaxPrefix+'&_mode=acljson', 'acl_params='+params, function(ajax) { |
506 if ( ajax.readyState == 4 && ajax.status == 200 ) |
506 if ( ajax.readyState == 4 && ajax.status == 200 ) |
507 { |
507 { |
508 document.getElementById(aclManagerID+'_main').innerHTML = ''; |
508 document.getElementById(aclManagerID+'_main').innerHTML = ''; |
509 document.getElementById(aclManagerID + '_back').style.display = 'none'; |
509 document.getElementById(aclManagerID + '_back').style.display = 'none'; |
510 document.getElementById(aclManagerID + '_next').value = $lang.get('etc_wizard_next'); |
510 document.getElementById(aclManagerID + '_next').value = $lang.get('etc_wizard_next'); |
511 ajaxACLSwitchToSelector(); |
511 ajaxACLSwitchToSelector(); |
512 |
512 |
513 // note |
513 // note |
514 var note = document.createElement('div'); |
514 var note = document.createElement('div'); |
515 note.className = 'info-box-mini'; |
515 note.className = 'info-box-mini'; |
516 note.appendChild(document.createTextNode($lang.get('acl_lbl_delete_success'))); |
516 note.appendChild(document.createTextNode($lang.get('acl_lbl_delete_success'))); |
517 |
517 |
518 // button: dismiss note |
518 // button: dismiss note |
519 var a_dismiss = document.createElement('a'); |
519 var a_dismiss = document.createElement('a'); |
520 a_dismiss.href = '#'; |
520 a_dismiss.href = '#'; |
521 a_dismiss.onclick = function() |
521 a_dismiss.onclick = function() |
522 { |
522 { |
523 var p = this.parentNode; |
523 var p = this.parentNode; |
524 domOpacity(p, 100, 0, 500); |
524 domOpacity(p, 100, 0, 500); |
525 window.setTimeout(function() |
525 window.setTimeout(function() |
526 { |
526 { |
527 p.parentNode.removeChild(p); |
527 p.parentNode.removeChild(p); |
528 }, 600); |
528 }, 600); |
529 return false; |
529 return false; |
530 } |
530 } |
531 a_dismiss.appendChild(document.createTextNode($lang.get('acl_btn_success_dismiss'))); |
531 a_dismiss.appendChild(document.createTextNode($lang.get('acl_btn_success_dismiss'))); |
532 note.appendChild(a_dismiss); |
532 note.appendChild(a_dismiss); |
533 // add a space |
533 // add a space |
534 note.appendChild(document.createTextNode(' / ')); |
534 note.appendChild(document.createTextNode(' / ')); |
535 |
535 |
536 // button: dismiss note |
536 // button: dismiss note |
537 var a_close = document.createElement('a'); |
537 var a_close = document.createElement('a'); |
538 a_close.href = '#'; |
538 a_close.href = '#'; |
539 a_close.onclick = function() |
539 a_close.onclick = function() |
540 { |
540 { |
541 killACLManager(); |
541 killACLManager(); |
542 return false; |
542 return false; |
543 } |
543 } |
544 a_close.appendChild(document.createTextNode($lang.get('acl_btn_success_close'))); |
544 a_close.appendChild(document.createTextNode($lang.get('acl_btn_success_close'))); |
545 note.appendChild(a_close); |
545 note.appendChild(a_close); |
546 |
546 |
547 // style note |
547 // style note |
548 domObjChangeOpac(note, 0); |
548 domObjChangeOpac(note, 0); |
549 note.style.position = 'absolute'; |
549 note.style.position = 'absolute'; |
550 // icon padding L + icon padding R + icon width + right padding + border width L + border width R |
550 // icon padding L + icon padding R + icon width + right padding + border width L + border width R |
551 note.style.width = ($dynano(aclManagerID + '_main').Width() - ( 5 + 5 + 16 + 4 + 1 + 1 )) + 'px'; |
551 note.style.width = ($dynano(aclManagerID + '_main').Width() - ( 5 + 5 + 16 + 4 + 1 + 1 )) + 'px'; |
552 |
552 |
553 // make tangible, then calculate height and position right above button panel |
553 // make tangible, then calculate height and position right above button panel |
554 var panel = document.getElementById(aclManagerID + '_panel'); |
554 var panel = document.getElementById(aclManagerID + '_panel'); |
555 panel.parentNode.parentNode.appendChild(note); |
555 panel.parentNode.parentNode.appendChild(note); |
556 note.style.top = '401px'; |
556 note.style.top = '401px'; |
557 note.style.left = '0px'; |
557 note.style.left = '0px'; |
558 |
558 |
559 opacity(note, 0, 100, 500); |
559 opacity(note, 0, 100, 500); |
560 } |
560 } |
561 }, true); |
561 }, true); |
562 |
562 |
563 break; |
563 break; |
564 case 'error': |
564 case 'error': |
565 alert("Server side processing error:\n"+data.error); |
565 alert("Server side processing error:\n"+data.error); |
566 break; |
566 break; |
567 case 'debug': |
567 case 'debug': |
568 aclDebug(data.text); |
568 aclDebug(data.text); |
569 break; |
569 break; |
570 case 'list_existing': |
570 case 'list_existing': |
571 aclSetViewListExistingRespond(data); |
571 aclSetViewListExistingRespond(data); |
572 break; |
572 break; |
573 case 'trace': |
573 case 'trace': |
574 aclDrawTraceWrapper(data); |
574 aclDrawTraceWrapper(data); |
575 break; |
575 break; |
576 default: |
576 default: |
577 handle_invalid_json(ajax.responseText); |
577 handle_invalid_json(ajax.responseText); |
578 break; |
578 break; |
579 } |
579 } |
580 } |
580 } |
581 }, true); |
581 }, true); |
582 } |
582 } |
583 |
583 |
584 function aclBuildRuleEditor(data, from_direct) |
584 function aclBuildRuleEditor(data, from_direct) |
585 { |
585 { |
586 var act_desc = ( data.type == 'new' ) ? $lang.get('acl_lbl_editwin_title_create') : $lang.get('acl_lbl_editwin_title_edit'); |
586 var act_desc = ( data.type == 'new' ) ? $lang.get('acl_lbl_editwin_title_create') : $lang.get('acl_lbl_editwin_title_edit'); |
587 var target_type_t = ( data.target_type == 1 ) ? $lang.get('acl_target_type_group') : $lang.get('acl_target_type_user'); |
587 var target_type_t = ( data.target_type == 1 ) ? $lang.get('acl_target_type_group') : $lang.get('acl_target_type_user'); |
588 var target_name_t = data.target_name; |
588 var target_name_t = data.target_name; |
589 var scope_type = ( data.page_id == false && data.namespace == false ) ? $lang.get('acl_scope_type_wholesite') : ( data.namespace == '__PageGroup' ) ? $lang.get('acl_scope_type_pagegroup') : $lang.get('acl_scope_type_thispage'); |
589 var scope_type = ( data.page_id == false && data.namespace == false ) ? $lang.get('acl_scope_type_wholesite') : ( data.namespace == '__PageGroup' ) ? $lang.get('acl_scope_type_pagegroup') : $lang.get('acl_scope_type_thispage'); |
590 |
590 |
591 document.getElementById(aclManagerID + '_next').style.display = 'inline'; |
591 document.getElementById(aclManagerID + '_next').style.display = 'inline'; |
592 |
592 |
593 html = '<h2>'+act_desc+'</h2>'; |
593 html = '<h2>'+act_desc+'</h2>'; |
594 html += '<p>' + $lang.get('acl_lbl_editwin_body', { target_type: target_type_t, target: target_name_t, scope_type: scope_type }) + '</p>'; |
594 html += '<p>' + $lang.get('acl_lbl_editwin_body', { target_type: target_type_t, target: target_name_t, scope_type: scope_type }) + '</p>'; |
595 |
595 |
596 // preset management |
596 // preset management |
597 var load_flags = 'href="#" onclick="aclShowPresetLoader(); return false;"'; |
597 var load_flags = 'href="#" onclick="aclShowPresetLoader(); return false;"'; |
598 var save_flags = 'href="#" onclick="aclShowPresetSave(); return false;"'; |
598 var save_flags = 'href="#" onclick="aclShowPresetSave(); return false;"'; |
599 html += '<div style="float: right;">'; |
599 html += '<div style="float: right;">'; |
600 html += $lang.get('acl_btn_edit_presets', { load_flags: load_flags, save_flags: save_flags }); |
600 html += $lang.get('acl_btn_edit_presets', { load_flags: load_flags, save_flags: save_flags }); |
601 html += '</div>'; |
601 html += '</div>'; |
602 html += '<div style="clear: both;"></div>'; |
602 html += '<div style="clear: both;"></div>'; |
603 |
603 |
604 parser = new templateParser(data.template.acl_field_begin); |
604 parser = new templateParser(data.template.acl_field_begin); |
605 html += parser.run(); |
605 html += parser.run(); |
606 |
606 |
607 cls = 'row2'; |
607 cls = 'row2'; |
608 for(var i in data.acl_types) |
608 for(var i in data.acl_types) |
609 { |
609 { |
610 if(typeof(data.acl_types[i]) == 'number') |
610 if(typeof(data.acl_types[i]) == 'number') |
611 { |
611 { |
612 cls = ( cls == 'row1' ) ? 'row2' : 'row1'; |
612 cls = ( cls == 'row1' ) ? 'row2' : 'row1'; |
613 p = new templateParser(data.template.acl_field_item); |
613 p = new templateParser(data.template.acl_field_item); |
614 vars = new Object(); |
614 vars = new Object(); |
615 if ( data.acl_descs[i].match(/^([a-z0-9_]+)$/) ) |
615 if ( data.acl_descs[i].match(/^([a-z0-9_]+)$/) ) |
616 { |
616 { |
617 vars['FIELD_DESC'] = $lang.get(data.acl_descs[i]); |
617 vars['FIELD_DESC'] = $lang.get(data.acl_descs[i]); |
618 } |
618 } |
619 else |
619 else |
620 { |
620 { |
621 vars['FIELD_DESC'] = data.acl_descs[i]; |
621 vars['FIELD_DESC'] = data.acl_descs[i]; |
622 } |
622 } |
623 vars['FIELD_INHERIT_CHECKED'] = ''; |
623 vars['FIELD_INHERIT_CHECKED'] = ''; |
624 vars['FIELD_DENY_CHECKED'] = ''; |
624 vars['FIELD_DENY_CHECKED'] = ''; |
625 vars['FIELD_DISALLOW_CHECKED'] = ''; |
625 vars['FIELD_DISALLOW_CHECKED'] = ''; |
626 vars['FIELD_WIKIMODE_CHECKED'] = ''; |
626 vars['FIELD_WIKIMODE_CHECKED'] = ''; |
627 vars['FIELD_ALLOW_CHECKED'] = ''; |
627 vars['FIELD_ALLOW_CHECKED'] = ''; |
628 vars['FIELD_NAME'] = i; |
628 vars['FIELD_NAME'] = i; |
629 if ( !data.current_perms[i] ) |
629 if ( !data.current_perms[i] ) |
630 { |
630 { |
631 data.current_perms[i] = 'i'; |
631 data.current_perms[i] = 'i'; |
632 } |
632 } |
633 switch(data.current_perms[i]) |
633 switch(data.current_perms[i]) |
634 { |
634 { |
635 case 'i': |
635 case 'i': |
636 default: |
636 default: |
637 vars['FIELD_INHERIT_CHECKED'] = 'checked="checked"'; |
637 vars['FIELD_INHERIT_CHECKED'] = 'checked="checked"'; |
638 break; |
638 break; |
639 case 1: |
639 case 1: |
640 vars['FIELD_DENY_CHECKED'] = 'checked="checked"'; |
640 vars['FIELD_DENY_CHECKED'] = 'checked="checked"'; |
641 break; |
641 break; |
642 case 2: |
642 case 2: |
643 vars['FIELD_DISALLOW_CHECKED'] = 'checked="checked"'; |
643 vars['FIELD_DISALLOW_CHECKED'] = 'checked="checked"'; |
644 break; |
644 break; |
645 case 3: |
645 case 3: |
646 vars['FIELD_WIKIMODE_CHECKED'] = 'checked="checked"'; |
646 vars['FIELD_WIKIMODE_CHECKED'] = 'checked="checked"'; |
647 break; |
647 break; |
648 case 4: |
648 case 4: |
649 vars['FIELD_ALLOW_CHECKED'] = 'checked="checked"'; |
649 vars['FIELD_ALLOW_CHECKED'] = 'checked="checked"'; |
650 break; |
650 break; |
651 } |
651 } |
652 vars['ROW_CLASS'] = cls; |
652 vars['ROW_CLASS'] = cls; |
653 p.assign_vars(vars); |
653 p.assign_vars(vars); |
654 html += p.run(); |
654 html += p.run(); |
655 } |
655 } |
656 } |
656 } |
657 |
657 |
658 var parser = new templateParser(data.template.acl_field_end); |
658 var parser = new templateParser(data.template.acl_field_end); |
659 html += parser.run(); |
659 html += parser.run(); |
660 |
660 |
661 if(data.type == 'edit') |
661 if(data.type == 'edit') |
662 html += '<p id="'+aclManagerID+'_deletelnk" style="text-align: right;"><a href="#delete_acl_rule" onclick="if(confirm(\'' + $lang.get('acl_msg_deleterule_confirm') + '\')) __aclDeleteRule(); return false;" style="color: red;">' + $lang.get('acl_lbl_deleterule') + '</a></p>'; |
662 html += '<p id="'+aclManagerID+'_deletelnk" style="text-align: right;"><a href="#delete_acl_rule" onclick="if(confirm(\'' + $lang.get('acl_msg_deleterule_confirm') + '\')) __aclDeleteRule(); return false;" style="color: red;">' + $lang.get('acl_lbl_deleterule') + '</a></p>'; |
663 |
663 |
664 var main = document.getElementById(aclManagerID + '_main'); |
664 var main = document.getElementById(aclManagerID + '_main'); |
665 main.innerHTML = html; |
665 main.innerHTML = html; |
666 |
666 |
667 var form = document.getElementById(aclManagerID + '_formobj_id'); |
667 var form = document.getElementById(aclManagerID + '_formobj_id'); |
668 |
668 |
669 if ( from_direct ) |
669 if ( from_direct ) |
670 { |
670 { |
671 var modeobj = document.getElementById(aclManagerID + '_mode'); |
671 var modeobj = document.getElementById(aclManagerID + '_mode'); |
672 modeobj.value = 'save_edit'; |
672 modeobj.value = 'save_edit'; |
673 } |
673 } |
674 else |
674 else |
675 { |
675 { |
676 var modeobj = form_fetch_field(form, 'mode'); |
676 var modeobj = form_fetch_field(form, 'mode'); |
677 if ( modeobj ) |
677 if ( modeobj ) |
678 modeobj.value = 'save_' + data.type; |
678 modeobj.value = 'save_' + data.type; |
679 else |
679 else |
680 alert('modeobj is invalid: '+modeobj); |
680 alert('modeobj is invalid: '+modeobj); |
681 } |
681 } |
682 |
682 |
683 aclPermList = array_keys(data.acl_types); |
683 aclPermList = array_keys(data.acl_types); |
684 |
684 |
685 document.getElementById(aclManagerID + '_back').style.display = 'inline'; |
685 document.getElementById(aclManagerID + '_back').style.display = 'inline'; |
686 document.getElementById(aclManagerID + '_next').value = $lang.get('etc_save_changes'); |
686 document.getElementById(aclManagerID + '_next').value = $lang.get('etc_save_changes'); |
687 } |
687 } |
688 |
688 |
689 function __aclBuildGroupsHTML(groups) |
689 function __aclBuildGroupsHTML(groups) |
690 { |
690 { |
691 var groups = groups.groups; |
691 var groups = groups.groups; |
692 select = document.createElement('select'); |
692 select = document.createElement('select'); |
693 for(var i in groups) |
693 for(var i in groups) |
694 { |
694 { |
695 if(typeof(groups[i]['name']) == 'string' && i != 'toJSONString') |
695 if(typeof(groups[i]['name']) == 'string' && i != 'toJSONString') |
696 { |
696 { |
697 o = document.createElement('option'); |
697 o = document.createElement('option'); |
698 o.value = groups[i]['id']; |
698 o.value = groups[i]['id']; |
699 t = document.createTextNode(groups[i]['name']); |
699 t = document.createTextNode(groups[i]['name']); |
700 o.appendChild(t); |
700 o.appendChild(t); |
701 select.appendChild(o); |
701 select.appendChild(o); |
702 } |
702 } |
703 } |
703 } |
704 return select; |
704 return select; |
705 } |
705 } |
706 |
706 |
707 function __aclBuildWizardWindow() |
707 function __aclBuildWizardWindow() |
708 { |
708 { |
709 darken(aclDisableTransitionFX, 70, 'acldarkener'); |
709 darken(aclDisableTransitionFX, 70, 'acldarkener'); |
710 var box = document.createElement('div'); |
710 var box = document.createElement('div'); |
711 box.style.width = '640px' |
711 box.style.width = '640px' |
712 box.style.height = IE ? '500px' : '440px'; |
712 box.style.height = IE ? '500px' : '440px'; |
713 box.style.position = 'fixed'; |
713 box.style.position = 'fixed'; |
714 width = getWidth(); |
714 width = getWidth(); |
715 height = getHeight(); |
715 height = getHeight(); |
716 box.style.left = ( width / 2 - 320 ) + 'px'; |
716 box.style.left = ( width / 2 - 320 ) + 'px'; |
717 box.style.top = ( height / 2 - 250 ) + 'px'; |
717 box.style.top = ( height / 2 - 250 ) + 'px'; |
718 box.style.backgroundColor = 'white'; |
718 box.style.backgroundColor = 'white'; |
719 box.style.zIndex = getHighestZ() + 1; |
719 box.style.zIndex = getHighestZ() + 1; |
720 box.id = aclManagerID; |
720 box.id = aclManagerID; |
721 box.style.opacity = '0'; |
721 box.style.opacity = '0'; |
722 box.style.filter = 'alpha(opacity=0)'; |
722 box.style.filter = 'alpha(opacity=0)'; |
723 box.style.display = 'none'; |
723 box.style.display = 'none'; |
724 |
724 |
725 var mainwin = document.createElement('div'); |
725 var mainwin = document.createElement('div'); |
726 mainwin.id = aclManagerID + '_main'; |
726 mainwin.id = aclManagerID + '_main'; |
727 mainwin.style.clip = 'rect(0px,640px,440px,0px)'; |
727 mainwin.style.clip = 'rect(0px,640px,440px,0px)'; |
728 mainwin.style.overflow = 'auto'; |
728 mainwin.style.overflow = 'auto'; |
729 mainwin.style.width = '620px'; |
729 mainwin.style.width = '620px'; |
730 mainwin.style.height = '420px'; |
730 mainwin.style.height = '420px'; |
731 |
731 |
732 var panel = document.createElement('div'); |
732 var panel = document.createElement('div'); |
733 panel.style.width = '620px'; |
733 panel.style.width = '620px'; |
734 panel.style.padding = '10px'; |
734 panel.style.padding = '10px'; |
735 panel.style.lineHeight = '40px'; |
735 panel.style.lineHeight = '40px'; |
736 panel.style.textAlign = 'right'; |
736 panel.style.textAlign = 'right'; |
737 panel.style.position = 'fixed'; |
737 panel.style.position = 'fixed'; |
738 if ( IE ) |
738 if ( IE ) |
739 { |
739 { |
740 panel.style.left = '0px'; |
740 panel.style.left = '0px'; |
741 panel.style.top = '440px'; |
741 panel.style.top = '440px'; |
742 } |
742 } |
743 else |
743 else |
744 { |
744 { |
745 panel.style.left = ( width / 2 - 320 ) + 'px'; |
745 panel.style.left = ( width / 2 - 320 ) + 'px'; |
746 panel.style.top = ( height / 2 + 190 ) + 'px'; |
746 panel.style.top = ( height / 2 + 190 ) + 'px'; |
747 } |
747 } |
748 panel.style.backgroundColor = '#D0D0D0'; |
748 panel.style.backgroundColor = '#D0D0D0'; |
749 panel.style.opacity = '0'; |
749 panel.style.opacity = '0'; |
750 panel.style.filter = 'alpha(opacity=0)'; |
750 panel.style.filter = 'alpha(opacity=0)'; |
751 panel.id = aclManagerID + '_panel'; |
751 panel.id = aclManagerID + '_panel'; |
752 |
752 |
753 var form = document.createElement('form'); |
753 var form = document.createElement('form'); |
754 form.method = 'post'; |
754 form.method = 'post'; |
755 form.action = 'javascript:void(0)'; |
755 form.action = 'javascript:void(0)'; |
756 form.onsubmit = function() { if(this.username && !submitAuthorized) return false; __aclSubmitManager(this); return false; }; |
756 form.onsubmit = function() { if(this.username && !submitAuthorized) return false; __aclSubmitManager(this); return false; }; |
757 form.name = aclManagerID + '_formobj'; |
757 form.name = aclManagerID + '_formobj'; |
758 form.id = aclManagerID + '_formobj_id'; |
758 form.id = aclManagerID + '_formobj_id'; |
759 |
759 |
760 var back = document.createElement('input'); |
760 var back = document.createElement('input'); |
761 back.type = 'button'; |
761 back.type = 'button'; |
762 back.value = $lang.get('etc_wizard_back'); |
762 back.value = $lang.get('etc_wizard_back'); |
763 back.style.fontWeight = 'normal'; |
763 back.style.fontWeight = 'normal'; |
764 back.onclick = function() { ajaxACLSwitchToSelector(); return false; }; |
764 back.onclick = function() { ajaxACLSwitchToSelector(); return false; }; |
765 back.style.display = 'none'; |
765 back.style.display = 'none'; |
766 back.id = aclManagerID + '_back'; |
766 back.id = aclManagerID + '_back'; |
767 |
767 |
768 var saver = document.createElement('input'); |
768 var saver = document.createElement('input'); |
769 saver.type = 'submit'; |
769 saver.type = 'submit'; |
770 saver.value = $lang.get('etc_wizard_next'); |
770 saver.value = $lang.get('etc_wizard_next'); |
771 saver.style.fontWeight = 'bold'; |
771 saver.style.fontWeight = 'bold'; |
772 saver.id = aclManagerID + '_next'; |
772 saver.id = aclManagerID + '_next'; |
773 |
773 |
774 var closer = document.createElement('input'); |
774 var closer = document.createElement('input'); |
775 closer.type = 'button'; |
775 closer.type = 'button'; |
776 closer.value = $lang.get('etc_cancel_changes'); |
776 closer.value = $lang.get('etc_cancel_changes'); |
777 closer.onclick = function() |
777 closer.onclick = function() |
778 { |
778 { |
779 miniPromptMessage({ |
779 miniPromptMessage({ |
780 title: $lang.get('acl_msg_closeacl_confirm_title'), |
780 title: $lang.get('acl_msg_closeacl_confirm_title'), |
781 message: $lang.get('acl_msg_closeacl_confirm_body'), |
781 message: $lang.get('acl_msg_closeacl_confirm_body'), |
782 buttons: [ |
782 buttons: [ |
783 { |
783 { |
784 text: $lang.get('acl_btn_close'), |
784 text: $lang.get('acl_btn_close'), |
785 color: 'red', |
785 color: 'red', |
786 style: { |
786 style: { |
787 fontWeight: 'bold' |
787 fontWeight: 'bold' |
788 }, |
788 }, |
789 onclick: function(e) |
789 onclick: function(e) |
790 { |
790 { |
791 killACLManager(); |
791 killACLManager(); |
792 miniPromptDestroy(this); |
792 miniPromptDestroy(this); |
793 } |
793 } |
794 }, |
794 }, |
795 { |
795 { |
796 text: $lang.get('etc_cancel'), |
796 text: $lang.get('etc_cancel'), |
797 onclick: function(e) |
797 onclick: function(e) |
798 { |
798 { |
799 miniPromptDestroy(this); |
799 miniPromptDestroy(this); |
800 } |
800 } |
801 } |
801 } |
802 ] |
802 ] |
803 }); |
803 }); |
804 return false; |
804 return false; |
805 } |
805 } |
806 |
806 |
807 var spacer1 = document.createTextNode(' '); |
807 var spacer1 = document.createTextNode(' '); |
808 var spacer2 = document.createTextNode(' '); |
808 var spacer2 = document.createTextNode(' '); |
809 |
809 |
810 panel.appendChild(back); |
810 panel.appendChild(back); |
811 panel.appendChild(spacer1); |
811 panel.appendChild(spacer1); |
812 panel.appendChild(saver); |
812 panel.appendChild(saver); |
813 panel.appendChild(spacer2); |
813 panel.appendChild(spacer2); |
814 panel.appendChild(closer); |
814 panel.appendChild(closer); |
815 form.appendChild(mainwin); |
815 form.appendChild(mainwin); |
816 form.appendChild(panel); |
816 form.appendChild(panel); |
817 box.appendChild(form); |
817 box.appendChild(form); |
818 |
818 |
819 var body = document.getElementsByTagName('body')[0]; |
819 var body = document.getElementsByTagName('body')[0]; |
820 body.appendChild(box); |
820 body.appendChild(box); |
821 if ( aclDisableTransitionFX ) |
821 if ( aclDisableTransitionFX ) |
822 { |
822 { |
823 document.getElementById(aclManagerID).style.display = 'block'; |
823 document.getElementById(aclManagerID).style.display = 'block'; |
824 changeOpac(100, aclManagerID); |
824 changeOpac(100, aclManagerID); |
825 changeOpac(100, aclManagerID + '_panel'); |
825 changeOpac(100, aclManagerID + '_panel'); |
826 } |
826 } |
827 else |
827 else |
828 { |
828 { |
829 setTimeout("document.getElementById('"+aclManagerID+"').style.display = 'block'; opacity('"+aclManagerID+"', 0, 100, 250); opacity('"+aclManagerID + '_panel'+"', 0, 100, 250);", 500); |
829 setTimeout("document.getElementById('"+aclManagerID+"').style.display = 'block'; opacity('"+aclManagerID+"', 0, 100, 250); opacity('"+aclManagerID + '_panel'+"', 0, 100, 250);", 500); |
830 } |
830 } |
831 |
831 |
832 console.debug(panel); |
832 console.debug(panel); |
833 } |
833 } |
834 |
834 |
835 function killACLManager() |
835 function killACLManager() |
836 { |
836 { |
837 el = document.getElementById(aclManagerID); |
837 el = document.getElementById(aclManagerID); |
838 if(el) |
838 if(el) |
839 { |
839 { |
840 if ( aclDisableTransitionFX ) |
840 if ( aclDisableTransitionFX ) |
841 { |
841 { |
842 enlighten(true, 'acldarkener'); |
842 enlighten(true, 'acldarkener'); |
843 el.parentNode.removeChild(el); |
843 el.parentNode.removeChild(el); |
844 } |
844 } |
845 else |
845 else |
846 { |
846 { |
847 opacity(aclManagerID, 100, 0, 500); |
847 opacity(aclManagerID, 100, 0, 500); |
848 setTimeout('var el = document.getElementById(aclManagerID); el.parentNode.removeChild(el); enlighten(false, "acldarkener");', 750); |
848 setTimeout('var el = document.getElementById(aclManagerID); el.parentNode.removeChild(el); enlighten(false, "acldarkener");', 750); |
849 } |
849 } |
850 } |
850 } |
851 } |
851 } |
852 |
852 |
853 function __aclSubmitManager(form) |
853 function __aclSubmitManager(form) |
854 { |
854 { |
855 console.debug(form); |
855 console.debug(form); |
856 var thefrm = form; |
856 var thefrm = form; |
857 // var thefrm = document.forms[form.name]; |
857 // var thefrm = document.forms[form.name]; |
858 var modeobj = form_fetch_field(thefrm, 'mode'); |
858 var modeobj = form_fetch_field(thefrm, 'mode'); |
859 if ( typeof(modeobj) == 'object' ) |
859 if ( typeof(modeobj) == 'object' ) |
860 { |
860 { |
861 var mode = (thefrm.mode.value) ? thefrm.mode.value : 'cant_get'; |
861 var mode = (thefrm.mode.value) ? thefrm.mode.value : 'cant_get'; |
862 } |
862 } |
863 else |
863 else |
864 { |
864 { |
865 var mode = ''; |
865 var mode = ''; |
866 } |
866 } |
867 switch(mode) |
867 switch(mode) |
868 { |
868 { |
869 case 'cant_get': |
869 case 'cant_get': |
870 alert('BUG: can\'t get the state value from the form field.'); |
870 alert('BUG: can\'t get the state value from the form field.'); |
871 break; |
871 break; |
872 case 'seltarget': |
872 case 'seltarget': |
873 var target_type = parseInt(getRadioState(thefrm, 'target_type', ['1', '2'])); |
873 var target_type = parseInt(getRadioState(thefrm, 'target_type', ['1', '2'])); |
874 if(isNaN(target_type)) |
874 if(isNaN(target_type)) |
875 { |
875 { |
876 alert($lang.get('acl_err_pleaseselect_targettype')); |
876 alert($lang.get('acl_err_pleaseselect_targettype')); |
877 return false; |
877 return false; |
878 } |
878 } |
879 target_id = ( target_type == 1 ) ? parseInt(thefrm.group_id.value) : thefrm.username.value; |
879 target_id = ( target_type == 1 ) ? parseInt(thefrm.group_id.value) : thefrm.username.value; |
880 |
880 |
881 obj = { 'mode' : mode, 'target_type' : target_type, 'target_id' : target_id }; |
881 obj = { 'mode' : mode, 'target_type' : target_type, 'target_id' : target_id }; |
882 |
882 |
883 thispage = strToPageID(title); |
883 thispage = strToPageID(title); |
884 do_scopesel = ( thispage[0] == aclDataCache.page_id && thispage[1] == aclDataCache.namespace ); |
884 do_scopesel = ( thispage[0] == aclDataCache.page_id && thispage[1] == aclDataCache.namespace ); |
885 |
885 |
886 if(do_scopesel) |
886 if(do_scopesel) |
887 { |
887 { |
888 scope = getRadioState(thefrm, 'scope', ['page', 'group', 'global']); |
888 scope = getRadioState(thefrm, 'scope', ['page', 'group', 'global']); |
889 if(scope == 'page') |
889 if(scope == 'page') |
890 { |
890 { |
891 pageid = strToPageID(title); |
891 pageid = strToPageID(title); |
892 obj['page_id'] = pageid[0]; |
892 obj['page_id'] = pageid[0]; |
893 obj['namespace'] = pageid[1]; |
893 obj['namespace'] = pageid[1]; |
894 } |
894 } |
895 else if(scope == 'global') |
895 else if(scope == 'global') |
896 { |
896 { |
897 obj['page_id'] = false; |
897 obj['page_id'] = false; |
898 obj['namespace'] = false; |
898 obj['namespace'] = false; |
899 } |
899 } |
900 else if(scope == 'group') |
900 else if(scope == 'group') |
901 { |
901 { |
902 obj['page_id'] = document.getElementById('enACL_pgsel_1048576').value; |
902 obj['page_id'] = document.getElementById('enACL_pgsel_1048576').value; |
903 obj['namespace'] = '__PageGroup'; |
903 obj['namespace'] = '__PageGroup'; |
904 } |
904 } |
905 else |
905 else |
906 { |
906 { |
907 alert('Invalid scope'); |
907 alert('Invalid scope'); |
908 return false; |
908 return false; |
909 } |
909 } |
910 } |
910 } |
911 else |
911 else |
912 { |
912 { |
913 obj['page_id'] = aclDataCache.page_id; |
913 obj['page_id'] = aclDataCache.page_id; |
914 obj['namespace'] = aclDataCache.namespace; |
914 obj['namespace'] = aclDataCache.namespace; |
915 } |
915 } |
916 if(target_id == '') |
916 if(target_id == '') |
917 { |
917 { |
918 alert($lang.get('acl_err_pleaseselect_username')); |
918 alert($lang.get('acl_err_pleaseselect_username')); |
919 return false; |
919 return false; |
920 } |
920 } |
921 __aclJSONSubmitAjaxHandler(obj); |
921 __aclJSONSubmitAjaxHandler(obj); |
922 break; |
922 break; |
923 case 'save_edit': |
923 case 'save_edit': |
924 case 'save_new': |
924 case 'save_new': |
925 var form = document.forms[aclManagerID + '_formobj']; |
925 var form = document.forms[aclManagerID + '_formobj']; |
926 selections = new Object(); |
926 selections = new Object(); |
927 var dbg = ''; |
927 var dbg = ''; |
928 var warned_everyone = false; |
928 var warned_everyone = false; |
929 for(var i in aclPermList) |
929 for(var i in aclPermList) |
930 { |
930 { |
931 selections[aclPermList[i]] = getRadioState(form, aclPermList[i], ['i', 1, 2, 3, 4]); |
931 selections[aclPermList[i]] = getRadioState(form, aclPermList[i], ['i', 1, 2, 3, 4]); |
932 // If we're editing permissions for everyone on the entire site and the |
932 // If we're editing permissions for everyone on the entire site and the |
933 // admin selected to deny privileges, give a stern warning about it. |
933 // admin selected to deny privileges, give a stern warning about it. |
934 if ( selections[aclPermList[i]] == 1 && aclDataCache.target_type == 1 /* ACL_TYPE_GROUP */ && aclDataCache.target_id == 1 && !warned_everyone ) |
934 if ( selections[aclPermList[i]] == 1 && aclDataCache.target_type == 1 /* ACL_TYPE_GROUP */ && aclDataCache.target_id == 1 && !warned_everyone ) |
935 { |
935 { |
936 warned_everyone = true; |
936 warned_everyone = true; |
937 if ( !confirm($lang.get('acl_msg_deny_everyone_confirm')) ) |
937 if ( !confirm($lang.get('acl_msg_deny_everyone_confirm')) ) |
938 { |
938 { |
939 return false; |
939 return false; |
940 } |
940 } |
941 } |
941 } |
942 dbg += aclPermList[i] + ': ' + selections[aclPermList[i]] + "\n"; |
942 dbg += aclPermList[i] + ': ' + selections[aclPermList[i]] + "\n"; |
943 if(!selections[aclPermList[i]]) |
943 if(!selections[aclPermList[i]]) |
944 { |
944 { |
945 alert("Invalid return from getRadioState: "+i+": "+selections[i]+" ("+typeof(selections[i])+")"); |
945 alert("Invalid return from getRadioState: "+i+": "+selections[i]+" ("+typeof(selections[i])+")"); |
946 return false; |
946 return false; |
947 } |
947 } |
948 } |
948 } |
949 obj = new Object(); |
949 obj = new Object(); |
950 obj['perms'] = selections; |
950 obj['perms'] = selections; |
951 obj['mode'] = mode; |
951 obj['mode'] = mode; |
952 obj['target_type'] = aclDataCache.target_type; |
952 obj['target_type'] = aclDataCache.target_type; |
953 obj['target_id'] = aclDataCache.target_id; |
953 obj['target_id'] = aclDataCache.target_id; |
954 obj['target_name'] = aclDataCache.target_name; |
954 obj['target_name'] = aclDataCache.target_name; |
955 obj['page_id'] = aclDataCache.page_id; |
955 obj['page_id'] = aclDataCache.page_id; |
956 obj['namespace'] = aclDataCache.namespace; |
956 obj['namespace'] = aclDataCache.namespace; |
957 __aclJSONSubmitAjaxHandler(obj); |
957 __aclJSONSubmitAjaxHandler(obj); |
958 break; |
958 break; |
959 case 'trace': |
959 case 'trace': |
960 var params = { |
960 var params = { |
961 mode: 'trace', |
961 mode: 'trace', |
962 user: document.getElementById(aclManagerID + 'trace_user').value, |
962 user: document.getElementById(aclManagerID + 'trace_user').value, |
963 page: document.getElementById(aclManagerID + 'trace_page').value |
963 page: document.getElementById(aclManagerID + 'trace_page').value |
964 }; |
964 }; |
965 __aclJSONSubmitAjaxHandler(params); |
965 __aclJSONSubmitAjaxHandler(params); |
966 break; |
966 break; |
967 default: |
967 default: |
968 alert("JSON form submit: invalid mode string "+mode+", stopping execution"); |
968 alert("JSON form submit: invalid mode string "+mode+", stopping execution"); |
969 return false; |
969 return false; |
970 break; |
970 break; |
971 } |
971 } |
972 } |
972 } |
973 |
973 |
974 function getRadioState(form, name, valArray) |
974 function getRadioState(form, name, valArray) |
975 { |
975 { |
976 // Konqueror/Safari fix |
976 // Konqueror/Safari fix |
977 if ( form[name] ) |
977 if ( form[name] ) |
978 { |
978 { |
979 var formitem = form[name]; |
979 var formitem = form[name]; |
980 if ( String(formitem) == '[object DOMNamedNodesCollection]' || is_Safari ) |
980 if ( String(formitem) == '[object DOMNamedNodesCollection]' || is_Safari ) |
981 { |
981 { |
982 var i = 0; |
982 var i = 0; |
983 var radios = new Array(); |
983 var radios = new Array(); |
984 var radioids = new Array(); |
984 var radioids = new Array(); |
985 while(true) |
985 while(true) |
986 { |
986 { |
987 var elem = formitem[i]; |
987 var elem = formitem[i]; |
988 if ( !elem ) |
988 if ( !elem ) |
989 break; |
989 break; |
990 radios.push(elem); |
990 radios.push(elem); |
991 if ( !elem.id ) |
991 if ( !elem.id ) |
992 { |
992 { |
993 elem.id = 'autoRadioBtn_' + Math.floor(Math.random() * 1000000); |
993 elem.id = 'autoRadioBtn_' + Math.floor(Math.random() * 1000000); |
994 } |
994 } |
995 radioids.push(elem.id); |
995 radioids.push(elem.id); |
996 i++; |
996 i++; |
997 } |
997 } |
998 var cr; |
998 var cr; |
999 for ( var i = 0; i < radios.length; i++ ) |
999 for ( var i = 0; i < radios.length; i++ ) |
1000 { |
1000 { |
1001 cr = document.getElementById(radioids[i]); |
1001 cr = document.getElementById(radioids[i]); |
1002 if ( cr.value == 'on' || cr.checked == true ) |
1002 if ( cr.value == 'on' || cr.checked == true ) |
1003 { |
1003 { |
1004 try { |
1004 try { |
1005 return ( typeof ( valArray[i] ) != 'undefined' ) ? valArray[i] : false; |
1005 return ( typeof ( valArray[i] ) != 'undefined' ) ? valArray[i] : false; |
1006 } catch(e) { |
1006 } catch(e) { |
1007 // alert('Didn\'t get value for index: ' + i); |
1007 // alert('Didn\'t get value for index: ' + i); |
1008 return false; |
1008 return false; |
1009 } |
1009 } |
1010 } |
1010 } |
1011 } |
1011 } |
1012 return false; |
1012 return false; |
1013 } |
1013 } |
1014 } |
1014 } |
1015 inputs = form.getElementsByTagName('input'); |
1015 inputs = form.getElementsByTagName('input'); |
1016 radios = new Array(); |
1016 radios = new Array(); |
1017 for(var i in inputs) |
1017 for(var i in inputs) |
1018 { |
1018 { |
1019 if(inputs[i]) if(inputs[i].type == 'radio') |
1019 if(inputs[i]) if(inputs[i].type == 'radio') |
1020 radios.push(inputs[i]); |
1020 radios.push(inputs[i]); |
1021 } |
1021 } |
1022 for(var i in radios) |
1022 for(var i in radios) |
1023 { |
1023 { |
1024 if(radios[i].checked && radios[i].name == name) |
1024 if(radios[i].checked && radios[i].name == name) |
1025 return radios[i].value; |
1025 return radios[i].value; |
1026 } |
1026 } |
1027 return false; |
1027 return false; |
1028 } |
1028 } |
1029 |
1029 |
1030 function __aclSetAllRadios(val, valArray) |
1030 function __aclSetAllRadios(val, valArray) |
1031 { |
1031 { |
1032 val = String(val); |
1032 val = String(val); |
1033 var form = document.forms[aclManagerID + '_formobj']; |
1033 var form = document.forms[aclManagerID + '_formobj']; |
1034 if (!form) |
1034 if (!form) |
1035 { |
1035 { |
1036 return false; |
1036 return false; |
1037 } |
1037 } |
1038 var inputs = form.getElementsByTagName('input'); |
1038 var inputs = form.getElementsByTagName('input'); |
1039 var radios = new Array(); |
1039 var radios = new Array(); |
1040 var dbg = ''; |
1040 var dbg = ''; |
1041 for(var i = 0; i < inputs.length; i++) |
1041 for(var i = 0; i < inputs.length; i++) |
1042 { |
1042 { |
1043 dbg += String(inputs[i]) + "\n"; |
1043 dbg += String(inputs[i]) + "\n"; |
1044 if(inputs[i].type == 'radio') |
1044 if(inputs[i].type == 'radio') |
1045 radios.push(inputs[i]); |
1045 radios.push(inputs[i]); |
1046 } |
1046 } |
1047 for(var i in radios) |
1047 for(var i in radios) |
1048 { |
1048 { |
1049 if(radios[i].value == val) |
1049 if(radios[i].value == val) |
1050 radios[i].checked = true; |
1050 radios[i].checked = true; |
1051 else |
1051 else |
1052 radios[i].checked = false; |
1052 radios[i].checked = false; |
1053 } |
1053 } |
1054 } |
1054 } |
1055 |
1055 |
1056 function __aclDeleteRule() |
1056 function __aclDeleteRule() |
1057 { |
1057 { |
1058 if(!aclDataCache) |
1058 if(!aclDataCache) |
1059 { |
1059 { |
1060 if ( window.console ) |
1060 if ( window.console ) |
1061 { |
1061 { |
1062 try{ console.error('ACL editor: can\'t load data cache on delete'); } catch(e) {}; |
1062 try{ console.error('ACL editor: can\'t load data cache on delete'); } catch(e) {}; |
1063 } |
1063 } |
1064 return false; |
1064 return false; |
1065 } |
1065 } |
1066 if(aclDataCache.mode != 'seltarget' && aclDataCache.mode != 'save_new' && aclDataCache.mode != 'save_edit') |
1066 if(aclDataCache.mode != 'seltarget' && aclDataCache.mode != 'save_new' && aclDataCache.mode != 'save_edit') |
1067 { |
1067 { |
1068 if ( window.console ) |
1068 if ( window.console ) |
1069 { |
1069 { |
1070 try{ console.error('ACL editor: wrong mode on aclDataCache: ' + aclDataCache.mode); } catch(e) {}; |
1070 try{ console.error('ACL editor: wrong mode on aclDataCache: ' + aclDataCache.mode); } catch(e) {}; |
1071 } |
1071 } |
1072 return false; |
1072 return false; |
1073 } |
1073 } |
1074 parms = { |
1074 parms = { |
1075 'target_type' : aclDataCache.target_type, |
1075 'target_type' : aclDataCache.target_type, |
1076 'target_id' : aclDataCache.target_id, |
1076 'target_id' : aclDataCache.target_id, |
1077 'target_name' : aclDataCache.target_name, |
1077 'target_name' : aclDataCache.target_name, |
1078 'page_id' : aclDataCache.page_id, |
1078 'page_id' : aclDataCache.page_id, |
1079 'namespace' : aclDataCache.namespace, |
1079 'namespace' : aclDataCache.namespace, |
1080 'mode' : 'delete' |
1080 'mode' : 'delete' |
1081 }; |
1081 }; |
1082 __aclJSONSubmitAjaxHandler(parms); |
1082 __aclJSONSubmitAjaxHandler(parms); |
1083 } |
1083 } |
1084 |
1084 |
1085 function aclSetViewListExisting() |
1085 function aclSetViewListExisting() |
1086 { |
1086 { |
1087 if ( !document.getElementById(aclManagerID) ) |
1087 if ( !document.getElementById(aclManagerID) ) |
1088 { |
1088 { |
1089 return false; |
1089 return false; |
1090 } |
1090 } |
1091 |
1091 |
1092 var main = document.getElementById(aclManagerID + '_main'); |
1092 var main = document.getElementById(aclManagerID + '_main'); |
1093 main.innerHTML = ''; |
1093 main.innerHTML = ''; |
1094 main.style.backgroundImage = 'url(' + scriptPath + '/images/loading-big.gif)'; |
1094 main.style.backgroundImage = 'url(' + scriptPath + '/images/loading-big.gif)'; |
1095 main.style.backgroundRepeat = 'no-repeat'; |
1095 main.style.backgroundRepeat = 'no-repeat'; |
1096 main.style.backgroundPosition = 'center center'; |
1096 main.style.backgroundPosition = 'center center'; |
1097 |
1097 |
1098 var parms = { |
1098 var parms = { |
1099 'mode' : 'list_existing' |
1099 'mode' : 'list_existing' |
1100 }; |
1100 }; |
1101 __aclJSONSubmitAjaxHandler(parms); |
1101 __aclJSONSubmitAjaxHandler(parms); |
1102 } |
1102 } |
1103 |
1103 |
1104 function aclSetViewListExistingRespond(data) |
1104 function aclSetViewListExistingRespond(data) |
1105 { |
1105 { |
1106 var main = document.getElementById(aclManagerID + '_main'); |
1106 var main = document.getElementById(aclManagerID + '_main'); |
1107 main.style.padding = '10px'; |
1107 main.style.padding = '10px'; |
1108 main.innerHTML = ''; |
1108 main.innerHTML = ''; |
1109 |
1109 |
1110 var heading = document.createElement('h3'); |
1110 var heading = document.createElement('h3'); |
1111 heading.appendChild(document.createTextNode($lang.get('acl_msg_scale_intro_title'))); |
1111 heading.appendChild(document.createTextNode($lang.get('acl_msg_scale_intro_title'))); |
1112 main.appendChild(heading); |
1112 main.appendChild(heading); |
1113 |
1113 |
1114 var p = document.createElement('p'); |
1114 var p = document.createElement('p'); |
1115 p.appendChild(document.createTextNode($lang.get('acl_msg_scale_intro_body'))); |
1115 p.appendChild(document.createTextNode($lang.get('acl_msg_scale_intro_body'))); |
1116 main.appendChild(p); |
1116 main.appendChild(p); |
1117 |
1117 |
1118 |
1118 |
1119 main.innerHTML += data.key; |
1119 main.innerHTML += data.key; |
1120 main.style.backgroundImage = 'none'; |
1120 main.style.backgroundImage = 'none'; |
1121 |
1121 |
1122 document.getElementById(aclManagerID + '_back').style.display = 'inline'; |
1122 document.getElementById(aclManagerID + '_back').style.display = 'inline'; |
1123 document.getElementById(aclManagerID + '_next').style.display = 'none'; |
1123 document.getElementById(aclManagerID + '_next').style.display = 'none'; |
1124 |
1124 |
1125 for ( var i = 0; i < data.rules.length; i++ ) |
1125 for ( var i = 0; i < data.rules.length; i++ ) |
1126 { |
1126 { |
1127 var rule = data.rules[i]; |
1127 var rule = data.rules[i]; |
1128 // build the rule, this is just more boring DOM crap. |
1128 // build the rule, this is just more boring DOM crap. |
1129 var div = document.createElement('div'); |
1129 var div = document.createElement('div'); |
1130 div.style.padding = '5px 3px'; |
1130 div.style.padding = '5px 3px'; |
1131 div.style.backgroundColor = '#' + rule.color; |
1131 div.style.backgroundColor = '#' + rule.color; |
1132 div.style.cursor = 'pointer'; |
1132 div.style.cursor = 'pointer'; |
1133 div.rule_id = rule.rule_id; |
1133 div.rule_id = rule.rule_id; |
1134 div.onclick = function() |
1134 div.onclick = function() |
1135 { |
1135 { |
1136 var main = document.getElementById(aclManagerID + '_main'); |
1136 var main = document.getElementById(aclManagerID + '_main'); |
1137 main.innerHTML = ''; |
1137 main.innerHTML = ''; |
1138 main.style.backgroundImage = 'url(' + scriptPath + '/images/loading-big.gif)'; |
1138 main.style.backgroundImage = 'url(' + scriptPath + '/images/loading-big.gif)'; |
1139 ajaxOpenDirectACLRule(parseInt(this.rule_id)); |
1139 ajaxOpenDirectACLRule(parseInt(this.rule_id)); |
1140 } |
1140 } |
1141 div.innerHTML = rule.score_string; |
1141 div.innerHTML = rule.score_string; |
1142 main.appendChild(div); |
1142 main.appendChild(div); |
1143 } |
1143 } |
1144 } |
1144 } |
1145 |
1145 |
1146 function aclSetViewDebugTools() |
1146 function aclSetViewDebugTools() |
1147 { |
1147 { |
1148 // selection window for viewing effective permissions |
1148 // selection window for viewing effective permissions |
1149 var main = document.getElementById(aclManagerID + '_main'); |
1149 var main = document.getElementById(aclManagerID + '_main'); |
1150 main.innerHTML = ''; |
1150 main.innerHTML = ''; |
1151 |
1151 |
1152 // set the submission handler to trace |
1152 // set the submission handler to trace |
1153 var thefrm = document.forms[aclManagerID + '_formobj']; |
1153 var thefrm = document.forms[aclManagerID + '_formobj']; |
1154 var modeobj = form_fetch_field(thefrm, 'mode'); |
1154 var modeobj = form_fetch_field(thefrm, 'mode'); |
1155 modeobj.value = 'trace'; |
1155 modeobj.value = 'trace'; |
1156 |
1156 |
1157 // show the back button |
1157 // show the back button |
1158 document.getElementById(aclManagerID + '_back').style.display = 'inline'; |
1158 document.getElementById(aclManagerID + '_back').style.display = 'inline'; |
1159 |
1159 |
1160 // |
1160 // |
1161 // start building |
1161 // start building |
1162 // |
1162 // |
1163 |
1163 |
1164 // selection interface |
1164 // selection interface |
1165 var selector = document.createElement('div'); |
1165 var selector = document.createElement('div'); |
1166 |
1166 |
1167 var table = document.createElement('table'); |
1167 var table = document.createElement('table'); |
1168 |
1168 |
1169 // username |
1169 // username |
1170 var tr_user = document.createElement('tr'); |
1170 var tr_user = document.createElement('tr'); |
1171 var td_user_l = document.createElement('td'); |
1171 var td_user_l = document.createElement('td'); |
1172 var lbl_user = document.createElement('label'); |
1172 var lbl_user = document.createElement('label'); |
1173 lbl_user.setAttribute('for', aclManagerID + 'trace_user'); |
1173 lbl_user.setAttribute('for', aclManagerID + 'trace_user'); |
1174 lbl_user.appendChild(document.createTextNode($lang.get('acl_lbl_trace_user'))); |
1174 lbl_user.appendChild(document.createTextNode($lang.get('acl_lbl_trace_user'))); |
1175 td_user_l.appendChild(lbl_user); |
1175 td_user_l.appendChild(lbl_user); |
1176 tr_user.appendChild(td_user_l); |
1176 tr_user.appendChild(td_user_l); |
1177 |
1177 |
1178 var td_user_i = document.createElement('td'); |
1178 var td_user_i = document.createElement('td'); |
1179 var i_user = document.createElement('input'); |
1179 var i_user = document.createElement('input'); |
1180 i_user.type = 'text'; |
1180 i_user.type = 'text'; |
1181 i_user.id = aclManagerID + 'trace_user'; |
1181 i_user.id = aclManagerID + 'trace_user'; |
1182 i_user.onkeyup = function() { new AutofillUsername(this, true); }; |
1182 i_user.onkeyup = function() { new AutofillUsername(this, true); }; |
1183 i_user.size = '20'; |
1183 i_user.size = '20'; |
1184 td_user_i.appendChild(i_user); |
1184 td_user_i.appendChild(i_user); |
1185 tr_user.appendChild(td_user_i); |
1185 tr_user.appendChild(td_user_i); |
1186 |
1186 |
1187 table.appendChild(tr_user); |
1187 table.appendChild(tr_user); |
1188 |
1188 |
1189 // page |
1189 // page |
1190 var tr_page = document.createElement('tr'); |
1190 var tr_page = document.createElement('tr'); |
1191 var td_page_l = document.createElement('td'); |
1191 var td_page_l = document.createElement('td'); |
1192 var lbl_page = document.createElement('label'); |
1192 var lbl_page = document.createElement('label'); |
1193 lbl_page.setAttribute('for', aclManagerID + 'trace_page'); |
1193 lbl_page.setAttribute('for', aclManagerID + 'trace_page'); |
1194 lbl_page.appendChild(document.createTextNode($lang.get('acl_lbl_trace_page'))); |
1194 lbl_page.appendChild(document.createTextNode($lang.get('acl_lbl_trace_page'))); |
1195 td_page_l.appendChild(lbl_page); |
1195 td_page_l.appendChild(lbl_page); |
1196 tr_page.appendChild(td_page_l); |
1196 tr_page.appendChild(td_page_l); |
1197 |
1197 |
1198 var td_page_i = document.createElement('td'); |
1198 var td_page_i = document.createElement('td'); |
1199 var i_page = document.createElement('input'); |
1199 var i_page = document.createElement('input'); |
1200 i_page.type = 'text'; |
1200 i_page.type = 'text'; |
1201 i_page.id = aclManagerID + 'trace_page'; |
1201 i_page.id = aclManagerID + 'trace_page'; |
1202 i_page.onkeyup = function() { new AutofillPage(this); }; |
1202 i_page.onkeyup = function() { new AutofillPage(this); }; |
1203 i_page.size = '20'; |
1203 i_page.size = '20'; |
1204 td_page_i.appendChild(i_page); |
1204 td_page_i.appendChild(i_page); |
1205 tr_page.appendChild(td_page_i); |
1205 tr_page.appendChild(td_page_i); |
1206 |
1206 |
1207 table.appendChild(tr_page); |
1207 table.appendChild(tr_page); |
1208 |
1208 |
1209 selector.appendChild(table); |
1209 selector.appendChild(table); |
1210 |
1210 |
1211 // wrapper |
1211 // wrapper |
1212 |
1212 |
1213 var container = document.createElement('div'); |
1213 var container = document.createElement('div'); |
1214 |
1214 |
1215 container.style.margin = 'auto'; |
1215 container.style.margin = 'auto'; |
1216 container.style.width = '360px'; |
1216 container.style.width = '360px'; |
1217 container.style.paddingTop = '90px'; |
1217 container.style.paddingTop = '90px'; |
1218 |
1218 |
1219 var head = document.createElement('h2'); |
1219 var head = document.createElement('h2'); |
1220 head.appendChild(document.createTextNode($lang.get('acl_lbl_trace_title'))); |
1220 head.appendChild(document.createTextNode($lang.get('acl_lbl_trace_title'))); |
1221 |
1221 |
1222 var desc = document.createElement('p'); |
1222 var desc = document.createElement('p'); |
1223 desc.innerHTML = $lang.get('acl_lbl_trace_body'); |
1223 desc.innerHTML = $lang.get('acl_lbl_trace_body'); |
1224 |
1224 |
1225 container.appendChild(head); |
1225 container.appendChild(head); |
1226 container.appendChild(desc); |
1226 container.appendChild(desc); |
1227 container.appendChild(selector); |
1227 container.appendChild(selector); |
1228 |
1228 |
1229 main.appendChild(container); |
1229 main.appendChild(container); |
1230 } |
1230 } |
1231 |
1231 |
1232 function aclTraceKey() |
1232 function aclTraceKey() |
1233 { |
1233 { |
1234 var div = document.createElement('div'); |
1234 var div = document.createElement('div'); |
1235 $(div).addClass('tblholder'); |
1235 $(div).addClass('tblholder'); |
1236 var table = document.createElement('table'); |
1236 var table = document.createElement('table'); |
1237 $(table).attr('cellspacing', '1').attr('cellpadding', '4'); |
1237 $(table).attr('cellspacing', '1').attr('cellpadding', '4'); |
1238 |
1238 |
1239 var inherit_list = ['enano_default', 'global_everyone', 'global_group', 'global_user', 'pg_everyone', 'pg_group', 'pg_user', 'local_everyone', 'local_group', 'local_user']; |
1239 var inherit_list = ['enano_default', 'global_everyone', 'global_group', 'global_user', 'pg_everyone', 'pg_group', 'pg_user', 'local_everyone', 'local_group', 'local_user']; |
1240 for ( var i = 0; i < inherit_list.length; i++ ) |
1240 for ( var i = 0; i < inherit_list.length; i++ ) |
1241 { |
1241 { |
1242 var t = inherit_list[i]; |
1242 var t = inherit_list[i]; |
1243 var tr = document.createElement('tr'); |
1243 var tr = document.createElement('tr'); |
1244 var td_key = document.createElement('td'); |
1244 var td_key = document.createElement('td'); |
1245 $(td_key).addClass('acl_' + t).addClass('acl_inherit_key'); |
1245 $(td_key).addClass('acl_' + t).addClass('acl_inherit_key'); |
1246 tr.appendChild(td_key); |
1246 tr.appendChild(td_key); |
1247 var td_explain = document.createElement('td'); |
1247 var td_explain = document.createElement('td'); |
1248 $(td_explain).addClass(i % 2 == 0 ? 'row1' : 'row2'); |
1248 $(td_explain).addClass(i % 2 == 0 ? 'row1' : 'row2'); |
1249 td_explain.appendChild(document.createTextNode($lang.get('acl_inherit_key_' + t))); |
1249 td_explain.appendChild(document.createTextNode($lang.get('acl_inherit_key_' + t))); |
1250 tr.appendChild(td_explain); |
1250 tr.appendChild(td_explain); |
1251 table.appendChild(tr); |
1251 table.appendChild(tr); |
1252 } |
1252 } |
1253 div.appendChild(table); |
1253 div.appendChild(table); |
1254 return div; |
1254 return div; |
1255 } |
1255 } |
1256 |
1256 |
1257 function aclTraceModalKey() |
1257 function aclTraceModalKey() |
1258 { |
1258 { |
1259 load_component('messagebox'); |
1259 load_component('messagebox'); |
1260 miniPrompt(function(parent) |
1260 miniPrompt(function(parent) |
1261 { |
1261 { |
1262 // heading |
1262 // heading |
1263 var h3 = document.createElement('h3'); |
1263 var h3 = document.createElement('h3'); |
1264 h3.appendChild(document.createTextNode($lang.get('acl_msg_trace_key'))); |
1264 h3.appendChild(document.createTextNode($lang.get('acl_msg_trace_key'))); |
1265 parent.appendChild(h3); |
1265 parent.appendChild(h3); |
1266 |
1266 |
1267 var key = aclTraceKey(); |
1267 var key = aclTraceKey(); |
1268 parent.appendChild(key); |
1268 parent.appendChild(key); |
1269 |
1269 |
1270 var p = document.createElement('p'); |
1270 var p = document.createElement('p'); |
1271 $(p).css('text-align', 'center'); |
1271 $(p).css('text-align', 'center'); |
1272 |
1272 |
1273 var closer = document.createElement('a'); |
1273 var closer = document.createElement('a'); |
1274 $(closer).addClass('abutton').addClass('abutton_red').css('font-weight', 'bold'); |
1274 $(closer).addClass('abutton').addClass('abutton_red').css('font-weight', 'bold'); |
1275 closer.appendChild(document.createTextNode($lang.get('etc_close'))); |
1275 closer.appendChild(document.createTextNode($lang.get('etc_close'))); |
1276 closer.href = '#'; |
1276 closer.href = '#'; |
1277 $(closer).click(function(e) |
1277 $(closer).click(function(e) |
1278 { |
1278 { |
1279 miniPromptDestroy(this); |
1279 miniPromptDestroy(this); |
1280 return false; |
1280 return false; |
1281 }); |
1281 }); |
1282 |
1282 |
1283 p.appendChild(closer); |
1283 p.appendChild(closer); |
1284 parent.appendChild(p); |
1284 parent.appendChild(p); |
1285 }); |
1285 }); |
1286 } |
1286 } |
1287 |
1287 |
1288 function aclDrawTraceWrapper(data) |
1288 function aclDrawTraceWrapper(data) |
1289 { |
1289 { |
1290 // hide the next button |
1290 // hide the next button |
1291 document.getElementById(aclManagerID + '_next').style.display = 'none'; |
1291 document.getElementById(aclManagerID + '_next').style.display = 'none'; |
1292 |
1292 |
1293 var trace_by_perm = aclDrawTraceByPerm(data); |
1293 var trace_by_perm = aclDrawTraceByPerm(data); |
1294 var trace_by_rule = aclDrawTraceByRule(data); |
1294 var trace_by_rule = aclDrawTraceByRule(data); |
1295 |
1295 |
1296 trace_by_perm.id = 'aclDebugTraceViewPerm'; |
1296 trace_by_perm.id = 'aclDebugTraceViewPerm'; |
1297 trace_by_rule.id = 'aclDebugTraceViewRule'; |
1297 trace_by_rule.id = 'aclDebugTraceViewRule'; |
1298 |
1298 |
1299 var start_with_rule = ( readCookie('acl_trace_view') == 'rule' ); |
1299 var start_with_rule = ( readCookie('acl_trace_view') == 'rule' ); |
1300 |
1300 |
1301 if ( start_with_rule ) |
1301 if ( start_with_rule ) |
1302 { |
1302 { |
1303 trace_by_perm.style.display = 'none'; |
1303 trace_by_perm.style.display = 'none'; |
1304 } |
1304 } |
1305 else |
1305 else |
1306 { |
1306 { |
1307 trace_by_rule.style.display = 'none'; |
1307 trace_by_rule.style.display = 'none'; |
1308 } |
1308 } |
1309 |
1309 |
1310 // selection window for viewing effective permissions |
1310 // selection window for viewing effective permissions |
1311 var main = document.getElementById(aclManagerID + '_main'); |
1311 var main = document.getElementById(aclManagerID + '_main'); |
1312 main.innerHTML = ''; |
1312 main.innerHTML = ''; |
1313 |
1313 |
1314 var wrapper = document.createElement('div'); |
1314 var wrapper = document.createElement('div'); |
1315 $(wrapper).css('padding-bottom', '20px'); |
1315 $(wrapper).css('padding-bottom', '20px'); |
1316 |
1316 |
1317 var floatlink = document.createElement('div'); |
1317 var floatlink = document.createElement('div'); |
1318 $(floatlink).css('float', 'right').css('margin-left', '20px').css('margin-bottom', '20px').css('text-align', 'right'); |
1318 $(floatlink).css('float', 'right').css('margin-left', '20px').css('margin-bottom', '20px').css('text-align', 'right'); |
1319 var a_toggle = document.createElement('a'); |
1319 var a_toggle = document.createElement('a'); |
1320 $(a_toggle).attr('id', 'aclDebugTraceViewToggle'); |
1320 $(a_toggle).attr('id', 'aclDebugTraceViewToggle'); |
1321 a_toggle.innerHTML = '» '; |
1321 a_toggle.innerHTML = '» '; |
1322 a_toggle.innerHTML += start_with_rule ? $lang.get('acl_btn_sort_perm') : $lang.get('acl_btn_sort_rule'); |
1322 a_toggle.innerHTML += start_with_rule ? $lang.get('acl_btn_sort_perm') : $lang.get('acl_btn_sort_rule'); |
1323 a_toggle.href = '#'; |
1323 a_toggle.href = '#'; |
1324 floatlink.appendChild(a_toggle); |
1324 floatlink.appendChild(a_toggle); |
1325 floatlink.appendChild(document.createElement('br')); |
1325 floatlink.appendChild(document.createElement('br')); |
1326 var a_key = document.createElement('a'); |
1326 var a_key = document.createElement('a'); |
1327 $(a_key).css('font-size', 'smaller'); |
1327 $(a_key).css('font-size', 'smaller'); |
1328 a_key.innerHTML = '» '; |
1328 a_key.innerHTML = '» '; |
1329 a_key.innerHTML += $lang.get('acl_btn_view_key'); |
1329 a_key.innerHTML += $lang.get('acl_btn_view_key'); |
1330 a_key.href = '#'; |
1330 a_key.href = '#'; |
1331 floatlink.appendChild(a_key); |
1331 floatlink.appendChild(a_key); |
1332 wrapper.appendChild(floatlink); |
1332 wrapper.appendChild(floatlink); |
1333 |
1333 |
1334 var h3 = document.createElement('h3'); |
1334 var h3 = document.createElement('h3'); |
1335 h3.appendChild(document.createTextNode($lang.get('acl_msg_debug_main_title'))); |
1335 h3.appendChild(document.createTextNode($lang.get('acl_msg_debug_main_title'))); |
1336 wrapper.appendChild(h3); |
1336 wrapper.appendChild(h3); |
1337 var p = document.createElement('p'); |
1337 var p = document.createElement('p'); |
1338 p.appendChild(document.createTextNode($lang.get('acl_msg_debug_main_body'))); |
1338 p.appendChild(document.createTextNode($lang.get('acl_msg_debug_main_body'))); |
1339 wrapper.appendChild(p); |
1339 wrapper.appendChild(p); |
1340 |
1340 |
1341 wrapper.appendChild(trace_by_perm); |
1341 wrapper.appendChild(trace_by_perm); |
1342 wrapper.appendChild(trace_by_rule); |
1342 wrapper.appendChild(trace_by_rule); |
1343 |
1343 |
1344 main.appendChild(wrapper); |
1344 main.appendChild(wrapper); |
1345 |
1345 |
1346 $(a_toggle).click(function(e) |
1346 $(a_toggle).click(function(e) |
1347 { |
1347 { |
1348 aclTraceToggleViews(); |
1348 aclTraceToggleViews(); |
1349 return false; |
1349 return false; |
1350 }); |
1350 }); |
1351 |
1351 |
1352 $(a_key).click(function(e) |
1352 $(a_key).click(function(e) |
1353 { |
1353 { |
1354 aclTraceModalKey(); |
1354 aclTraceModalKey(); |
1355 return false; |
1355 return false; |
1356 }); |
1356 }); |
1357 } |
1357 } |
1358 |
1358 |
1359 function aclTraceToggleViews() |
1359 function aclTraceToggleViews() |
1360 { |
1360 { |
1361 var trace_by_perm = document.getElementById('aclDebugTraceViewPerm'); |
1361 var trace_by_perm = document.getElementById('aclDebugTraceViewPerm'); |
1362 var trace_by_rule = document.getElementById('aclDebugTraceViewRule'); |
1362 var trace_by_rule = document.getElementById('aclDebugTraceViewRule'); |
1363 |
1363 |
1364 var toggler = document.getElementById('aclDebugTraceViewToggle'); |
1364 var toggler = document.getElementById('aclDebugTraceViewToggle'); |
1365 var newtext; |
1365 var newtext; |
1366 |
1366 |
1367 if ( trace_by_perm.style.display == 'none' ) |
1367 if ( trace_by_perm.style.display == 'none' ) |
1368 { |
1368 { |
1369 newtext = $lang.get('acl_btn_sort_rule'); |
1369 newtext = $lang.get('acl_btn_sort_rule'); |
1370 $(trace_by_rule).hide('blind', {}, 750, function() |
1370 $(trace_by_rule).hide('blind', {}, 750, function() |
1371 { |
1371 { |
1372 $(trace_by_perm).show('blind', {}, 750); |
1372 $(trace_by_perm).show('blind', {}, 750); |
1373 }); |
1373 }); |
1374 createCookie('acl_trace_view', 'perm'); |
1374 createCookie('acl_trace_view', 'perm'); |
1375 } |
1375 } |
1376 else |
1376 else |
1377 { |
1377 { |
1378 newtext = $lang.get('acl_btn_sort_perm'); |
1378 newtext = $lang.get('acl_btn_sort_perm'); |
1379 $(trace_by_perm).hide('blind', {}, 750, function() |
1379 $(trace_by_perm).hide('blind', {}, 750, function() |
1380 { |
1380 { |
1381 $(trace_by_rule).show('blind', {}, 750); |
1381 $(trace_by_rule).show('blind', {}, 750); |
1382 }); |
1382 }); |
1383 createCookie('acl_trace_view', 'rule'); |
1383 createCookie('acl_trace_view', 'rule'); |
1384 } |
1384 } |
1385 $(toggler).fadeOut(500, function() |
1385 $(toggler).fadeOut(500, function() |
1386 { |
1386 { |
1387 this.innerHTML = '» ' + newtext; |
1387 this.innerHTML = '» ' + newtext; |
1388 $(this).fadeIn(500); |
1388 $(this).fadeIn(500); |
1389 }); |
1389 }); |
1390 } |
1390 } |
1391 |
1391 |
1392 function aclDrawTraceByPerm(data) |
1392 function aclDrawTraceByPerm(data) |
1393 { |
1393 { |
1394 var wrapper = document.createElement('div'); |
1394 var wrapper = document.createElement('div'); |
1395 // wrapper.style.display = 'none'; |
1395 // wrapper.style.display = 'none'; |
1396 |
1396 |
1397 // temporarily append wrapper to body to allow onclick to work |
1397 // temporarily append wrapper to body to allow onclick to work |
1398 // var body = document.getElementsByTagName('body')[0]; |
1398 // var body = document.getElementsByTagName('body')[0]; |
1399 // body.appendChild(wrapper); |
1399 // body.appendChild(wrapper); |
1400 |
1400 |
1401 for ( var i in data.perms ) |
1401 for ( var i in data.perms ) |
1402 { |
1402 { |
1403 var perm = data.perms[i]; |
1403 var perm = data.perms[i]; |
1404 var item = document.createElement('div'); |
1404 var item = document.createElement('div'); |
1405 item.className = perm.divclass; |
1405 item.className = perm.divclass; |
1406 |
1406 |
1407 // first row - permission name + current setting |
1407 // first row - permission name + current setting |
1408 // use innerHTML here to allow for HTML in localized permission types |
1408 // use innerHTML here to allow for HTML in localized permission types |
1409 item.innerHTML += '<b>' + perm.perm_name + ' - ' + perm.perm_value + '</b>'; |
1409 item.innerHTML += '<b>' + perm.perm_name + ' - ' + perm.perm_value + '</b>'; |
1410 item.appendChild(document.createElement('br')); |
1410 item.appendChild(document.createElement('br')); |
1411 |
1411 |
1412 // second row - permission localized name + rule ID |
1412 // second row - permission localized name + rule ID |
1413 var sm = document.createElement('small'); |
1413 var sm = document.createElement('small'); |
1414 sm.innerHTML = perm.perm_src; |
1414 sm.innerHTML = perm.perm_src; |
1415 |
1415 |
1416 item.appendChild(sm); |
1416 item.appendChild(sm); |
1417 |
1417 |
1418 wrapper.appendChild(item); |
1418 wrapper.appendChild(item); |
1419 |
1419 |
1420 // whole row is now in the document |
1420 // whole row is now in the document |
1421 if ( perm.rule_id != -1 ) |
1421 if ( perm.rule_id != -1 ) |
1422 { |
1422 { |
1423 sm.innerHTML += ' ['; |
1423 sm.innerHTML += ' ['; |
1424 // rule is editable |
1424 // rule is editable |
1425 var editlink = document.createElement('a'); |
1425 var editlink = document.createElement('a'); |
1426 editlink.href = 'javascript:ajaxOpenDirectACLRule(' + perm.rule_id + ');'; |
1426 editlink.href = 'javascript:ajaxOpenDirectACLRule(' + perm.rule_id + ');'; |
1427 editlink.appendChild(document.createTextNode($lang.get('acl_btn_edit_rule'))); |
1427 editlink.appendChild(document.createTextNode($lang.get('acl_btn_edit_rule'))); |
1428 sm.appendChild(editlink); |
1428 sm.appendChild(editlink); |
1429 sm.innerHTML += ']'; |
1429 sm.innerHTML += ']'; |
1430 } |
1430 } |
1431 |
1431 |
1432 if ( perm.bad_deps.length > 0 ) |
1432 if ( perm.bad_deps.length > 0 ) |
1433 { |
1433 { |
1434 var bd = document.createElement('span'); |
1434 var bd = document.createElement('span'); |
1435 $(bd).addClass('acl_failed_deps'); |
1435 $(bd).addClass('acl_failed_deps'); |
1436 var failed_deps = ''; |
1436 var failed_deps = ''; |
1437 for ( var i = 0; i < perm.bad_deps.length; i++ ) |
1437 for ( var i = 0; i < perm.bad_deps.length; i++ ) |
1438 { |
1438 { |
1439 if ( i > 0 ) |
1439 if ( i > 0 ) |
1440 failed_deps += ', '; |
1440 failed_deps += ', '; |
1441 failed_deps += data.perms[perm.bad_deps[i]].perm_name; |
1441 failed_deps += data.perms[perm.bad_deps[i]].perm_name; |
1442 } |
1442 } |
1443 var title = document.createElement('span'); |
1443 var title = document.createElement('span'); |
1444 $(title).addClass('title'); |
1444 $(title).addClass('title'); |
1445 title.appendChild(document.createTextNode($lang.get('acl_msg_failed_deps'))); |
1445 title.appendChild(document.createTextNode($lang.get('acl_msg_failed_deps'))); |
1446 bd.appendChild(title); |
1446 bd.appendChild(title); |
1447 bd.appendChild(document.createTextNode(failed_deps)); |
1447 bd.appendChild(document.createTextNode(failed_deps)); |
1448 |
1448 |
1449 item.appendChild(document.createElement('br')); |
1449 item.appendChild(document.createElement('br')); |
1450 item.appendChild(bd); |
1450 item.appendChild(bd); |
1451 } |
1451 } |
1452 } |
1452 } |
1453 |
1453 |
1454 // var ret = wrapper.cloneNode(true); |
1454 // var ret = wrapper.cloneNode(true); |
1455 // body.removeChild(wrapper); |
1455 // body.removeChild(wrapper); |
1456 // wrapper = false; |
1456 // wrapper = false; |
1457 // ret.style.display = 'block'; |
1457 // ret.style.display = 'block'; |
1458 // console.debug(ret); |
1458 // console.debug(ret); |
1459 // return ret; |
1459 // return ret; |
1460 return wrapper; |
1460 return wrapper; |
1461 } |
1461 } |
1462 |
1462 |
1463 function aclDrawTraceByRule(data) |
1463 function aclDrawTraceByRule(data) |
1464 { |
1464 { |
1465 var wrapper = document.createElement('div'); |
1465 var wrapper = document.createElement('div'); |
1466 var groupdata = {}; |
1466 var groupdata = {}; |
1467 |
1467 |
1468 for ( var i in data.perms ) |
1468 for ( var i in data.perms ) |
1469 { |
1469 { |
1470 var perm = data.perms[i]; |
1470 var perm = data.perms[i]; |
1471 if ( !groupdata[perm['rule_id']] ) |
1471 if ( !groupdata[perm['rule_id']] ) |
1472 { |
1472 { |
1473 groupdata[perm['rule_id']] = { |
1473 groupdata[perm['rule_id']] = { |
1474 meta: { |
1474 meta: { |
1475 divclass: perm.divclass, |
1475 divclass: perm.divclass, |
1476 perm_src: perm.perm_src, |
1476 perm_src: perm.perm_src, |
1477 rule_id: perm.rule_id |
1477 rule_id: perm.rule_id |
1478 }, |
1478 }, |
1479 rules: {} |
1479 rules: {} |
1480 }; |
1480 }; |
1481 } |
1481 } |
1482 groupdata[perm['rule_id']]['rules'][i] = perm; |
1482 groupdata[perm['rule_id']]['rules'][i] = perm; |
1483 } |
1483 } |
1484 |
1484 |
1485 for ( var i in groupdata ) |
1485 for ( var i in groupdata ) |
1486 { |
1486 { |
1487 var group = groupdata[i]; |
1487 var group = groupdata[i]; |
1488 var grp = document.createElement('div'); |
1488 var grp = document.createElement('div'); |
1489 var head = document.createElement('div'); |
1489 var head = document.createElement('div'); |
1490 head.className = group.meta.divclass; |
1490 head.className = group.meta.divclass; |
1491 var span = document.createElement('span'); |
1491 var span = document.createElement('span'); |
1492 span.style.fontSize = 'larger'; |
1492 span.style.fontSize = 'larger'; |
1493 span.appendChild(document.createTextNode(group.meta.perm_src)); |
1493 span.appendChild(document.createTextNode(group.meta.perm_src)); |
1494 head.appendChild(span); |
1494 head.appendChild(span); |
1495 if ( group.meta.rule_id != -1 ) |
1495 if ( group.meta.rule_id != -1 ) |
1496 { |
1496 { |
1497 head.innerHTML += ' ['; |
1497 head.innerHTML += ' ['; |
1498 // rule is editable |
1498 // rule is editable |
1499 var editlink = document.createElement('a'); |
1499 var editlink = document.createElement('a'); |
1500 editlink.href = 'javascript:ajaxOpenDirectACLRule(' + group.meta.rule_id + ');'; |
1500 editlink.href = 'javascript:ajaxOpenDirectACLRule(' + group.meta.rule_id + ');'; |
1501 editlink.appendChild(document.createTextNode($lang.get('acl_btn_edit_rule'))); |
1501 editlink.appendChild(document.createTextNode($lang.get('acl_btn_edit_rule'))); |
1502 head.appendChild(editlink); |
1502 head.appendChild(editlink); |
1503 head.innerHTML += ']'; |
1503 head.innerHTML += ']'; |
1504 } |
1504 } |
1505 grp.appendChild(head); |
1505 grp.appendChild(head); |
1506 for ( var i in group.rules ) |
1506 for ( var i in group.rules ) |
1507 { |
1507 { |
1508 var rule = group.rules[i]; |
1508 var rule = group.rules[i]; |
1509 var rulediv = document.createElement('div'); |
1509 var rulediv = document.createElement('div'); |
1510 rulediv.style.padding = '3px 12px'; |
1510 rulediv.style.padding = '3px 12px'; |
1511 rulediv.innerHTML += rule.perm_name + ': '; |
1511 rulediv.innerHTML += rule.perm_name + ': '; |
1512 var b = document.createElement('strong'); |
1512 var b = document.createElement('strong'); |
1513 b.appendChild(document.createTextNode(rule.perm_value)); |
1513 b.appendChild(document.createTextNode(rule.perm_value)); |
1514 rulediv.appendChild(b); |
1514 rulediv.appendChild(b); |
1515 grp.appendChild(rulediv); |
1515 grp.appendChild(rulediv); |
1516 |
1516 |
1517 if ( rule.bad_deps.length > 0 ) |
1517 if ( rule.bad_deps.length > 0 ) |
1518 { |
1518 { |
1519 var bd = document.createElement('span'); |
1519 var bd = document.createElement('span'); |
1520 $(bd).addClass('acl_failed_deps'); |
1520 $(bd).addClass('acl_failed_deps'); |
1521 var failed_deps = ''; |
1521 var failed_deps = ''; |
1522 for ( var i = 0; i < rule.bad_deps.length; i++ ) |
1522 for ( var i = 0; i < rule.bad_deps.length; i++ ) |
1523 { |
1523 { |
1524 if ( i > 0 ) |
1524 if ( i > 0 ) |
1525 failed_deps += ', '; |
1525 failed_deps += ', '; |
1526 failed_deps += data.perms[rule.bad_deps[i]].perm_name; |
1526 failed_deps += data.perms[rule.bad_deps[i]].perm_name; |
1527 } |
1527 } |
1528 var title = document.createElement('span'); |
1528 var title = document.createElement('span'); |
1529 $(title).addClass('title'); |
1529 $(title).addClass('title'); |
1530 title.appendChild(document.createTextNode($lang.get('acl_msg_failed_deps'))); |
1530 title.appendChild(document.createTextNode($lang.get('acl_msg_failed_deps'))); |
1531 bd.appendChild(title); |
1531 bd.appendChild(title); |
1532 bd.appendChild(document.createTextNode(failed_deps)); |
1532 bd.appendChild(document.createTextNode(failed_deps)); |
1533 |
1533 |
1534 rulediv.appendChild(document.createElement('br')); |
1534 rulediv.appendChild(document.createElement('br')); |
1535 rulediv.appendChild(bd); |
1535 rulediv.appendChild(bd); |
1536 } |
1536 } |
1537 } |
1537 } |
1538 wrapper.appendChild(grp); |
1538 wrapper.appendChild(grp); |
1539 } |
1539 } |
1540 |
1540 |
1541 return wrapper; |
1541 return wrapper; |
1542 } |
1542 } |
1543 |
1543 |
1544 function aclShowPresetLoader() |
1544 function aclShowPresetLoader() |
1545 { |
1545 { |
1546 var prompt = miniPrompt(function(parent) |
1546 var prompt = miniPrompt(function(parent) |
1547 { |
1547 { |
1548 parent.innerHTML = '<img style="display: block; margin: 0 auto;" src="' + cdnPath + '/images/loading-big.gif" />'; |
1548 parent.innerHTML = '<img style="display: block; margin: 0 auto;" src="' + cdnPath + '/images/loading-big.gif" />'; |
1549 }); |
1549 }); |
1550 var request = toJSONString({ |
1550 var request = toJSONString({ |
1551 mode: 'list_presets' |
1551 mode: 'list_presets' |
1552 }); |
1552 }); |
1553 ajaxPost(stdAjaxPrefix + '&_mode=acljson', 'acl_params=' + ajaxEscape(request), function(ajax) |
1553 ajaxPost(stdAjaxPrefix + '&_mode=acljson', 'acl_params=' + ajaxEscape(request), function(ajax) |
1554 { |
1554 { |
1555 if ( ajax.readyState == 4 && ajax.status == 200 ) |
1555 if ( ajax.readyState == 4 && ajax.status == 200 ) |
1556 { |
1556 { |
1557 if ( !check_json_response(ajax.responseText) ) |
1557 if ( !check_json_response(ajax.responseText) ) |
1558 { |
1558 { |
1559 miniPromptDestroy(prompt); |
1559 miniPromptDestroy(prompt); |
1560 return handle_invalid_json(ajax.responseText); |
1560 return handle_invalid_json(ajax.responseText); |
1561 } |
1561 } |
1562 var response = parseJSON(ajax.responseText); |
1562 var response = parseJSON(ajax.responseText); |
1563 if ( response.mode == 'error' ) |
1563 if ( response.mode == 'error' ) |
1564 { |
1564 { |
1565 alert(response.error); |
1565 alert(response.error); |
1566 miniPromptDestroy(prompt); |
1566 miniPromptDestroy(prompt); |
1567 return false; |
1567 return false; |
1568 } |
1568 } |
1569 prompt = prompt.firstChild.nextSibling; |
1569 prompt = prompt.firstChild.nextSibling; |
1570 prompt.style.textAlign = 'center'; |
1570 prompt.style.textAlign = 'center'; |
1571 prompt.innerHTML = '<h3>' + $lang.get('acl_lbl_preset_load_title') + '</h3>'; |
1571 prompt.innerHTML = '<h3>' + $lang.get('acl_lbl_preset_load_title') + '</h3>'; |
1572 |
1572 |
1573 if ( response.presets.length > 0 ) |
1573 if ( response.presets.length > 0 ) |
1574 { |
1574 { |
1575 // selection box |
1575 // selection box |
1576 var para = document.createElement('p'); |
1576 var para = document.createElement('p'); |
1577 var select = document.createElement('select'); |
1577 var select = document.createElement('select'); |
1578 |
1578 |
1579 var option = document.createElement('option'); |
1579 var option = document.createElement('option'); |
1580 option.value = '0'; |
1580 option.value = '0'; |
1581 option.appendChild(document.createTextNode($lang.get('acl_lbl_preset_load'))); |
1581 option.appendChild(document.createTextNode($lang.get('acl_lbl_preset_load'))); |
1582 select.appendChild(option); |
1582 select.appendChild(option); |
1583 |
1583 |
1584 for ( var i = 0; i < response.presets.length; i++ ) |
1584 for ( var i = 0; i < response.presets.length; i++ ) |
1585 { |
1585 { |
1586 var preset = response.presets[i]; |
1586 var preset = response.presets[i]; |
1587 var option = document.createElement('option'); |
1587 var option = document.createElement('option'); |
1588 option.value = preset.rule_id; |
1588 option.value = preset.rule_id; |
1589 option.preset_data = preset; |
1589 option.preset_data = preset; |
1590 option.appendChild(document.createTextNode($lang.get(preset.preset_name))); |
1590 option.appendChild(document.createTextNode($lang.get(preset.preset_name))); |
1591 select.appendChild(option); |
1591 select.appendChild(option); |
1592 } |
1592 } |
1593 |
1593 |
1594 para.appendChild(select); |
1594 para.appendChild(select); |
1595 prompt.appendChild(para); |
1595 prompt.appendChild(para); |
1596 |
1596 |
1597 // buttons |
1597 // buttons |
1598 var buttons = document.createElement('p'); |
1598 var buttons = document.createElement('p'); |
1599 |
1599 |
1600 // load button |
1600 // load button |
1601 var btn_load = document.createElement('a'); |
1601 var btn_load = document.createElement('a'); |
1602 btn_load.className = 'abutton abutton_green'; |
1602 btn_load.className = 'abutton abutton_green'; |
1603 btn_load.style.fontWeight = 'bold'; |
1603 btn_load.style.fontWeight = 'bold'; |
1604 btn_load.appendChild(document.createTextNode($lang.get('acl_btn_load_preset'))); |
1604 btn_load.appendChild(document.createTextNode($lang.get('acl_btn_load_preset'))); |
1605 btn_load.selectobj = select; |
1605 btn_load.selectobj = select; |
1606 btn_load.onclick = function() |
1606 btn_load.onclick = function() |
1607 { |
1607 { |
1608 if ( this.selectobj.value == '0' ) |
1608 if ( this.selectobj.value == '0' ) |
1609 { |
1609 { |
1610 alert($lang.get('acl_err_select_preset')); |
1610 alert($lang.get('acl_err_select_preset')); |
1611 return false; |
1611 return false; |
1612 } |
1612 } |
1613 // retrieve preset data |
1613 // retrieve preset data |
1614 for ( var i = 0; i < this.selectobj.childNodes.length; i++ ) |
1614 for ( var i = 0; i < this.selectobj.childNodes.length; i++ ) |
1615 { |
1615 { |
1616 if ( this.selectobj.childNodes[i].tagName == 'OPTION' ) |
1616 if ( this.selectobj.childNodes[i].tagName == 'OPTION' ) |
1617 { |
1617 { |
1618 var node = this.selectobj.childNodes[i]; |
1618 var node = this.selectobj.childNodes[i]; |
1619 if ( node.value == this.selectobj.value ) |
1619 if ( node.value == this.selectobj.value ) |
1620 { |
1620 { |
1621 aclSetRulesAbsolute(node.preset_data.rules); |
1621 aclSetRulesAbsolute(node.preset_data.rules); |
1622 break; |
1622 break; |
1623 } |
1623 } |
1624 } |
1624 } |
1625 } |
1625 } |
1626 miniPromptDestroy(this); |
1626 miniPromptDestroy(this); |
1627 return false; |
1627 return false; |
1628 } |
1628 } |
1629 btn_load.href = '#'; |
1629 btn_load.href = '#'; |
1630 buttons.appendChild(btn_load); |
1630 buttons.appendChild(btn_load); |
1631 |
1631 |
1632 buttons.appendChild(document.createTextNode(' ')); |
1632 buttons.appendChild(document.createTextNode(' ')); |
1633 |
1633 |
1634 // cancel button |
1634 // cancel button |
1635 var btn_cancel = document.createElement('a'); |
1635 var btn_cancel = document.createElement('a'); |
1636 btn_cancel.className = 'abutton'; |
1636 btn_cancel.className = 'abutton'; |
1637 btn_cancel.appendChild(document.createTextNode($lang.get('etc_cancel'))); |
1637 btn_cancel.appendChild(document.createTextNode($lang.get('etc_cancel'))); |
1638 btn_cancel.onclick = function() |
1638 btn_cancel.onclick = function() |
1639 { |
1639 { |
1640 miniPromptDestroy(this); |
1640 miniPromptDestroy(this); |
1641 return false; |
1641 return false; |
1642 } |
1642 } |
1643 btn_cancel.href = '#'; |
1643 btn_cancel.href = '#'; |
1644 buttons.appendChild(btn_cancel); |
1644 buttons.appendChild(btn_cancel); |
1645 |
1645 |
1646 prompt.appendChild(buttons); |
1646 prompt.appendChild(buttons); |
1647 } |
1647 } |
1648 else |
1648 else |
1649 { |
1649 { |
1650 // "no presets" |
1650 // "no presets" |
1651 prompt.innerHTML += '<p>' + $lang.get('acl_msg_no_presets', { close_flags: 'href="#" onclick="miniPromptDestroy(this); return false;"' }) + '</p>'; |
1651 prompt.innerHTML += '<p>' + $lang.get('acl_msg_no_presets', { close_flags: 'href="#" onclick="miniPromptDestroy(this); return false;"' }) + '</p>'; |
1652 } |
1652 } |
1653 } |
1653 } |
1654 }); |
1654 }); |
1655 } |
1655 } |
1656 |
1656 |
1657 function aclSetRulesAbsolute(rules) |
1657 function aclSetRulesAbsolute(rules) |
1658 { |
1658 { |
1659 __aclSetAllRadios('i'); |
1659 __aclSetAllRadios('i'); |
1660 |
1660 |
1661 var form = document.forms[aclManagerID + '_formobj']; |
1661 var form = document.forms[aclManagerID + '_formobj']; |
1662 if (!form) |
1662 if (!form) |
1663 { |
1663 { |
1664 return false; |
1664 return false; |
1665 } |
1665 } |
1666 var inputs = form.getElementsByTagName('input'); |
1666 var inputs = form.getElementsByTagName('input'); |
1667 var radios = new Array(); |
1667 var radios = new Array(); |
1668 var dbg = ''; |
1668 var dbg = ''; |
1669 for(var i = 0; i < inputs.length; i++) |
1669 for(var i = 0; i < inputs.length; i++) |
1670 { |
1670 { |
1671 if(inputs[i].type == 'radio') |
1671 if(inputs[i].type == 'radio') |
1672 radios.push(inputs[i]); |
1672 radios.push(inputs[i]); |
1673 } |
1673 } |
1674 for(var i in radios) |
1674 for(var i in radios) |
1675 { |
1675 { |
1676 if ( typeof(rules[ radios[i]['name'] ]) == 'number' ) |
1676 if ( typeof(rules[ radios[i]['name'] ]) == 'number' ) |
1677 { |
1677 { |
1678 radios[i].checked = ( rules[radios[i]['name']] == radios[i].value ); |
1678 radios[i].checked = ( rules[radios[i]['name']] == radios[i].value ); |
1679 } |
1679 } |
1680 } |
1680 } |
1681 } |
1681 } |
1682 |
1682 |
1683 function aclShowPresetSave() |
1683 function aclShowPresetSave() |
1684 { |
1684 { |
1685 miniPrompt(function(parent) |
1685 miniPrompt(function(parent) |
1686 { |
1686 { |
1687 parent.style.textAlign = 'center'; |
1687 parent.style.textAlign = 'center'; |
1688 |
1688 |
1689 parent.innerHTML = '<h3>' + $lang.get('acl_lbl_preset_save_title') + '</h3>'; |
1689 parent.innerHTML = '<h3>' + $lang.get('acl_lbl_preset_save_title') + '</h3>'; |
1690 var input = document.createElement('input'); |
1690 var input = document.createElement('input'); |
1691 input.id = aclManagerID + '_preset_save'; |
1691 input.id = aclManagerID + '_preset_save'; |
1692 input.type = 'text'; |
1692 input.type = 'text'; |
1693 input.size = '30'; |
1693 input.size = '30'; |
1694 input.onkeypress = function(e) |
1694 input.onkeypress = function(e) |
1695 { |
1695 { |
1696 // javascript sucks. IE and several others throw myriad errors unless it's done this way. |
1696 // javascript sucks. IE and several others throw myriad errors unless it's done this way. |
1697 if ( e ) |
1697 if ( e ) |
1698 if ( e.keyCode ) |
1698 if ( e.keyCode ) |
1699 if ( e.keyCode == 13 ) |
1699 if ( e.keyCode == 13 ) |
1700 { |
1700 { |
1701 if ( aclSavePreset() ) |
1701 if ( aclSavePreset() ) |
1702 { |
1702 { |
1703 if ( window.opera ) |
1703 if ( window.opera ) |
1704 { |
1704 { |
1705 // damn weird opera bug. |
1705 // damn weird opera bug. |
1706 var input = this; |
1706 var input = this; |
1707 setTimeout(function() |
1707 setTimeout(function() |
1708 { |
1708 { |
1709 miniPromptDestroy(input); |
1709 miniPromptDestroy(input); |
1710 }, 10); |
1710 }, 10); |
1711 } |
1711 } |
1712 else |
1712 else |
1713 { |
1713 { |
1714 miniPromptDestroy(this); |
1714 miniPromptDestroy(this); |
1715 } |
1715 } |
1716 } |
1716 } |
1717 } |
1717 } |
1718 else if ( e.keyCode == 27 ) |
1718 else if ( e.keyCode == 27 ) |
1719 { |
1719 { |
1720 miniPromptDestroy(this); |
1720 miniPromptDestroy(this); |
1721 } |
1721 } |
1722 } |
1722 } |
1723 var para = document.createElement('p'); |
1723 var para = document.createElement('p'); |
1724 para.appendChild(input); |
1724 para.appendChild(input); |
1725 |
1725 |
1726 parent.appendChild(para); |
1726 parent.appendChild(para); |
1727 |
1727 |
1728 // buttons |
1728 // buttons |
1729 var buttons = document.createElement('p'); |
1729 var buttons = document.createElement('p'); |
1730 |
1730 |
1731 // save button |
1731 // save button |
1732 var btn_save = document.createElement('a'); |
1732 var btn_save = document.createElement('a'); |
1733 btn_save.className = 'abutton abutton_green'; |
1733 btn_save.className = 'abutton abutton_green'; |
1734 btn_save.style.fontWeight = 'bold'; |
1734 btn_save.style.fontWeight = 'bold'; |
1735 btn_save.appendChild(document.createTextNode($lang.get('acl_btn_save_preset'))); |
1735 btn_save.appendChild(document.createTextNode($lang.get('acl_btn_save_preset'))); |
1736 btn_save.selectobj = select; |
1736 btn_save.selectobj = select; |
1737 btn_save.onclick = function() |
1737 btn_save.onclick = function() |
1738 { |
1738 { |
1739 if ( aclSavePreset() ) |
1739 if ( aclSavePreset() ) |
1740 { |
1740 { |
1741 miniPromptDestroy(this); |
1741 miniPromptDestroy(this); |
1742 } |
1742 } |
1743 return false; |
1743 return false; |
1744 } |
1744 } |
1745 btn_save.href = '#'; |
1745 btn_save.href = '#'; |
1746 buttons.appendChild(btn_save); |
1746 buttons.appendChild(btn_save); |
1747 |
1747 |
1748 buttons.appendChild(document.createTextNode(' ')); |
1748 buttons.appendChild(document.createTextNode(' ')); |
1749 |
1749 |
1750 // cancel button |
1750 // cancel button |
1751 var btn_cancel = document.createElement('a'); |
1751 var btn_cancel = document.createElement('a'); |
1752 btn_cancel.className = 'abutton'; |
1752 btn_cancel.className = 'abutton'; |
1753 btn_cancel.appendChild(document.createTextNode($lang.get('etc_cancel'))); |
1753 btn_cancel.appendChild(document.createTextNode($lang.get('etc_cancel'))); |
1754 btn_cancel.onclick = function() |
1754 btn_cancel.onclick = function() |
1755 { |
1755 { |
1756 miniPromptDestroy(this); |
1756 miniPromptDestroy(this); |
1757 return false; |
1757 return false; |
1758 } |
1758 } |
1759 btn_cancel.href = '#'; |
1759 btn_cancel.href = '#'; |
1760 buttons.appendChild(btn_cancel); |
1760 buttons.appendChild(btn_cancel); |
1761 |
1761 |
1762 parent.appendChild(buttons); |
1762 parent.appendChild(buttons); |
1763 |
1763 |
1764 var timeout = ( aclDisableTransitionFX ) ? 10 : 1000; |
1764 var timeout = ( aclDisableTransitionFX ) ? 10 : 1000; |
1765 setTimeout(function() |
1765 setTimeout(function() |
1766 { |
1766 { |
1767 input.focus(); |
1767 input.focus(); |
1768 }, timeout); |
1768 }, timeout); |
1769 }); |
1769 }); |
1770 } |
1770 } |
1771 |
1771 |
1772 function aclSavePreset() |
1772 function aclSavePreset() |
1773 { |
1773 { |
1774 var input = document.getElementById(aclManagerID + '_preset_save'); |
1774 var input = document.getElementById(aclManagerID + '_preset_save'); |
1775 if ( trim(input.value) == '' ) |
1775 if ( trim(input.value) == '' ) |
1776 { |
1776 { |
1777 alert($lang.get('acl_err_preset_name_empty')); |
1777 alert($lang.get('acl_err_preset_name_empty')); |
1778 return false; |
1778 return false; |
1779 } |
1779 } |
1780 var form = document.forms[aclManagerID + '_formobj'], selections = {}; |
1780 var form = document.forms[aclManagerID + '_formobj'], selections = {}; |
1781 var dbg = ''; |
1781 var dbg = ''; |
1782 var warned_everyone = false; |
1782 var warned_everyone = false; |
1783 for(var i in aclPermList) |
1783 for(var i in aclPermList) |
1784 { |
1784 { |
1785 selections[aclPermList[i]] = getRadioState(form, aclPermList[i], ['i', 1, 2, 3, 4]); |
1785 selections[aclPermList[i]] = getRadioState(form, aclPermList[i], ['i', 1, 2, 3, 4]); |
1786 // If we're editing permissions for everyone on the entire site and the |
1786 // If we're editing permissions for everyone on the entire site and the |
1787 // admin selected to deny privileges, give a stern warning about it. |
1787 // admin selected to deny privileges, give a stern warning about it. |
1788 if ( selections[aclPermList[i]] == 1 && aclDataCache.target_type == 1 /* ACL_TYPE_GROUP */ && aclDataCache.target_id == 1 && !warned_everyone ) |
1788 if ( selections[aclPermList[i]] == 1 && aclDataCache.target_type == 1 /* ACL_TYPE_GROUP */ && aclDataCache.target_id == 1 && !warned_everyone ) |
1789 { |
1789 { |
1790 warned_everyone = true; |
1790 warned_everyone = true; |
1791 if ( !confirm($lang.get('acl_msg_deny_everyone_confirm')) ) |
1791 if ( !confirm($lang.get('acl_msg_deny_everyone_confirm')) ) |
1792 { |
1792 { |
1793 return false; |
1793 return false; |
1794 } |
1794 } |
1795 } |
1795 } |
1796 dbg += aclPermList[i] + ': ' + selections[aclPermList[i]] + "\n"; |
1796 dbg += aclPermList[i] + ': ' + selections[aclPermList[i]] + "\n"; |
1797 if(!selections[aclPermList[i]]) |
1797 if(!selections[aclPermList[i]]) |
1798 { |
1798 { |
1799 alert("Invalid return from getRadioState: "+i+": "+selections[i]+" ("+typeof(selections[i])+")"); |
1799 alert("Invalid return from getRadioState: "+i+": "+selections[i]+" ("+typeof(selections[i])+")"); |
1800 return false; |
1800 return false; |
1801 } |
1801 } |
1802 } |
1802 } |
1803 |
1803 |
1804 var packet = toJSONString({ |
1804 var packet = toJSONString({ |
1805 mode: 'save_preset', |
1805 mode: 'save_preset', |
1806 preset_name: input.value, |
1806 preset_name: input.value, |
1807 perms: selections |
1807 perms: selections |
1808 }); |
1808 }); |
1809 |
1809 |
1810 var whitey = whiteOutElement(document.getElementById(aclManagerID)); |
1810 var whitey = whiteOutElement(document.getElementById(aclManagerID)); |
1811 |
1811 |
1812 ajaxPost(stdAjaxPrefix + '&_mode=acljson', 'acl_params=' + ajaxEscape(packet), function(ajax) |
1812 ajaxPost(stdAjaxPrefix + '&_mode=acljson', 'acl_params=' + ajaxEscape(packet), function(ajax) |
1813 { |
1813 { |
1814 if ( ajax.readyState == 4 && ajax.status == 200 ) |
1814 if ( ajax.readyState == 4 && ajax.status == 200 ) |
1815 { |
1815 { |
1816 if ( !check_json_response(ajax.responseText) ) |
1816 if ( !check_json_response(ajax.responseText) ) |
1817 { |
1817 { |
1818 whitey.parentNode.removeChild(whitey); |
1818 whitey.parentNode.removeChild(whitey); |
1819 return handle_invalid_json(ajax.responseText); |
1819 return handle_invalid_json(ajax.responseText); |
1820 } |
1820 } |
1821 var response = parseJSON(ajax.responseText); |
1821 var response = parseJSON(ajax.responseText); |
1822 if ( response.mode == 'error' ) |
1822 if ( response.mode == 'error' ) |
1823 { |
1823 { |
1824 whitey.parentNode.removeChild(whitey); |
1824 whitey.parentNode.removeChild(whitey); |
1825 alert(response.error); |
1825 alert(response.error); |
1826 return false; |
1826 return false; |
1827 } |
1827 } |
1828 whiteOutReportSuccess(whitey); |
1828 whiteOutReportSuccess(whitey); |
1829 } |
1829 } |
1830 }); |
1830 }); |
1831 |
1831 |
1832 return true; |
1832 return true; |
1833 } |
1833 } |
1834 |
1834 |
1835 function array_keys(obj) |
1835 function array_keys(obj) |
1836 { |
1836 { |
1837 keys = new Array(); |
1837 keys = new Array(); |
1838 for(var i in obj) |
1838 for(var i in obj) |
1839 keys.push(i); |
1839 keys.push(i); |
1840 return keys; |
1840 return keys; |
1841 } |
1841 } |