1071 ajaxOpenDirectACLRule(parseInt(this.rule_id)); |
1096 ajaxOpenDirectACLRule(parseInt(this.rule_id)); |
1072 } |
1097 } |
1073 div.innerHTML = rule.score_string; |
1098 div.innerHTML = rule.score_string; |
1074 main.appendChild(div); |
1099 main.appendChild(div); |
1075 } |
1100 } |
|
1101 } |
|
1102 |
|
1103 function aclSetViewDebugTools() |
|
1104 { |
|
1105 // selection window for viewing effective permissions |
|
1106 var main = document.getElementById(aclManagerID + '_main'); |
|
1107 main.innerHTML = ''; |
|
1108 |
|
1109 // set the submission handler to trace |
|
1110 var thefrm = document.forms[form.name]; |
|
1111 var modeobj = form_fetch_field(thefrm, 'mode'); |
|
1112 modeobj.value = 'trace'; |
|
1113 |
|
1114 // show the back button |
|
1115 document.getElementById(aclManagerID + '_back').style.display = 'inline'; |
|
1116 |
|
1117 // |
|
1118 // start building |
|
1119 // |
|
1120 |
|
1121 // selection interface |
|
1122 var selector = document.createElement('div'); |
|
1123 |
|
1124 var table = document.createElement('table'); |
|
1125 |
|
1126 // username |
|
1127 var tr_user = document.createElement('tr'); |
|
1128 var td_user_l = document.createElement('td'); |
|
1129 var lbl_user = document.createElement('label'); |
|
1130 lbl_user.setAttribute('for', aclManagerID + 'trace_user'); |
|
1131 lbl_user.appendChild(document.createTextNode($lang.get('acl_lbl_trace_user'))); |
|
1132 td_user_l.appendChild(lbl_user); |
|
1133 tr_user.appendChild(td_user_l); |
|
1134 |
|
1135 var td_user_i = document.createElement('td'); |
|
1136 var i_user = document.createElement('input'); |
|
1137 i_user.type = 'text'; |
|
1138 i_user.id = aclManagerID + 'trace_user'; |
|
1139 i_user.onkeyup = function() { new AutofillUsername(this); }; |
|
1140 i_user.size = '20'; |
|
1141 td_user_i.appendChild(i_user); |
|
1142 tr_user.appendChild(td_user_i); |
|
1143 |
|
1144 table.appendChild(tr_user); |
|
1145 |
|
1146 // page |
|
1147 var tr_page = document.createElement('tr'); |
|
1148 var td_page_l = document.createElement('td'); |
|
1149 var lbl_page = document.createElement('label'); |
|
1150 lbl_page.setAttribute('for', aclManagerID + 'trace_page'); |
|
1151 lbl_page.appendChild(document.createTextNode($lang.get('acl_lbl_trace_page'))); |
|
1152 td_page_l.appendChild(lbl_page); |
|
1153 tr_page.appendChild(td_page_l); |
|
1154 |
|
1155 var td_page_i = document.createElement('td'); |
|
1156 var i_page = document.createElement('input'); |
|
1157 i_page.type = 'text'; |
|
1158 i_page.id = aclManagerID + 'trace_page'; |
|
1159 i_page.onkeyup = function() { new AutofillPage(this); }; |
|
1160 i_page.size = '20'; |
|
1161 td_page_i.appendChild(i_page); |
|
1162 tr_page.appendChild(td_page_i); |
|
1163 |
|
1164 table.appendChild(tr_page); |
|
1165 |
|
1166 selector.appendChild(table); |
|
1167 |
|
1168 // wrapper |
|
1169 |
|
1170 var container = document.createElement('div'); |
|
1171 |
|
1172 container.style.margin = 'auto'; |
|
1173 container.style.width = '360px'; |
|
1174 container.style.paddingTop = '90px'; |
|
1175 |
|
1176 var head = document.createElement('h2'); |
|
1177 head.appendChild(document.createTextNode($lang.get('acl_lbl_trace_title'))); |
|
1178 |
|
1179 var desc = document.createElement('p'); |
|
1180 desc.innerHTML = $lang.get('acl_lbl_trace_body'); |
|
1181 |
|
1182 container.appendChild(head); |
|
1183 container.appendChild(desc); |
|
1184 container.appendChild(selector); |
|
1185 |
|
1186 main.appendChild(container); |
|
1187 } |
|
1188 |
|
1189 function aclTraceKey() |
|
1190 { |
|
1191 var div = document.createElement('div'); |
|
1192 $(div).addClass('tblholder'); |
|
1193 var table = document.createElement('table'); |
|
1194 $(table).attr('cellspacing', '1').attr('cellpadding', '4'); |
|
1195 |
|
1196 var inherit_list = ['enano_default', 'global_everyone', 'global_group', 'global_user', 'pg_everyone', 'pg_group', 'pg_user', 'local_everyone', 'local_group', 'local_user']; |
|
1197 for ( var i = 0; i < inherit_list.length; i++ ) |
|
1198 { |
|
1199 var t = inherit_list[i]; |
|
1200 var tr = document.createElement('tr'); |
|
1201 var td_key = document.createElement('td'); |
|
1202 $(td_key).addClass('acl_' + t).addClass('acl_inherit_key'); |
|
1203 tr.appendChild(td_key); |
|
1204 var td_explain = document.createElement('td'); |
|
1205 $(td_explain).addClass(i % 2 == 0 ? 'row1' : 'row2'); |
|
1206 td_explain.appendChild(document.createTextNode($lang.get('acl_inherit_key_' + t))); |
|
1207 tr.appendChild(td_explain); |
|
1208 table.appendChild(tr); |
|
1209 } |
|
1210 div.appendChild(table); |
|
1211 return div; |
|
1212 } |
|
1213 |
|
1214 function aclTraceModalKey() |
|
1215 { |
|
1216 load_component('messagebox'); |
|
1217 miniPrompt(function(parent) |
|
1218 { |
|
1219 // heading |
|
1220 var h3 = document.createElement('h3'); |
|
1221 h3.appendChild(document.createTextNode($lang.get('acl_msg_trace_key'))); |
|
1222 parent.appendChild(h3); |
|
1223 |
|
1224 var key = aclTraceKey(); |
|
1225 parent.appendChild(key); |
|
1226 |
|
1227 var p = document.createElement('p'); |
|
1228 $(p).css('text-align', 'center'); |
|
1229 |
|
1230 var closer = document.createElement('a'); |
|
1231 $(closer).addClass('abutton').addClass('abutton_red').css('font-weight', 'bold'); |
|
1232 closer.appendChild(document.createTextNode($lang.get('etc_close'))); |
|
1233 closer.href = '#'; |
|
1234 $(closer).click(function(e) |
|
1235 { |
|
1236 miniPromptDestroy(this); |
|
1237 return false; |
|
1238 }); |
|
1239 |
|
1240 p.appendChild(closer); |
|
1241 parent.appendChild(p); |
|
1242 }); |
|
1243 } |
|
1244 |
|
1245 function aclDrawTraceWrapper(data) |
|
1246 { |
|
1247 var trace_by_perm = aclDrawTraceByPerm(data); |
|
1248 var trace_by_rule = aclDrawTraceByRule(data); |
|
1249 |
|
1250 trace_by_perm.id = 'aclDebugTraceViewPerm'; |
|
1251 trace_by_rule.id = 'aclDebugTraceViewRule'; |
|
1252 |
|
1253 var start_with_rule = ( readCookie('acl_trace_view') == 'rule' ); |
|
1254 |
|
1255 if ( start_with_rule ) |
|
1256 { |
|
1257 trace_by_perm.style.display = 'none'; |
|
1258 } |
|
1259 else |
|
1260 { |
|
1261 trace_by_rule.style.display = 'none'; |
|
1262 } |
|
1263 |
|
1264 // selection window for viewing effective permissions |
|
1265 var main = document.getElementById(aclManagerID + '_main'); |
|
1266 main.innerHTML = ''; |
|
1267 |
|
1268 var wrapper = document.createElement('div'); |
|
1269 $(wrapper).css('padding-bottom', '20px'); |
|
1270 |
|
1271 var floatlink = document.createElement('div'); |
|
1272 $(floatlink).css('float', 'right').css('margin-left', '20px').css('margin-bottom', '20px').css('text-align', 'right'); |
|
1273 var a_toggle = document.createElement('a'); |
|
1274 $(a_toggle).attr('id', 'aclDebugTraceViewToggle'); |
|
1275 a_toggle.innerHTML = '» '; |
|
1276 a_toggle.innerHTML += start_with_rule ? $lang.get('acl_btn_sort_perm') : $lang.get('acl_btn_sort_rule'); |
|
1277 a_toggle.href = '#'; |
|
1278 floatlink.appendChild(a_toggle); |
|
1279 floatlink.appendChild(document.createElement('br')); |
|
1280 var a_key = document.createElement('a'); |
|
1281 $(a_key).css('font-size', 'smaller'); |
|
1282 a_key.innerHTML = '» '; |
|
1283 a_key.innerHTML += $lang.get('acl_btn_view_key'); |
|
1284 a_key.href = '#'; |
|
1285 floatlink.appendChild(a_key); |
|
1286 wrapper.appendChild(floatlink); |
|
1287 |
|
1288 var h3 = document.createElement('h3'); |
|
1289 h3.appendChild(document.createTextNode($lang.get('acl_msg_debug_main_title'))); |
|
1290 wrapper.appendChild(h3); |
|
1291 var p = document.createElement('p'); |
|
1292 p.appendChild(document.createTextNode($lang.get('acl_msg_debug_main_body'))); |
|
1293 wrapper.appendChild(p); |
|
1294 |
|
1295 wrapper.appendChild(trace_by_perm); |
|
1296 wrapper.appendChild(trace_by_rule); |
|
1297 |
|
1298 main.appendChild(wrapper); |
|
1299 |
|
1300 $(a_toggle).click(function(e) |
|
1301 { |
|
1302 aclTraceToggleViews(); |
|
1303 return false; |
|
1304 }); |
|
1305 |
|
1306 $(a_key).click(function(e) |
|
1307 { |
|
1308 aclTraceModalKey(); |
|
1309 return false; |
|
1310 }); |
|
1311 } |
|
1312 |
|
1313 function aclTraceToggleViews() |
|
1314 { |
|
1315 var trace_by_perm = document.getElementById('aclDebugTraceViewPerm'); |
|
1316 var trace_by_rule = document.getElementById('aclDebugTraceViewRule'); |
|
1317 |
|
1318 var toggler = document.getElementById('aclDebugTraceViewToggle'); |
|
1319 var newtext; |
|
1320 |
|
1321 if ( trace_by_perm.style.display == 'none' ) |
|
1322 { |
|
1323 newtext = $lang.get('acl_btn_sort_rule'); |
|
1324 $(trace_by_rule).hide('blind', {}, 750, function() |
|
1325 { |
|
1326 $(trace_by_perm).show('blind', {}, 750); |
|
1327 }); |
|
1328 createCookie('acl_trace_view', 'perm'); |
|
1329 } |
|
1330 else |
|
1331 { |
|
1332 newtext = $lang.get('acl_btn_sort_perm'); |
|
1333 $(trace_by_perm).hide('blind', {}, 750, function() |
|
1334 { |
|
1335 $(trace_by_rule).show('blind', {}, 750); |
|
1336 }); |
|
1337 createCookie('acl_trace_view', 'rule'); |
|
1338 } |
|
1339 $(toggler).fadeOut(500, function() |
|
1340 { |
|
1341 this.innerHTML = '» ' + newtext; |
|
1342 $(this).fadeIn(500); |
|
1343 }); |
|
1344 } |
|
1345 |
|
1346 function aclDrawTraceByPerm(data) |
|
1347 { |
|
1348 var wrapper = document.createElement('div'); |
|
1349 // wrapper.style.display = 'none'; |
|
1350 |
|
1351 // temporarily append wrapper to body to allow onclick to work |
|
1352 // var body = document.getElementsByTagName('body')[0]; |
|
1353 // body.appendChild(wrapper); |
|
1354 |
|
1355 for ( var i in data.perms ) |
|
1356 { |
|
1357 var perm = data.perms[i]; |
|
1358 var item = document.createElement('div'); |
|
1359 item.className = perm.divclass; |
|
1360 |
|
1361 // first row - permission name + current setting |
|
1362 // use innerHTML here to allow for HTML in localized permission types |
|
1363 item.innerHTML += '<b>' + perm.perm_name + ' - ' + perm.perm_value + '</b>'; |
|
1364 item.appendChild(document.createElement('br')); |
|
1365 |
|
1366 // second row - permission localized name + rule ID |
|
1367 var sm = document.createElement('small'); |
|
1368 sm.innerHTML = perm.perm_src; |
|
1369 |
|
1370 item.appendChild(sm); |
|
1371 |
|
1372 wrapper.appendChild(item); |
|
1373 |
|
1374 // whole row is now in the document |
|
1375 if ( perm.rule_id != -1 ) |
|
1376 { |
|
1377 sm.innerHTML += ' ['; |
|
1378 // rule is editable |
|
1379 var editlink = document.createElement('a'); |
|
1380 editlink.href = 'javascript:ajaxOpenDirectACLRule(' + perm.rule_id + ');'; |
|
1381 editlink.appendChild(document.createTextNode($lang.get('acl_btn_edit_rule'))); |
|
1382 sm.appendChild(editlink); |
|
1383 sm.innerHTML += ']'; |
|
1384 } |
|
1385 } |
|
1386 |
|
1387 // var ret = wrapper.cloneNode(true); |
|
1388 // body.removeChild(wrapper); |
|
1389 // wrapper = false; |
|
1390 // ret.style.display = 'block'; |
|
1391 // console.debug(ret); |
|
1392 // return ret; |
|
1393 return wrapper; |
|
1394 } |
|
1395 |
|
1396 function aclDrawTraceByRule(data) |
|
1397 { |
|
1398 var wrapper = document.createElement('div'); |
|
1399 var groupdata = {}; |
|
1400 |
|
1401 for ( var i in data.perms ) |
|
1402 { |
|
1403 var perm = data.perms[i]; |
|
1404 if ( !groupdata[perm['rule_id']] ) |
|
1405 { |
|
1406 groupdata[perm['rule_id']] = { |
|
1407 meta: { |
|
1408 divclass: perm.divclass, |
|
1409 perm_src: perm.perm_src, |
|
1410 rule_id: perm.rule_id |
|
1411 }, |
|
1412 rules: {} |
|
1413 }; |
|
1414 } |
|
1415 groupdata[perm['rule_id']]['rules'][i] = perm; |
|
1416 } |
|
1417 |
|
1418 console.debug('draw by rule - group data: ', groupdata); |
|
1419 |
|
1420 for ( var i in groupdata ) |
|
1421 { |
|
1422 var group = groupdata[i]; |
|
1423 var grp = document.createElement('div'); |
|
1424 var head = document.createElement('div'); |
|
1425 head.className = group.meta.divclass; |
|
1426 var span = document.createElement('span'); |
|
1427 span.style.fontSize = 'larger'; |
|
1428 span.appendChild(document.createTextNode(group.meta.perm_src)); |
|
1429 head.appendChild(span); |
|
1430 if ( group.meta.rule_id != -1 ) |
|
1431 { |
|
1432 head.innerHTML += ' ['; |
|
1433 // rule is editable |
|
1434 var editlink = document.createElement('a'); |
|
1435 editlink.href = 'javascript:ajaxOpenDirectACLRule(' + group.meta.rule_id + ');'; |
|
1436 editlink.appendChild(document.createTextNode($lang.get('acl_btn_edit_rule'))); |
|
1437 head.appendChild(editlink); |
|
1438 head.innerHTML += ']'; |
|
1439 } |
|
1440 grp.appendChild(head); |
|
1441 for ( var i in group.rules ) |
|
1442 { |
|
1443 var rule = group.rules[i]; |
|
1444 var rulediv = document.createElement('div'); |
|
1445 rulediv.style.padding = '3px 12px'; |
|
1446 rulediv.innerHTML += rule.perm_name + ': '; |
|
1447 var b = document.createElement('strong'); |
|
1448 b.appendChild(document.createTextNode(rule.perm_value)); |
|
1449 rulediv.appendChild(b); |
|
1450 grp.appendChild(rulediv); |
|
1451 } |
|
1452 wrapper.appendChild(grp); |
|
1453 } |
|
1454 |
|
1455 return wrapper; |
1076 } |
1456 } |
1077 |
1457 |
1078 function aclShowPresetLoader() |
1458 function aclShowPresetLoader() |
1079 { |
1459 { |
1080 var prompt = miniPrompt(function(parent) |
1460 var prompt = miniPrompt(function(parent) |