author | Dan |
Tue, 06 Nov 2007 16:40:19 -0500 | |
changeset 242 | 78a94f7bb5e3 |
parent 218 | e878bcf0227e |
child 326 | ab66d6d1f1f4 |
permissions | -rw-r--r-- |
1 | 1 |
// Javascript routines for the ACL editor |
2 |
||
3 |
var aclManagerID = 'enano_aclmanager_' + Math.floor(Math.random() * 1000000); |
|
4 |
var aclPermList = false; |
|
5 |
var aclDataCache = false; |
|
6 |
||
151
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
76
diff
changeset
|
7 |
// Can be set to true by slow themes (St. Patty) |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
76
diff
changeset
|
8 |
var aclDisableTransitionFX = false; |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
76
diff
changeset
|
9 |
|
1 | 10 |
function ajaxOpenACLManager(page_id, namespace) |
11 |
{ |
|
12 |
if(IE) |
|
13 |
return true; |
|
14 |
if(!page_id || !namespace) |
|
15 |
{ |
|
16 |
var data = strToPageID(title); |
|
17 |
var page_id = data[0]; |
|
18 |
var namespace = data[1]; |
|
19 |
} |
|
20 |
var params = { |
|
21 |
'mode' : 'listgroups', |
|
22 |
'page_id' : page_id, |
|
23 |
'namespace' : namespace |
|
24 |
}; |
|
25 |
params = toJSONString(params); |
|
26 |
params = ajaxEscape(params); |
|
27 |
ajaxPost(stdAjaxPrefix+'&_mode=acljson', 'acl_params='+params, function() { |
|
28 |
if(ajax.readyState == 4) |
|
29 |
{ |
|
30 |
__aclBuildWizardWindow(); |
|
31 |
groups = parseJSON(ajax.responseText); |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
32 |
if ( groups.mode == 'error' ) |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
33 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
34 |
alert(groups.error); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
35 |
killACLManager(); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
36 |
return false; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
37 |
} |
1 | 38 |
aclDataCache = groups; |
39 |
__aclBuildSelector(groups); |
|
40 |
} |
|
41 |
}); |
|
42 |
return false; |
|
43 |
} |
|
44 |
||
45 |
function ajaxACLSwitchToSelector() |
|
46 |
{ |
|
47 |
params = { |
|
48 |
'mode' : 'listgroups' |
|
49 |
}; |
|
50 |
if ( aclDataCache.page_id && aclDataCache.namespace ) |
|
51 |
{ |
|
52 |
params.page_id = aclDataCache.page_id; |
|
53 |
params.namespace = aclDataCache.namespace; |
|
54 |
} |
|
55 |
params = toJSONString(params); |
|
56 |
params = ajaxEscape(params); |
|
57 |
ajaxPost(stdAjaxPrefix+'&_mode=acljson', 'acl_params='+params, function() { |
|
58 |
if(ajax.readyState == 4) |
|
59 |
{ |
|
60 |
document.getElementById(aclManagerID+'_main').innerHTML = ''; |
|
61 |
document.getElementById(aclManagerID + '_back').style.display = 'none'; |
|
218 | 62 |
document.getElementById(aclManagerID + '_next').value = $lang.get('etc_wizard_next'); |
1 | 63 |
groups = parseJSON(ajax.responseText); |
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
64 |
if ( groups.mode == 'error' ) |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
65 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
66 |
alert(groups.error); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
67 |
killACLManager(); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
68 |
return false; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
69 |
} |
1 | 70 |
aclDataCache = groups; |
71 |
thispage = strToPageID(title); |
|
72 |
groups.page_id = thispage[0]; |
|
73 |
groups.namespace = thispage[1]; |
|
74 |
__aclBuildSelector(groups); |
|
75 |
} |
|
76 |
}); |
|
77 |
} |
|
78 |
||
79 |
function __aclBuildSelector(groups) |
|
80 |
{ |
|
81 |
thispage = strToPageID(title); |
|
82 |
do_scopesel = ( thispage[0] == groups.page_id && thispage[1] == groups.namespace ); |
|
83 |
||
84 |
seed = Math.floor(Math.random() * 1000000); |
|
85 |
||
86 |
main = document.getElementById(aclManagerID + '_main'); |
|
87 |
main.style.padding = '10px'; |
|
88 |
||
89 |
selector = document.createElement('div'); |
|
90 |
||
91 |
grpsel = __aclBuildGroupsHTML(groups); |
|
92 |
grpsel.name = 'group_id'; |
|
93 |
||
94 |
span = document.createElement('div'); |
|
95 |
span.id = "enACL_grpbox_"+seed+""; |
|
96 |
||
97 |
// Build the selector |
|
98 |
grpb = document.createElement('input'); |
|
99 |
grpb.type = 'radio'; |
|
100 |
grpb.name = 'target_type'; |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
101 |
grpb.value = '1'; // ACL_TYPE_GROUP |
1 | 102 |
grpb.checked = 'checked'; |
103 |
grpb.className = seed; |
|
104 |
grpb.onclick = function() { seed = this.className; document.getElementById('enACL_grpbox_'+seed).style.display = 'block'; document.getElementById('enACL_usrbox_'+seed).style.display = 'none'; }; |
|
105 |
lbl = document.createElement('label'); |
|
106 |
lbl.appendChild(grpb); |
|
218 | 107 |
lbl.appendChild(document.createTextNode($lang.get('acl_radio_usergroup'))); |
1 | 108 |
lbl.style.display = 'block'; |
109 |
span.appendChild(grpsel); |
|
110 |
||
42
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
111 |
anoninfo = document.createElement('div'); |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
112 |
anoninfo.className = 'info-box-mini'; |
218 | 113 |
anoninfo.appendChild(document.createTextNode($lang.get('acl_msg_guest_howto'))); |
42
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
114 |
span.appendChild(document.createElement('br')); |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
115 |
span.appendChild(anoninfo); |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
116 |
|
1 | 117 |
usrb = document.createElement('input'); |
118 |
usrb.type = 'radio'; |
|
119 |
usrb.name = 'target_type'; |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
120 |
usrb.value = '2'; // ACL_TYPE_USER |
1 | 121 |
usrb.className = seed; |
122 |
usrb.onclick = function() { seed = this.className; document.getElementById('enACL_grpbox_'+seed).style.display = 'none'; document.getElementById('enACL_usrbox_'+seed).style.display = 'block'; }; |
|
123 |
lbl2 = document.createElement('label'); |
|
124 |
lbl2.appendChild(usrb); |
|
218 | 125 |
lbl2.appendChild(document.createTextNode($lang.get('acl_radio_user'))); |
1 | 126 |
lbl2.style.display = 'block'; |
127 |
||
128 |
usrsel = document.createElement('input'); |
|
129 |
usrsel.type = 'text'; |
|
130 |
usrsel.name = 'username'; |
|
184
d74ff822acc9
Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
151
diff
changeset
|
131 |
usrsel.onkeyup = function() { new AutofillUsername(this, undefined, true); }; |
1 | 132 |
usrsel.id = 'userfield_' + aclManagerID; |
133 |
try { |
|
134 |
usrsel.setAttribute("autocomplete","off"); |
|
135 |
} catch(e) {}; |
|
136 |
||
137 |
span2 = document.createElement('div'); |
|
138 |
span2.id = "enACL_usrbox_"+seed+""; |
|
139 |
span2.style.display = 'none'; |
|
140 |
span2.appendChild(usrsel); |
|
141 |
||
142 |
// Scope selector |
|
143 |
if(do_scopesel) |
|
144 |
{ |
|
145 |
scopediv1 = document.createElement('div'); |
|
146 |
scopediv2 = document.createElement('div'); |
|
73
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
147 |
scopediv3 = document.createElement('div'); |
1 | 148 |
scopeRadioPage = document.createElement('input'); |
149 |
scopeRadioPage.type = 'radio'; |
|
150 |
scopeRadioPage.name = 'scope'; |
|
151 |
scopeRadioPage.value = 'page'; |
|
152 |
scopeRadioPage.checked = 'checked'; |
|
73
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
153 |
scopeRadioPage.className = '1048576'; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
154 |
if ( groups.page_groups.length > 0 ) scopeRadioPage.onclick = function() { var id = 'enACL_pgsel_' + this.className; document.getElementById(id).style.display = 'none'; }; |
1 | 155 |
scopeRadioGlobal = document.createElement('input'); |
156 |
scopeRadioGlobal.type = 'radio'; |
|
157 |
scopeRadioGlobal.name = 'scope'; |
|
158 |
scopeRadioGlobal.value = 'global'; |
|
73
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
159 |
scopeRadioGlobal.className = '1048576'; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
160 |
if ( groups.page_groups.length > 0 ) scopeRadioGlobal.onclick = function() { var id = 'enACL_pgsel_' + this.className; document.getElementById(id).style.display = 'none'; }; |
73
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
161 |
scopeRadioGroup = document.createElement('input'); |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
162 |
scopeRadioGroup.type = 'radio'; |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
163 |
scopeRadioGroup.name = 'scope'; |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
164 |
scopeRadioGroup.value = 'group'; |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
165 |
scopeRadioGroup.className = '1048576'; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
166 |
if ( groups.page_groups.length > 0 ) scopeRadioGroup.onclick = function() { var id = 'enACL_pgsel_' + this.className; document.getElementById(id).style.display = 'block'; }; |
1 | 167 |
lblPage = document.createElement('label'); |
168 |
lblPage.style.display = 'block'; |
|
169 |
lblPage.appendChild(scopeRadioPage); |
|
218 | 170 |
lblPage.appendChild(document.createTextNode($lang.get('acl_radio_scope_thispage'))); |
1 | 171 |
lblGlobal = document.createElement('label'); |
172 |
lblGlobal.style.display = 'block'; |
|
173 |
lblGlobal.appendChild(scopeRadioGlobal); |
|
218 | 174 |
lblGlobal.appendChild(document.createTextNode($lang.get('acl_radio_scope_wholesite'))); |
73
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
175 |
lblGroup = document.createElement('label'); |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
176 |
lblGroup.style.display = 'block'; |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
177 |
lblGroup.appendChild(scopeRadioGroup); |
218 | 178 |
lblGroup.appendChild(document.createTextNode($lang.get('acl_radio_scope_pagegroup'))); |
1 | 179 |
scopediv1.appendChild(lblPage); |
73
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
180 |
scopediv2.appendChild(lblGroup); |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
181 |
scopediv3.appendChild(lblGlobal); |
1 | 182 |
|
183 |
scopedesc = document.createElement('p'); |
|
218 | 184 |
scopedesc.appendChild(document.createTextNode($lang.get('acl_lbl_scope'))); |
73
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
185 |
|
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
186 |
scopePGrp = document.createElement('select'); |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
187 |
scopePGrp.style.marginLeft = '13px'; |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
188 |
scopePGrp.style.display = 'none'; |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
189 |
scopePGrp.id = "enACL_pgsel_1048576"; |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
190 |
|
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
191 |
var opt; |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
192 |
for ( var i = 0; i < groups.page_groups.length; i++ ) |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
193 |
{ |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
194 |
opt = document.createElement('option'); |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
195 |
opt.value = groups.page_groups[i].id; |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
196 |
opt.appendChild(document.createTextNode(groups.page_groups[i].name)); |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
197 |
scopePGrp.appendChild(opt); |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
198 |
} |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
199 |
|
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
200 |
scopediv2.appendChild(scopePGrp); |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
201 |
|
1 | 202 |
} |
203 |
||
204 |
// Styles |
|
205 |
span.style.marginLeft = '13px'; |
|
206 |
span.style.padding = '5px 0'; |
|
207 |
span2.style.marginLeft = '13px'; |
|
208 |
span2.style.padding = '5px 0'; |
|
209 |
||
210 |
selector.appendChild(lbl); |
|
211 |
selector.appendChild(span); |
|
212 |
||
213 |
selector.appendChild(lbl2); |
|
214 |
selector.appendChild(span2); |
|
215 |
||
216 |
container = document.createElement('div'); |
|
217 |
container.style.margin = 'auto'; |
|
218 |
container.style.width = '360px'; |
|
73
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
219 |
container.style.paddingTop = '50px'; |
1 | 220 |
|
221 |
head = document.createElement('h2'); |
|
218 | 222 |
head.appendChild(document.createTextNode($lang.get('acl_lbl_welcome_title'))); |
1 | 223 |
|
224 |
desc = document.createElement('p'); |
|
218 | 225 |
desc.appendChild(document.createTextNode($lang.get('acl_lbl_welcome_body'))); |
1 | 226 |
|
227 |
container.appendChild(head); |
|
228 |
container.appendChild(desc); |
|
229 |
container.appendChild(selector); |
|
230 |
||
231 |
if(do_scopesel) |
|
232 |
{ |
|
233 |
container.appendChild(scopedesc); |
|
234 |
container.appendChild(scopediv1); |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
235 |
if ( groups.page_groups.length > 0 ) |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
236 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
237 |
container.appendChild(scopediv2); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
238 |
} |
73
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
239 |
container.appendChild(scopediv3); |
1 | 240 |
} |
241 |
||
242 |
main.appendChild(container); |
|
243 |
||
244 |
var mode = document.createElement('input'); |
|
245 |
mode.name = 'mode'; |
|
246 |
mode.type = 'hidden'; |
|
247 |
mode.id = aclManagerID + '_mode'; |
|
248 |
mode.value = 'seltarget'; |
|
249 |
||
250 |
var theform = document.getElementById(aclManagerID + '_formobj_id'); |
|
251 |
if ( !theform.mode ) |
|
252 |
{ |
|
253 |
theform.appendChild(mode); |
|
254 |
} |
|
255 |
else |
|
256 |
{ |
|
257 |
theform.removeChild(theform.mode); |
|
258 |
theform.appendChild(mode); |
|
259 |
} |
|
260 |
} |
|
261 |
||
262 |
var aclDebugWin = false; |
|
263 |
||
264 |
function aclDebug(text) |
|
265 |
{ |
|
266 |
if(!aclDebugWin) |
|
267 |
aclDebugWin = pseudoWindowOpen("data:text/html;plain,<html><head><title>debug win</title></head><body><h1>Debug window</h1></body></html>", "aclDebugWin"); |
|
268 |
setTimeout(function() { |
|
269 |
aclDebugWin.pre = aclDebugWin.document.createElement('pre'); |
|
270 |
aclDebugWin.pre.appendChild(aclDebugWin.document.createTextNode(text)); |
|
271 |
aclDebugWin.b = aclDebugWin.document.getElementsByTagName('body')[0]; |
|
272 |
aclDebugWin.b.appendChild(aclDebugWin.pre);}, 1000); |
|
273 |
} |
|
274 |
||
275 |
var pseudoWindows = new Object(); |
|
276 |
||
277 |
function pseudoWindowOpen(url, id) |
|
278 |
{ |
|
279 |
if(pseudoWindows[id]) |
|
280 |
{ |
|
281 |
document.getElementById('pseudowin_ifr_'+id).src = url; |
|
282 |
} |
|
283 |
else |
|
284 |
{ |
|
285 |
win = document.createElement('iframe'); |
|
286 |
win.style.position='fixed'; |
|
287 |
win.style.width = '640px'; |
|
288 |
win.style.height = '480px'; |
|
289 |
win.style.top = '0px'; |
|
290 |
win.style.left = '0px'; |
|
291 |
win.style.zIndex = getHighestZ() + 1; |
|
292 |
win.style.backgroundColor = '#FFFFFF'; |
|
293 |
win.name = 'pseudo_ifr_'+id; |
|
294 |
win.id = 'pseudowindow_ifr_'+id; |
|
295 |
win.src = url; |
|
296 |
body = document.getElementsByTagName('body')[0]; |
|
297 |
body.appendChild(win); |
|
298 |
} |
|
299 |
win_obj = eval("( pseudo_ifr_"+id+" )"); |
|
300 |
return win_obj; |
|
301 |
} |
|
302 |
||
303 |
function __aclJSONSubmitAjaxHandler(params) |
|
304 |
{ |
|
305 |
params = toJSONString(params); |
|
306 |
params = ajaxEscape(params); |
|
307 |
ajaxPost(stdAjaxPrefix+'&_mode=acljson', 'acl_params='+params, function() { |
|
308 |
if(ajax.readyState == 4) |
|
309 |
{ |
|
310 |
try { |
|
311 |
data = parseJSON(ajax.responseText); |
|
312 |
} catch(e) { |
|
313 |
aclDebug(e+"\n\nResponse:\n"+ajax.responseText); |
|
314 |
} |
|
315 |
aclDataCache = data; |
|
316 |
switch(data.mode) |
|
317 |
{ |
|
318 |
case 'seltarget': |
|
319 |
||
320 |
// Build the ACL edit form |
|
321 |
// try { |
|
218 | 322 |
|
323 |
var act_desc = ( data.type == 'new' ) ? $lang.get('acl_lbl_editwin_title_create') : $lang.get('acl_lbl_editwin_title_edit'); |
|
324 |
var target_type_t = ( data.target_type == 1 ) ? $lang.get('acl_target_type_group') : $lang.get('acl_target_type_user'); |
|
325 |
var target_name_t = data.target_name; |
|
326 |
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'); |
|
327 |
||
328 |
html = '<h2>'+act_desc+'</h2>'; |
|
329 |
html += '<p>' + $lang.get('acl_lbl_editwin_body', { target_type: target_type_t, target: target_name_t, scope_type: scope_type }) + '</p>'; |
|
1 | 330 |
parser = new templateParser(data.template.acl_field_begin); |
331 |
html += parser.run(); |
|
332 |
||
333 |
cls = 'row2'; |
|
334 |
for(var i in data.acl_types) |
|
335 |
{ |
|
336 |
if(typeof(data.acl_types[i]) == 'number') |
|
337 |
{ |
|
338 |
cls = ( cls == 'row1' ) ? 'row2' : 'row1'; |
|
339 |
p = new templateParser(data.template.acl_field_item); |
|
340 |
vars = new Object(); |
|
218 | 341 |
if ( data.acl_descs[i].match(/^([a-z0-9_]+)$/) ) |
342 |
{ |
|
343 |
vars['FIELD_DESC'] = $lang.get(data.acl_descs[i]); |
|
344 |
} |
|
345 |
else |
|
346 |
{ |
|
347 |
vars['FIELD_DESC'] = data.acl_descs[i]; |
|
348 |
} |
|
1 | 349 |
vars['FIELD_DENY_CHECKED'] = ''; |
350 |
vars['FIELD_DISALLOW_CHECKED'] = ''; |
|
351 |
vars['FIELD_WIKIMODE_CHECKED'] = ''; |
|
352 |
vars['FIELD_ALLOW_CHECKED'] = ''; |
|
353 |
vars['FIELD_NAME'] = i; |
|
354 |
switch(data.current_perms[i]) |
|
355 |
{ |
|
356 |
case 1: |
|
357 |
vars['FIELD_DENY_CHECKED'] = 'checked="checked"'; |
|
358 |
break; |
|
359 |
case 2: |
|
360 |
default: |
|
361 |
vars['FIELD_DISALLOW_CHECKED'] = 'checked="checked"'; |
|
362 |
break; |
|
363 |
case 3: |
|
364 |
vars['FIELD_WIKIMODE_CHECKED'] = 'checked="checked"'; |
|
365 |
break; |
|
366 |
case 4: |
|
367 |
vars['FIELD_ALLOW_CHECKED'] = 'checked="checked"'; |
|
368 |
break; |
|
369 |
} |
|
370 |
vars['ROW_CLASS'] = cls; |
|
371 |
p.assign_vars(vars); |
|
372 |
html += p.run(); |
|
373 |
} |
|
374 |
} |
|
375 |
||
376 |
var parser = new templateParser(data.template.acl_field_end); |
|
377 |
html += parser.run(); |
|
378 |
||
379 |
if(data.type == 'edit') |
|
218 | 380 |
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>'; |
1 | 381 |
|
382 |
var main = document.getElementById(aclManagerID + '_main'); |
|
383 |
main.innerHTML = html; |
|
384 |
||
385 |
var form = document.getElementById(aclManagerID + '_formobj_id'); |
|
386 |
||
387 |
var modeobj = form_fetch_field(form, 'mode'); |
|
388 |
if ( modeobj ) |
|
389 |
modeobj.value = 'save_' + data.type; |
|
390 |
else |
|
391 |
alert('modeobj is invalid: '+modeobj); |
|
392 |
||
393 |
aclPermList = array_keys(data.acl_types); |
|
394 |
||
395 |
document.getElementById(aclManagerID + '_back').style.display = 'inline'; |
|
218 | 396 |
document.getElementById(aclManagerID + '_next').value = $lang.get('etc_save_changes'); |
1 | 397 |
|
398 |
// } catch(e) { alert(e); aclDebug(ajax.responseText); } |
|
399 |
||
400 |
break; |
|
401 |
case 'success': |
|
402 |
var note = document.createElement('div'); |
|
403 |
note.className = 'info-box'; |
|
404 |
note.style.marginLeft = '0'; |
|
405 |
var b = document.createElement('b'); |
|
218 | 406 |
b.appendChild(document.createTextNode($lang.get('acl_lbl_save_success_title'))); |
1 | 407 |
note.appendChild(b); |
408 |
note.appendChild(document.createElement('br')); |
|
218 | 409 |
note.appendChild(document.createTextNode($lang.get('acl_lbl_save_success_body', { target_name: data.target_name }))); |
1 | 410 |
note.appendChild(document.createElement('br')); |
411 |
var a = document.createElement('a'); |
|
412 |
a.href = 'javascript:void(0);'; |
|
413 |
a.onclick = function() { this.parentNode.parentNode.removeChild(this.parentNode); return false; }; |
|
218 | 414 |
a.appendChild(document.createTextNode('[ ' + $lang.get('acl_btn_success_dismiss') + ' :')); |
1 | 415 |
note.appendChild(a); |
416 |
var a2 = document.createElement('a'); |
|
417 |
a2.href = 'javascript:void(0);'; |
|
418 |
a2.onclick = function() { killACLManager(); return false; }; |
|
218 | 419 |
a2.appendChild(document.createTextNode(': ' + $lang.get('acl_btn_success_close') + ' ]')); |
1 | 420 |
note.appendChild(a2); |
421 |
document.getElementById(aclManagerID + '_main').insertBefore(note, document.getElementById(aclManagerID + '_main').firstChild); |
|
422 |
if(!document.getElementById(aclManagerID+'_deletelnk')) |
|
218 | 423 |
document.getElementById(aclManagerID + '_main').innerHTML += '<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>'; |
1 | 424 |
//fadeInfoBoxes(); |
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
425 |
document.getElementById(aclManagerID+'_main').scrollTop = 0; |
42
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
426 |
|
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
427 |
aclDataCache.mode = 'save_edit'; |
1 | 428 |
break; |
429 |
case 'delete': |
|
430 |
||
431 |
params = { |
|
432 |
'mode' : 'listgroups' |
|
433 |
}; |
|
434 |
params = toJSONString(params); |
|
435 |
params = ajaxEscape(params); |
|
436 |
ajaxPost(stdAjaxPrefix+'&_mode=acljson', 'acl_params='+params, function() { |
|
437 |
if(ajax.readyState == 4) |
|
438 |
{ |
|
439 |
document.getElementById(aclManagerID+'_main').innerHTML = ''; |
|
440 |
document.getElementById(aclManagerID + '_back').style.display = 'none'; |
|
218 | 441 |
document.getElementById(aclManagerID + '_next').value = $lang.get('etc_wizard_next'); |
1 | 442 |
var thispage = strToPageID(title); |
443 |
groups.page_id = thispage[0]; |
|
444 |
groups.namespace = thispage[1]; |
|
445 |
__aclBuildSelector(groups); |
|
446 |
||
447 |
note = document.createElement('div'); |
|
448 |
note.className = 'info-box'; |
|
449 |
note.style.marginLeft = '0'; |
|
42
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
450 |
note.style.position = 'absolute'; |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
451 |
note.style.width = '558px'; |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
452 |
note.id = 'aclSuccessNotice_' + Math.floor(Math.random() * 100000); |
1 | 453 |
b = document.createElement('b'); |
218 | 454 |
b.appendChild(document.createTextNode($lang.get('acl_lbl_delete_success_title'))); |
1 | 455 |
note.appendChild(b); |
456 |
note.appendChild(document.createElement('br')); |
|
218 | 457 |
note.appendChild(document.createTextNode($lang.get('acl_lbl_delete_success_title', { target_name: aclDataCache.target_name }))); |
1 | 458 |
note.appendChild(document.createElement('br')); |
459 |
a = document.createElement('a'); |
|
460 |
a.href = '#'; |
|
42
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
461 |
a.onclick = function() { opacity(this.parentNode.id, 100, 0, 1000); setTimeout('var div = document.getElementById("' + this.parentNode.id + '"); div.parentNode.removeChild(div);', 1100); return false; }; |
218 | 462 |
a.appendChild(document.createTextNode('[ ' + $lang.get('acl_btn_success_dismiss') + ' :')); |
1 | 463 |
note.appendChild(a); |
464 |
a = document.createElement('a'); |
|
465 |
a.href = '#'; |
|
466 |
a.onclick = function() { killACLManager(); return false; }; |
|
218 | 467 |
a.appendChild(document.createTextNode(': ' + $lang.get('acl_btn_success_close') + ' ]')); |
1 | 468 |
note.appendChild(a); |
469 |
document.getElementById(aclManagerID + '_main').insertBefore(note, document.getElementById(aclManagerID + '_main').firstChild); |
|
470 |
//fadeInfoBoxes(); |
|
471 |
||
472 |
} |
|
473 |
}); |
|
474 |
||
475 |
break; |
|
476 |
case 'error': |
|
477 |
alert("Server side processing error:\n"+data.error); |
|
478 |
break; |
|
479 |
case 'debug': |
|
480 |
aclDebug(data.text); |
|
481 |
break; |
|
482 |
default: |
|
483 |
alert("Invalid JSON response from server\nMode: "+data.mode+"\nJSON string: "+ajax.responseText); |
|
484 |
break; |
|
485 |
} |
|
486 |
} |
|
487 |
}); |
|
488 |
} |
|
489 |
||
490 |
function __aclBuildGroupsHTML(groups) |
|
491 |
{ |
|
492 |
groups = groups.groups; |
|
493 |
select = document.createElement('select'); |
|
494 |
for(var i in groups) |
|
495 |
{ |
|
496 |
if(typeof(groups[i]['name']) == 'string' && i != 'toJSONString') |
|
497 |
{ |
|
498 |
o = document.createElement('option'); |
|
499 |
o.value = groups[i]['id']; |
|
500 |
t = document.createTextNode(groups[i]['name']); |
|
501 |
o.appendChild(t); |
|
502 |
select.appendChild(o); |
|
503 |
} |
|
504 |
} |
|
505 |
return select; |
|
506 |
} |
|
507 |
||
508 |
function __aclBuildWizardWindow() |
|
509 |
{ |
|
151
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
76
diff
changeset
|
510 |
darken(aclDisableTransitionFX); |
1 | 511 |
box = document.createElement('div'); |
512 |
box.style.width = '640px' |
|
513 |
box.style.height = '440px'; |
|
514 |
box.style.position = 'fixed'; |
|
515 |
width = getWidth(); |
|
516 |
height = getHeight(); |
|
517 |
box.style.left = ( width / 2 - 320 ) + 'px'; |
|
518 |
box.style.top = ( height / 2 - 250 ) + 'px'; |
|
519 |
box.style.backgroundColor = 'white'; |
|
520 |
box.style.zIndex = getHighestZ() + 1; |
|
521 |
box.id = aclManagerID; |
|
522 |
box.style.opacity = '0'; |
|
523 |
box.style.filter = 'alpha(opacity=0)'; |
|
524 |
box.style.display = 'none'; |
|
525 |
||
526 |
mainwin = document.createElement('div'); |
|
527 |
mainwin.id = aclManagerID + '_main'; |
|
528 |
mainwin.style.clip = 'rect(0px,640px,440px,0px)'; |
|
529 |
mainwin.style.overflow = 'auto'; |
|
530 |
mainwin.style.width = '620px'; |
|
531 |
mainwin.style.height = '420px'; |
|
532 |
||
533 |
panel = document.createElement('div'); |
|
534 |
panel.style.width = '620px'; |
|
535 |
panel.style.padding = '10px'; |
|
536 |
panel.style.lineHeight = '40px'; |
|
537 |
panel.style.textAlign = 'right'; |
|
538 |
panel.style.position = 'fixed'; |
|
539 |
panel.style.left = ( width / 2 - 320 ) + 'px'; |
|
540 |
panel.style.top = ( height / 2 + 190 ) + 'px'; |
|
541 |
panel.style.backgroundColor = '#D0D0D0'; |
|
542 |
panel.style.opacity = '0'; |
|
543 |
panel.style.filter = 'alpha(opacity=0)'; |
|
544 |
panel.id = aclManagerID + '_panel'; |
|
545 |
||
546 |
form = document.createElement('form'); |
|
547 |
form.method = 'post'; |
|
548 |
form.action = 'javascript:void(0)'; |
|
549 |
form.onsubmit = function() { if(this.username && !submitAuthorized) return false; __aclSubmitManager(this); return false; }; |
|
550 |
form.name = aclManagerID + '_formobj'; |
|
551 |
form.id = aclManagerID + '_formobj_id'; |
|
552 |
||
553 |
back = document.createElement('input'); |
|
554 |
back.type = 'button'; |
|
218 | 555 |
back.value = $lang.get('etc_wizard_back'); |
1 | 556 |
back.style.fontWeight = 'normal'; |
557 |
back.onclick = function() { ajaxACLSwitchToSelector(); return false; }; |
|
558 |
back.style.display = 'none'; |
|
559 |
back.id = aclManagerID + '_back'; |
|
560 |
||
561 |
saver = document.createElement('input'); |
|
562 |
saver.type = 'submit'; |
|
218 | 563 |
saver.value = $lang.get('etc_wizard_next'); |
1 | 564 |
saver.style.fontWeight = 'bold'; |
565 |
saver.id = aclManagerID + '_next'; |
|
566 |
||
567 |
closer = document.createElement('input'); |
|
568 |
closer.type = 'button'; |
|
218 | 569 |
closer.value = $lang.get('etc_cancel_changes'); |
570 |
closer.onclick = function() { if(!confirm($lang.get('acl_msg_closeacl_confirm'))) return false; killACLManager(); return false; } |
|
1 | 571 |
|
572 |
spacer1 = document.createTextNode(' '); |
|
573 |
spacer2 = document.createTextNode(' '); |
|
574 |
||
575 |
panel.appendChild(back); |
|
576 |
panel.appendChild(spacer1); |
|
577 |
panel.appendChild(saver); |
|
578 |
panel.appendChild(spacer2); |
|
579 |
panel.appendChild(closer); |
|
580 |
form.appendChild(mainwin); |
|
581 |
form.appendChild(panel); |
|
582 |
box.appendChild(form); |
|
583 |
||
584 |
body = document.getElementsByTagName('body')[0]; |
|
585 |
body.appendChild(box); |
|
151
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
76
diff
changeset
|
586 |
if ( aclDisableTransitionFX ) |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
76
diff
changeset
|
587 |
{ |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
76
diff
changeset
|
588 |
document.getElementById(aclManagerID).style.display = 'block'; |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
76
diff
changeset
|
589 |
changeOpac(100, aclManagerID); |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
76
diff
changeset
|
590 |
changeOpac(100, aclManagerID + '_panel'); |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
76
diff
changeset
|
591 |
} |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
76
diff
changeset
|
592 |
else |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
76
diff
changeset
|
593 |
{ |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
76
diff
changeset
|
594 |
setTimeout("document.getElementById('"+aclManagerID+"').style.display = 'block'; opacity('"+aclManagerID+"', 0, 100, 500); opacity('"+aclManagerID + '_panel'+"', 0, 100, 500);", 1000); |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
76
diff
changeset
|
595 |
} |
1 | 596 |
} |
597 |
||
598 |
function killACLManager() |
|
599 |
{ |
|
600 |
el = document.getElementById(aclManagerID); |
|
601 |
if(el) |
|
602 |
{ |
|
151
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
76
diff
changeset
|
603 |
if ( aclDisableTransitionFX ) |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
76
diff
changeset
|
604 |
{ |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
76
diff
changeset
|
605 |
enlighten(true); |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
76
diff
changeset
|
606 |
el.parentNode.removeChild(el); |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
76
diff
changeset
|
607 |
} |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
76
diff
changeset
|
608 |
else |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
76
diff
changeset
|
609 |
{ |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
76
diff
changeset
|
610 |
opacity(aclManagerID, 100, 0, 500); |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
76
diff
changeset
|
611 |
setTimeout('var el = document.getElementById(aclManagerID); el.parentNode.removeChild(el); enlighten();', 750); |
824821224153
Added a new Javascript variable, aclDisableTransitionFX, that will switch off effects on message boxes and the ACL editor when set to true
Dan
parents:
76
diff
changeset
|
612 |
} |
1 | 613 |
} |
614 |
} |
|
615 |
||
616 |
function __aclSubmitManager(form) |
|
617 |
{ |
|
618 |
var thefrm = document.forms[form.name]; |
|
619 |
var modeobj = form_fetch_field(thefrm, 'mode'); |
|
620 |
if ( typeof(modeobj) == 'object' ) |
|
621 |
{ |
|
622 |
var mode = (thefrm.mode.value) ? thefrm.mode.value : 'cant_get'; |
|
623 |
} |
|
624 |
else |
|
625 |
{ |
|
626 |
var mode = ''; |
|
627 |
} |
|
628 |
switch(mode) |
|
629 |
{ |
|
630 |
case 'cant_get': |
|
631 |
alert('BUG: can\'t get the state value from the form field.'); |
|
632 |
break; |
|
633 |
case 'seltarget': |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
634 |
var target_type = parseInt(getRadioState(thefrm, 'target_type', ['1', '2'])); |
1 | 635 |
if(isNaN(target_type)) |
636 |
{ |
|
218 | 637 |
alert($lang.get('acl_err_pleaseselect_targettype')); |
1 | 638 |
return false; |
639 |
} |
|
640 |
target_id = ( target_type == 1 ) ? parseInt(thefrm.group_id.value) : thefrm.username.value; |
|
641 |
||
642 |
obj = { 'mode' : mode, 'target_type' : target_type, 'target_id' : target_id }; |
|
643 |
||
644 |
thispage = strToPageID(title); |
|
645 |
do_scopesel = ( thispage[0] == aclDataCache.page_id && thispage[1] == aclDataCache.namespace ); |
|
646 |
||
647 |
if(do_scopesel) |
|
648 |
{ |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
649 |
scope = getRadioState(thefrm, 'scope', ['page', 'global']); |
1 | 650 |
if(scope == 'page') |
651 |
{ |
|
652 |
pageid = strToPageID(title); |
|
653 |
obj['page_id'] = pageid[0]; |
|
654 |
obj['namespace'] = pageid[1]; |
|
655 |
} |
|
656 |
else if(scope == 'global') |
|
657 |
{ |
|
658 |
obj['page_id'] = false; |
|
659 |
obj['namespace'] = false; |
|
660 |
} |
|
73
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
661 |
else if(scope == 'group') |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
662 |
{ |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
663 |
obj['page_id'] = document.getElementById('enACL_pgsel_1048576').value; |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
664 |
obj['namespace'] = '__PageGroup'; |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
665 |
} |
1 | 666 |
else |
667 |
{ |
|
668 |
alert('Invalid scope'); |
|
669 |
return false; |
|
670 |
} |
|
671 |
} |
|
672 |
else |
|
673 |
{ |
|
674 |
obj['page_id'] = aclDataCache.page_id; |
|
675 |
obj['namespace'] = aclDataCache.namespace; |
|
676 |
} |
|
677 |
if(target_id == '') |
|
678 |
{ |
|
218 | 679 |
alert($lang.get('acl_err_pleaseselect_username')); |
1 | 680 |
return false; |
681 |
} |
|
682 |
__aclJSONSubmitAjaxHandler(obj); |
|
683 |
break; |
|
684 |
case 'save_edit': |
|
685 |
case 'save_new': |
|
686 |
var form = document.forms[aclManagerID + '_formobj']; |
|
687 |
selections = new Object(); |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
688 |
var dbg = ''; |
1 | 689 |
for(var i in aclPermList) |
690 |
{ |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
691 |
selections[aclPermList[i]] = getRadioState(form, aclPermList[i], [1, 2, 3, 4]); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
692 |
dbg += aclPermList[i] + ': ' + selections[aclPermList[i]] + "\n"; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
693 |
if(!selections[aclPermList[i]]) |
1 | 694 |
{ |
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
695 |
alert("Invalid return from getRadioState: "+i+": "+selections[i]+" ("+typeof(selections[i])+")"); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
696 |
return false; |
1 | 697 |
} |
698 |
} |
|
699 |
obj = new Object(); |
|
700 |
obj['perms'] = selections; |
|
701 |
obj['mode'] = mode; |
|
702 |
obj['target_type'] = aclDataCache.target_type; |
|
703 |
obj['target_id'] = aclDataCache.target_id; |
|
704 |
obj['target_name'] = aclDataCache.target_name; |
|
705 |
obj['page_id'] = aclDataCache.page_id; |
|
706 |
obj['namespace'] = aclDataCache.namespace; |
|
707 |
__aclJSONSubmitAjaxHandler(obj); |
|
708 |
break; |
|
709 |
default: |
|
710 |
alert("JSON form submit: invalid mode string "+mode+", stopping execution"); |
|
711 |
return false; |
|
712 |
break; |
|
713 |
} |
|
714 |
} |
|
715 |
||
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
716 |
function getRadioState(form, name, valArray) |
1 | 717 |
{ |
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
718 |
// Konqueror/Safari fix |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
719 |
if ( form[name] ) |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
720 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
721 |
var formitem = form[name]; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
722 |
if ( String(formitem) == '[object DOMNamedNodesCollection]' || is_Safari ) |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
723 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
724 |
var i = 0; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
725 |
var radios = new Array(); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
726 |
var radioids = new Array(); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
727 |
while(true) |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
728 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
729 |
var elem = formitem[i]; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
730 |
if ( !elem ) |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
731 |
break; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
732 |
radios.push(elem); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
733 |
if ( !elem.id ) |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
734 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
735 |
elem.id = 'autoRadioBtn_' + Math.floor(Math.random() * 1000000); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
736 |
} |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
737 |
radioids.push(elem.id); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
738 |
i++; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
739 |
} |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
740 |
var cr; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
741 |
for ( var i = 0; i < radios.length; i++ ) |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
742 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
743 |
cr = document.getElementById(radioids[i]); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
744 |
if ( cr.value == 'on' || cr.checked == true ) |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
745 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
746 |
try { |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
747 |
return ( typeof ( valArray[i] ) != 'undefined' ) ? valArray[i] : false; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
748 |
} catch(e) { |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
749 |
// alert('Didn\'t get value for index: ' + i); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
750 |
return false; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
751 |
} |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
752 |
} |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
753 |
} |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
754 |
return false; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
755 |
} |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
756 |
} |
1 | 757 |
inputs = form.getElementsByTagName('input'); |
758 |
radios = new Array(); |
|
759 |
for(var i in inputs) |
|
760 |
{ |
|
761 |
if(inputs[i]) if(inputs[i].type == 'radio') |
|
762 |
radios.push(inputs[i]); |
|
763 |
} |
|
764 |
for(var i in radios) |
|
765 |
{ |
|
766 |
if(radios[i].checked && radios[i].name == name) |
|
767 |
return radios[i].value; |
|
768 |
} |
|
769 |
return false; |
|
770 |
} |
|
771 |
||
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
772 |
function __aclSetAllRadios(val, valArray) |
1 | 773 |
{ |
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
774 |
val = String(val); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
775 |
var form = document.forms[aclManagerID + '_formobj']; |
1 | 776 |
if (!form) |
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
777 |
{ |
1 | 778 |
return false; |
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
779 |
} |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
780 |
var inputs = form.getElementsByTagName('input'); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
781 |
var radios = new Array(); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
782 |
var dbg = ''; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
783 |
for(var i = 0; i < inputs.length; i++) |
1 | 784 |
{ |
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
785 |
dbg += String(inputs[i]) + "\n"; |
1 | 786 |
if(inputs[i].type == 'radio') |
787 |
radios.push(inputs[i]); |
|
788 |
} |
|
789 |
for(var i in radios) |
|
790 |
{ |
|
791 |
if(radios[i].value == val) |
|
792 |
radios[i].checked = true; |
|
793 |
else |
|
794 |
radios[i].checked = false; |
|
795 |
} |
|
796 |
} |
|
797 |
||
798 |
function __aclDeleteRule() |
|
799 |
{ |
|
42
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
800 |
if(!aclDataCache) |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
801 |
{ |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
802 |
if ( window.console ) |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
803 |
{ |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
804 |
try{ console.error('ACL editor: can\'t load data cache on delete'); } catch(e) {}; |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
805 |
} |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
806 |
return false; |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
807 |
} |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
808 |
if(aclDataCache.mode != 'seltarget' && aclDataCache.mode != 'save_new' && aclDataCache.mode != 'save_edit') |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
809 |
{ |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
810 |
if ( window.console ) |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
811 |
{ |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
812 |
try{ console.error('ACL editor: wrong mode on aclDataCache: ' + aclDataCache.mode); } catch(e) {}; |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
813 |
} |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
814 |
return false; |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
815 |
} |
1 | 816 |
parms = { |
817 |
'target_type' : aclDataCache.target_type, |
|
818 |
'target_id' : aclDataCache.target_id, |
|
819 |
'target_name' : aclDataCache.target_name, |
|
820 |
'page_id' : aclDataCache.page_id, |
|
821 |
'namespace' : aclDataCache.namespace, |
|
822 |
'mode' : 'delete' |
|
823 |
}; |
|
824 |
__aclJSONSubmitAjaxHandler(parms); |
|
825 |
} |
|
826 |
||
827 |
function array_keys(obj) |
|
828 |
{ |
|
829 |
keys = new Array(); |
|
830 |
for(var i in obj) |
|
831 |
keys.push(i); |
|
832 |
return keys; |
|
833 |
} |
|
834 |
||
835 |
function form_fetch_field(form, name) |
|
836 |
{ |
|
837 |
var fields = form.getElementsByTagName('input'); |
|
838 |
if ( fields.length < 1 ) |
|
839 |
return false; |
|
840 |
for ( var i = 0; i < fields.length; i++ ) |
|
841 |
{ |
|
842 |
var field = fields[i]; |
|
843 |
if ( field.name == name ) |
|
844 |
return field; |
|
845 |
} |
|
846 |
return false; |
|
847 |
} |
|
848 |