author | Dan |
Sat, 24 Nov 2007 02:11:43 -0500 | |
changeset 290 | 1201c9412cb6 |
parent 184 | d74ff822acc9 |
child 218 | e878bcf0227e |
child 320 | 112debff64bd |
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'; |
|
62 |
document.getElementById(aclManagerID + '_next').value = 'Next >'; |
|
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); |
|
107 |
lbl.appendChild(document.createTextNode('A usergroup')); |
|
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'; |
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
|
113 |
anoninfo.appendChild(document.createTextNode('To edit permissions for guests, select "a specific user", and enter Anonymous as the username.')); |
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); |
|
125 |
lbl2.appendChild(document.createTextNode('A specific user')); |
|
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); |
|
170 |
lblPage.appendChild(document.createTextNode('Only this page')); |
|
171 |
lblGlobal = document.createElement('label'); |
|
172 |
lblGlobal.style.display = 'block'; |
|
173 |
lblGlobal.appendChild(scopeRadioGlobal); |
|
174 |
lblGlobal.appendChild(document.createTextNode('The entire website')); |
|
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); |
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
|
178 |
lblGroup.appendChild(document.createTextNode('A group of pages')); |
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'); |
|
184 |
scopedesc.appendChild(document.createTextNode('What should this access rule control?')); |
|
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'); |
|
222 |
head.appendChild(document.createTextNode('Manage page access')); |
|
223 |
||
224 |
desc = document.createElement('p'); |
|
225 |
desc.appendChild(document.createTextNode('Please select who should be affected by this access rule.')); |
|
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 { |
|
322 |
act_desc = ( data.type == 'new' ) ? 'Create access rule' : 'Editing permissions'; |
|
323 |
target_type_t = ( data.target_type == 1 ) ? 'group' : 'user'; |
|
324 |
target_name_t = data.target_name; |
|
74
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
73
diff
changeset
|
325 |
var scope_type = ( data.page_id == false && data.namespace == false ) ? 'this entire site' : ( data.namespace == '__PageGroup' ) ? 'this group of pages' : 'this page'; |
1 | 326 |
html = '<h2>'+act_desc+'</h2><p>This panel allows you to edit what the '+target_type_t+' "<b>'+target_name_t+'</b>" can do on <b>' + scope_type + '</b>. Unless you set a permission to "Deny", these permissions may be overridden by other rules.</p>'; |
327 |
parser = new templateParser(data.template.acl_field_begin); |
|
328 |
html += parser.run(); |
|
329 |
||
330 |
cls = 'row2'; |
|
331 |
for(var i in data.acl_types) |
|
332 |
{ |
|
333 |
if(typeof(data.acl_types[i]) == 'number') |
|
334 |
{ |
|
335 |
cls = ( cls == 'row1' ) ? 'row2' : 'row1'; |
|
336 |
p = new templateParser(data.template.acl_field_item); |
|
337 |
vars = new Object(); |
|
338 |
vars['FIELD_DESC'] = data.acl_descs[i]; |
|
339 |
vars['FIELD_DENY_CHECKED'] = ''; |
|
340 |
vars['FIELD_DISALLOW_CHECKED'] = ''; |
|
341 |
vars['FIELD_WIKIMODE_CHECKED'] = ''; |
|
342 |
vars['FIELD_ALLOW_CHECKED'] = ''; |
|
343 |
vars['FIELD_NAME'] = i; |
|
344 |
switch(data.current_perms[i]) |
|
345 |
{ |
|
346 |
case 1: |
|
347 |
vars['FIELD_DENY_CHECKED'] = 'checked="checked"'; |
|
348 |
break; |
|
349 |
case 2: |
|
350 |
default: |
|
351 |
vars['FIELD_DISALLOW_CHECKED'] = 'checked="checked"'; |
|
352 |
break; |
|
353 |
case 3: |
|
354 |
vars['FIELD_WIKIMODE_CHECKED'] = 'checked="checked"'; |
|
355 |
break; |
|
356 |
case 4: |
|
357 |
vars['FIELD_ALLOW_CHECKED'] = 'checked="checked"'; |
|
358 |
break; |
|
359 |
} |
|
360 |
vars['ROW_CLASS'] = cls; |
|
361 |
p.assign_vars(vars); |
|
362 |
html += p.run(); |
|
363 |
} |
|
364 |
} |
|
365 |
||
366 |
var parser = new templateParser(data.template.acl_field_end); |
|
367 |
html += parser.run(); |
|
368 |
||
369 |
if(data.type == 'edit') |
|
370 |
html += '<p id="'+aclManagerID+'_deletelnk" style="text-align: right;"><a href="#delete_acl_rule" onclick="if(confirm(\'Do you really want to delete this rule?\')) __aclDeleteRule(); return false;" style="color: red;">Delete this rule</a></p>'; |
|
371 |
||
372 |
var main = document.getElementById(aclManagerID + '_main'); |
|
373 |
main.innerHTML = html; |
|
374 |
||
375 |
var form = document.getElementById(aclManagerID + '_formobj_id'); |
|
376 |
||
377 |
var modeobj = form_fetch_field(form, 'mode'); |
|
378 |
if ( modeobj ) |
|
379 |
modeobj.value = 'save_' + data.type; |
|
380 |
else |
|
381 |
alert('modeobj is invalid: '+modeobj); |
|
382 |
||
383 |
aclPermList = array_keys(data.acl_types); |
|
384 |
||
385 |
document.getElementById(aclManagerID + '_back').style.display = 'inline'; |
|
386 |
document.getElementById(aclManagerID + '_next').value = 'Save Changes'; |
|
387 |
||
388 |
// } catch(e) { alert(e); aclDebug(ajax.responseText); } |
|
389 |
||
390 |
break; |
|
391 |
case 'success': |
|
392 |
var note = document.createElement('div'); |
|
393 |
note.className = 'info-box'; |
|
394 |
note.style.marginLeft = '0'; |
|
395 |
var b = document.createElement('b'); |
|
396 |
b.appendChild(document.createTextNode('Permissions updated')); |
|
397 |
note.appendChild(b); |
|
398 |
note.appendChild(document.createElement('br')); |
|
74
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
73
diff
changeset
|
399 |
note.appendChild(document.createTextNode('The permissions for '+data.target_name+' on this page have been updated successfully. If you changed permissions that affect your user account, you may not see changes until you reload the page.')); |
1 | 400 |
note.appendChild(document.createElement('br')); |
401 |
var a = document.createElement('a'); |
|
402 |
a.href = 'javascript:void(0);'; |
|
403 |
a.onclick = function() { this.parentNode.parentNode.removeChild(this.parentNode); return false; }; |
|
404 |
a.appendChild(document.createTextNode('[ dismiss :')); |
|
405 |
note.appendChild(a); |
|
406 |
var a2 = document.createElement('a'); |
|
407 |
a2.href = 'javascript:void(0);'; |
|
408 |
a2.onclick = function() { killACLManager(); return false; }; |
|
409 |
a2.appendChild(document.createTextNode(': close manager ]')); |
|
410 |
note.appendChild(a2); |
|
411 |
document.getElementById(aclManagerID + '_main').insertBefore(note, document.getElementById(aclManagerID + '_main').firstChild); |
|
412 |
if(!document.getElementById(aclManagerID+'_deletelnk')) |
|
413 |
document.getElementById(aclManagerID + '_main').innerHTML += '<p id="'+aclManagerID+'_deletelnk" style="text-align: right;"><a href="#delete_acl_rule" onclick="if(confirm(\'Do you really want to delete this rule?\')) __aclDeleteRule(); return false;" style="color: red;">Delete this rule</a></p>'; |
|
414 |
//fadeInfoBoxes(); |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
415 |
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
|
416 |
|
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
|
417 |
aclDataCache.mode = 'save_edit'; |
1 | 418 |
break; |
419 |
case 'delete': |
|
420 |
||
421 |
params = { |
|
422 |
'mode' : 'listgroups' |
|
423 |
}; |
|
424 |
params = toJSONString(params); |
|
425 |
params = ajaxEscape(params); |
|
426 |
ajaxPost(stdAjaxPrefix+'&_mode=acljson', 'acl_params='+params, function() { |
|
427 |
if(ajax.readyState == 4) |
|
428 |
{ |
|
429 |
document.getElementById(aclManagerID+'_main').innerHTML = ''; |
|
430 |
document.getElementById(aclManagerID + '_back').style.display = 'none'; |
|
431 |
document.getElementById(aclManagerID + '_next').value = 'Next >'; |
|
432 |
var thispage = strToPageID(title); |
|
433 |
groups.page_id = thispage[0]; |
|
434 |
groups.namespace = thispage[1]; |
|
435 |
__aclBuildSelector(groups); |
|
436 |
||
437 |
note = document.createElement('div'); |
|
438 |
note.className = 'info-box'; |
|
439 |
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
|
440 |
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
|
441 |
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
|
442 |
note.id = 'aclSuccessNotice_' + Math.floor(Math.random() * 100000); |
1 | 443 |
b = document.createElement('b'); |
444 |
b.appendChild(document.createTextNode('Entry deleted')); |
|
445 |
note.appendChild(b); |
|
446 |
note.appendChild(document.createElement('br')); |
|
447 |
note.appendChild(document.createTextNode('The access rules for '+aclDataCache.target_name+' on this page have been deleted.')); |
|
448 |
note.appendChild(document.createElement('br')); |
|
449 |
a = document.createElement('a'); |
|
450 |
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
|
451 |
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; }; |
1 | 452 |
a.appendChild(document.createTextNode('[ dismiss :')); |
453 |
note.appendChild(a); |
|
454 |
a = document.createElement('a'); |
|
455 |
a.href = '#'; |
|
456 |
a.onclick = function() { killACLManager(); return false; }; |
|
457 |
a.appendChild(document.createTextNode(': close manager ]')); |
|
458 |
note.appendChild(a); |
|
459 |
document.getElementById(aclManagerID + '_main').insertBefore(note, document.getElementById(aclManagerID + '_main').firstChild); |
|
460 |
//fadeInfoBoxes(); |
|
461 |
||
462 |
} |
|
463 |
}); |
|
464 |
||
465 |
break; |
|
466 |
case 'error': |
|
467 |
alert("Server side processing error:\n"+data.error); |
|
468 |
break; |
|
469 |
case 'debug': |
|
470 |
aclDebug(data.text); |
|
471 |
break; |
|
472 |
default: |
|
473 |
alert("Invalid JSON response from server\nMode: "+data.mode+"\nJSON string: "+ajax.responseText); |
|
474 |
break; |
|
475 |
} |
|
476 |
} |
|
477 |
}); |
|
478 |
} |
|
479 |
||
480 |
function __aclBuildGroupsHTML(groups) |
|
481 |
{ |
|
482 |
groups = groups.groups; |
|
483 |
select = document.createElement('select'); |
|
484 |
for(var i in groups) |
|
485 |
{ |
|
486 |
if(typeof(groups[i]['name']) == 'string' && i != 'toJSONString') |
|
487 |
{ |
|
488 |
o = document.createElement('option'); |
|
489 |
o.value = groups[i]['id']; |
|
490 |
t = document.createTextNode(groups[i]['name']); |
|
491 |
o.appendChild(t); |
|
492 |
select.appendChild(o); |
|
493 |
} |
|
494 |
} |
|
495 |
return select; |
|
496 |
} |
|
497 |
||
498 |
function __aclBuildWizardWindow() |
|
499 |
{ |
|
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
|
500 |
darken(aclDisableTransitionFX); |
1 | 501 |
box = document.createElement('div'); |
502 |
box.style.width = '640px' |
|
503 |
box.style.height = '440px'; |
|
504 |
box.style.position = 'fixed'; |
|
505 |
width = getWidth(); |
|
506 |
height = getHeight(); |
|
507 |
box.style.left = ( width / 2 - 320 ) + 'px'; |
|
508 |
box.style.top = ( height / 2 - 250 ) + 'px'; |
|
509 |
box.style.backgroundColor = 'white'; |
|
510 |
box.style.zIndex = getHighestZ() + 1; |
|
511 |
box.id = aclManagerID; |
|
512 |
box.style.opacity = '0'; |
|
513 |
box.style.filter = 'alpha(opacity=0)'; |
|
514 |
box.style.display = 'none'; |
|
515 |
||
516 |
mainwin = document.createElement('div'); |
|
517 |
mainwin.id = aclManagerID + '_main'; |
|
518 |
mainwin.style.clip = 'rect(0px,640px,440px,0px)'; |
|
519 |
mainwin.style.overflow = 'auto'; |
|
520 |
mainwin.style.width = '620px'; |
|
521 |
mainwin.style.height = '420px'; |
|
522 |
||
523 |
panel = document.createElement('div'); |
|
524 |
panel.style.width = '620px'; |
|
525 |
panel.style.padding = '10px'; |
|
526 |
panel.style.lineHeight = '40px'; |
|
527 |
panel.style.textAlign = 'right'; |
|
528 |
panel.style.position = 'fixed'; |
|
529 |
panel.style.left = ( width / 2 - 320 ) + 'px'; |
|
530 |
panel.style.top = ( height / 2 + 190 ) + 'px'; |
|
531 |
panel.style.backgroundColor = '#D0D0D0'; |
|
532 |
panel.style.opacity = '0'; |
|
533 |
panel.style.filter = 'alpha(opacity=0)'; |
|
534 |
panel.id = aclManagerID + '_panel'; |
|
535 |
||
536 |
form = document.createElement('form'); |
|
537 |
form.method = 'post'; |
|
538 |
form.action = 'javascript:void(0)'; |
|
539 |
form.onsubmit = function() { if(this.username && !submitAuthorized) return false; __aclSubmitManager(this); return false; }; |
|
540 |
form.name = aclManagerID + '_formobj'; |
|
541 |
form.id = aclManagerID + '_formobj_id'; |
|
542 |
||
543 |
back = document.createElement('input'); |
|
544 |
back.type = 'button'; |
|
545 |
back.value = '< Back'; |
|
546 |
back.style.fontWeight = 'normal'; |
|
547 |
back.onclick = function() { ajaxACLSwitchToSelector(); return false; }; |
|
548 |
back.style.display = 'none'; |
|
549 |
back.id = aclManagerID + '_back'; |
|
550 |
||
551 |
saver = document.createElement('input'); |
|
552 |
saver.type = 'submit'; |
|
553 |
saver.value = 'Next >'; |
|
554 |
saver.style.fontWeight = 'bold'; |
|
555 |
saver.id = aclManagerID + '_next'; |
|
556 |
||
557 |
closer = document.createElement('input'); |
|
558 |
closer.type = 'button'; |
|
559 |
closer.value = 'Cancel Changes'; |
|
560 |
closer.onclick = function() { if(!confirm('Do you really want to close the ACL manager?')) return false; killACLManager(); return false; } |
|
561 |
||
562 |
spacer1 = document.createTextNode(' '); |
|
563 |
spacer2 = document.createTextNode(' '); |
|
564 |
||
565 |
panel.appendChild(back); |
|
566 |
panel.appendChild(spacer1); |
|
567 |
panel.appendChild(saver); |
|
568 |
panel.appendChild(spacer2); |
|
569 |
panel.appendChild(closer); |
|
570 |
form.appendChild(mainwin); |
|
571 |
form.appendChild(panel); |
|
572 |
box.appendChild(form); |
|
573 |
||
574 |
body = document.getElementsByTagName('body')[0]; |
|
575 |
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
|
576 |
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
|
577 |
{ |
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
|
578 |
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
|
579 |
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
|
580 |
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
|
581 |
} |
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
|
582 |
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
|
583 |
{ |
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
|
584 |
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
|
585 |
} |
1 | 586 |
} |
587 |
||
588 |
function killACLManager() |
|
589 |
{ |
|
590 |
el = document.getElementById(aclManagerID); |
|
591 |
if(el) |
|
592 |
{ |
|
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
|
593 |
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
|
594 |
{ |
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 |
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
|
596 |
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
|
597 |
} |
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
|
598 |
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
|
599 |
{ |
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
|
600 |
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
|
601 |
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
|
602 |
} |
1 | 603 |
} |
604 |
} |
|
605 |
||
606 |
function __aclSubmitManager(form) |
|
607 |
{ |
|
608 |
var thefrm = document.forms[form.name]; |
|
609 |
var modeobj = form_fetch_field(thefrm, 'mode'); |
|
610 |
if ( typeof(modeobj) == 'object' ) |
|
611 |
{ |
|
612 |
var mode = (thefrm.mode.value) ? thefrm.mode.value : 'cant_get'; |
|
613 |
} |
|
614 |
else |
|
615 |
{ |
|
616 |
var mode = ''; |
|
617 |
} |
|
618 |
switch(mode) |
|
619 |
{ |
|
620 |
case 'cant_get': |
|
621 |
alert('BUG: can\'t get the state value from the form field.'); |
|
622 |
break; |
|
623 |
case 'seltarget': |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
624 |
var target_type = parseInt(getRadioState(thefrm, 'target_type', ['1', '2'])); |
1 | 625 |
if(isNaN(target_type)) |
626 |
{ |
|
627 |
alert('Please select a target type.'); |
|
628 |
return false; |
|
629 |
} |
|
630 |
target_id = ( target_type == 1 ) ? parseInt(thefrm.group_id.value) : thefrm.username.value; |
|
631 |
||
632 |
obj = { 'mode' : mode, 'target_type' : target_type, 'target_id' : target_id }; |
|
633 |
||
634 |
thispage = strToPageID(title); |
|
635 |
do_scopesel = ( thispage[0] == aclDataCache.page_id && thispage[1] == aclDataCache.namespace ); |
|
636 |
||
637 |
if(do_scopesel) |
|
638 |
{ |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
639 |
scope = getRadioState(thefrm, 'scope', ['page', 'global']); |
1 | 640 |
if(scope == 'page') |
641 |
{ |
|
642 |
pageid = strToPageID(title); |
|
643 |
obj['page_id'] = pageid[0]; |
|
644 |
obj['namespace'] = pageid[1]; |
|
645 |
} |
|
646 |
else if(scope == 'global') |
|
647 |
{ |
|
648 |
obj['page_id'] = false; |
|
649 |
obj['namespace'] = false; |
|
650 |
} |
|
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
|
651 |
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
|
652 |
{ |
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
|
653 |
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
|
654 |
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
|
655 |
} |
1 | 656 |
else |
657 |
{ |
|
658 |
alert('Invalid scope'); |
|
659 |
return false; |
|
660 |
} |
|
661 |
} |
|
662 |
else |
|
663 |
{ |
|
664 |
obj['page_id'] = aclDataCache.page_id; |
|
665 |
obj['namespace'] = aclDataCache.namespace; |
|
666 |
} |
|
667 |
if(target_id == '') |
|
668 |
{ |
|
669 |
alert('Please enter a username.'); |
|
670 |
return false; |
|
671 |
} |
|
672 |
__aclJSONSubmitAjaxHandler(obj); |
|
673 |
break; |
|
674 |
case 'save_edit': |
|
675 |
case 'save_new': |
|
676 |
var form = document.forms[aclManagerID + '_formobj']; |
|
677 |
selections = new Object(); |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
678 |
var dbg = ''; |
1 | 679 |
for(var i in aclPermList) |
680 |
{ |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
681 |
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
|
682 |
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
|
683 |
if(!selections[aclPermList[i]]) |
1 | 684 |
{ |
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
685 |
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
|
686 |
return false; |
1 | 687 |
} |
688 |
} |
|
689 |
obj = new Object(); |
|
690 |
obj['perms'] = selections; |
|
691 |
obj['mode'] = mode; |
|
692 |
obj['target_type'] = aclDataCache.target_type; |
|
693 |
obj['target_id'] = aclDataCache.target_id; |
|
694 |
obj['target_name'] = aclDataCache.target_name; |
|
695 |
obj['page_id'] = aclDataCache.page_id; |
|
696 |
obj['namespace'] = aclDataCache.namespace; |
|
697 |
__aclJSONSubmitAjaxHandler(obj); |
|
698 |
break; |
|
699 |
default: |
|
700 |
alert("JSON form submit: invalid mode string "+mode+", stopping execution"); |
|
701 |
return false; |
|
702 |
break; |
|
703 |
} |
|
704 |
} |
|
705 |
||
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
706 |
function getRadioState(form, name, valArray) |
1 | 707 |
{ |
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
708 |
// Konqueror/Safari fix |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
709 |
if ( form[name] ) |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
710 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
711 |
var formitem = form[name]; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
712 |
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
|
713 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
714 |
var i = 0; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
715 |
var radios = new Array(); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
716 |
var radioids = new Array(); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
717 |
while(true) |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
718 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
719 |
var elem = formitem[i]; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
720 |
if ( !elem ) |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
721 |
break; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
722 |
radios.push(elem); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
723 |
if ( !elem.id ) |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
724 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
725 |
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
|
726 |
} |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
727 |
radioids.push(elem.id); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
728 |
i++; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
729 |
} |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
730 |
var cr; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
731 |
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
|
732 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
733 |
cr = document.getElementById(radioids[i]); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
734 |
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
|
735 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
736 |
try { |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
737 |
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
|
738 |
} catch(e) { |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
739 |
// 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
|
740 |
return false; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
741 |
} |
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 |
} |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
744 |
return false; |
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 |
} |
1 | 747 |
inputs = form.getElementsByTagName('input'); |
748 |
radios = new Array(); |
|
749 |
for(var i in inputs) |
|
750 |
{ |
|
751 |
if(inputs[i]) if(inputs[i].type == 'radio') |
|
752 |
radios.push(inputs[i]); |
|
753 |
} |
|
754 |
for(var i in radios) |
|
755 |
{ |
|
756 |
if(radios[i].checked && radios[i].name == name) |
|
757 |
return radios[i].value; |
|
758 |
} |
|
759 |
return false; |
|
760 |
} |
|
761 |
||
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
762 |
function __aclSetAllRadios(val, valArray) |
1 | 763 |
{ |
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
764 |
val = String(val); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
765 |
var form = document.forms[aclManagerID + '_formobj']; |
1 | 766 |
if (!form) |
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
767 |
{ |
1 | 768 |
return false; |
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
769 |
} |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
770 |
var inputs = form.getElementsByTagName('input'); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
771 |
var radios = new Array(); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
772 |
var dbg = ''; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
773 |
for(var i = 0; i < inputs.length; i++) |
1 | 774 |
{ |
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
775 |
dbg += String(inputs[i]) + "\n"; |
1 | 776 |
if(inputs[i].type == 'radio') |
777 |
radios.push(inputs[i]); |
|
778 |
} |
|
779 |
for(var i in radios) |
|
780 |
{ |
|
781 |
if(radios[i].value == val) |
|
782 |
radios[i].checked = true; |
|
783 |
else |
|
784 |
radios[i].checked = false; |
|
785 |
} |
|
786 |
} |
|
787 |
||
788 |
function __aclDeleteRule() |
|
789 |
{ |
|
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
|
790 |
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
|
791 |
{ |
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
|
792 |
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
|
793 |
{ |
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
|
794 |
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
|
795 |
} |
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
|
796 |
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
|
797 |
} |
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
|
798 |
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
|
799 |
{ |
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 ( 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
|
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 |
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
|
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 |
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
|
805 |
} |
1 | 806 |
parms = { |
807 |
'target_type' : aclDataCache.target_type, |
|
808 |
'target_id' : aclDataCache.target_id, |
|
809 |
'target_name' : aclDataCache.target_name, |
|
810 |
'page_id' : aclDataCache.page_id, |
|
811 |
'namespace' : aclDataCache.namespace, |
|
812 |
'mode' : 'delete' |
|
813 |
}; |
|
814 |
__aclJSONSubmitAjaxHandler(parms); |
|
815 |
} |
|
816 |
||
817 |
function array_keys(obj) |
|
818 |
{ |
|
819 |
keys = new Array(); |
|
820 |
for(var i in obj) |
|
821 |
keys.push(i); |
|
822 |
return keys; |
|
823 |
} |
|
824 |
||
825 |
function form_fetch_field(form, name) |
|
826 |
{ |
|
827 |
var fields = form.getElementsByTagName('input'); |
|
828 |
if ( fields.length < 1 ) |
|
829 |
return false; |
|
830 |
for ( var i = 0; i < fields.length; i++ ) |
|
831 |
{ |
|
832 |
var field = fields[i]; |
|
833 |
if ( field.name == name ) |
|
834 |
return field; |
|
835 |
} |
|
836 |
return false; |
|
837 |
} |
|
838 |