plugin:superacl
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
plugin:superacl [2011-02-10 12:00] – [Code] fixed a typo and tampered the code formatting 94.69.81.2 | plugin:superacl [2014-03-20 18:23] (current) – Aleksandr | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
---- plugin ---- | ---- plugin ---- | ||
Line 7: | Line 7: | ||
type : admin | type : admin | ||
lastupdate : 2008-05-25 | lastupdate : 2008-05-25 | ||
- | compatible : 2006-11-06, 2007-06-26, 2008-05-05 | + | compatible : 2010-11-07, |
depends | depends | ||
conflicts | conflicts | ||
similar | similar | ||
tags : acl, users, groups | tags : acl, users, groups | ||
- | downloadurl: | + | downloadurl: |
---- | ---- | ||
Line 24: | Line 24: | ||
==== Download / Installation ==== | ==== Download / Installation ==== | ||
- | Download the plugin here (manually or via Plugin Manager): http:// | + | Download the plugin here (manually or via Plugin Manager): http:// |
===== Former edition ===== | ===== Former edition ===== | ||
Line 730: | Line 730: | ||
**ajax.php: | **ajax.php: | ||
+ | |||
+ | FIXME move this to action.php where it can hook the [[devel: | ||
<code php ajax.php> | <code php ajax.php> | ||
Line 741: | Line 743: | ||
//fix for Opera XMLHttpRequests | //fix for Opera XMLHttpRequests | ||
if(!count($_POST) && $HTTP_RAW_POST_DATA){ | if(!count($_POST) && $HTTP_RAW_POST_DATA){ | ||
- | | + | |
} | } | ||
+ | |||
if(!defined(' | if(!defined(' | ||
require_once(DOKU_INC.' | require_once(DOKU_INC.' | ||
Line 752: | Line 754: | ||
//close session | //close session | ||
session_write_close(); | session_write_close(); | ||
+ | |||
// check, if user is admin (or at least manager) | // check, if user is admin (or at least manager) | ||
if (! auth_ismanager()) { | if (! auth_ismanager()) { | ||
- | exit; | + | |
} | } | ||
+ | |||
if ($_POST[" | if ($_POST[" | ||
- | get_namespace_list(); | + | |
} elseif ($_POST[" | } elseif ($_POST[" | ||
- | get_pages_list(); | + | |
} | } | ||
+ | |||
function get_namespace_list() { | function get_namespace_list() { | ||
- | | ||
- | $ID = $_POST[" | ||
- | $selid = $_POST[" | ||
- | $opt = array(); | + | $ID = $_POST[" |
- | + | $selid = $_POST["selid"]; | |
- | // all namespace | + | |
- | | + | |
- | + | ||
- | // add namespaces of current page to the list of namespaces (even if the namespaces doesn' | + | |
- | for($ns_id = getNS($ID); $ns_id !== false; $ns_id = getNS($ns_id)){ | + | |
- | if (!in_array($ns_id, | + | |
- | $namespaces[] = $ns_id; | + | |
- | } | + | |
- | sort($namespaces); | + | |
- | + | ||
- | $namespaces | + | |
- | foreach ($namespaces as $ns_id) { | + | |
- | $opt[] = array(' | + | |
- | if ($ns_id == $selid) // set sel on current selected namespcase | + | |
- | $opt[count($opt)-1][' | + | |
- | } | + | |
- | + | ||
- | $opt[] = array(' | + | |
+ | $opt = array(); | ||
- | | + | |
- | $opt = array_reverse($opt); | + | $namespaces |
+ | // add namespaces of current page to the list of namespaces (even if the namespaces doesn' | ||
+ | for($ns_id = getNS($ID); $ns_id !== false; $ns_id = getNS($ns_id)){ | ||
+ | if (!in_array($ns_id, | ||
+ | } | ||
+ | sort($namespaces); | ||
- | /* now construct a json */ | + | $namespaces = array_reverse($namespaces); |
- | $json = new JSON(); | + | foreach ($namespaces as $ns_id) { |
+ | $opt[] = array(' | ||
+ | if ($ns_id == $selid) { // set sel on current selected namespcase | ||
+ | $opt[count($opt)-1][' | ||
+ | } | ||
+ | } | ||
- | + | $opt[] = array('value'=> ' | |
- | //header('Content-Type: | + | |
- | header('Content-Type: | + | |
- | print $json->encode($opt); | + | |
- | } | + | |
+ | // flip options | ||
+ | $opt = array_reverse($opt); | ||
+ | |||
+ | |||
+ | /* now construct a json */ | ||
+ | $json = new JSON(); | ||
+ | |||
+ | |||
+ | // | ||
+ | header(' | ||
+ | print $json-> | ||
+ | } | ||
+ | |||
+ | |||
function get_pages_list() { | function get_pages_list() { | ||
- | $id = $_POST[" | + | |
- | $selected_id = $_POST[" | + | $selected_id = $_POST[" |
- | + | ||
$opt = array(); | $opt = array(); | ||
- | |||
- | $pages = array_reverse(get_pages($id)); | ||
- | | + | $pages = array_reverse(get_pages($id)); |
- | foreach ($pages as $page_id) { | + | |
- | $page_id = ($id != ' | + | |
- | $opt[] = array(' | + | foreach ($pages as $page_id) { |
- | | + | $page_id = ($id != ' |
- | if ($page_id == $selected_id) | + | $opt[] = array( |
- | | + | |
- | } | + | ' |
- | + | | |
- | // additional namespaces | + | if ($page_id == $selected_id) $opt[count($opt)-1][' |
- | for(; $id !== false && $id != ' | + | } |
+ | |||
+ | // additional namespaces | ||
+ | for(; $id !== false && $id != ' | ||
$opt[] = array(' | $opt[] = array(' | ||
- | if ($id.': | + | if ($id.': |
- | | + | } |
- | + | ||
- | | + | |
- | | + | |
- | $opt[] = array(' | + | $opt[] = array(' |
- | | + | // flip options |
+ | $opt = array_reverse($opt); | ||
+ | |||
+ | /* now construct a json */ | ||
+ | $json = new JSON(); | ||
- | // flip options | + | |
- | $opt = array_reverse($opt); | + | header(' |
- | + | print $json-> | |
- | + | ||
- | /* now construct a json */ | + | |
- | $json = new JSON(); | + | |
- | + | ||
- | + | ||
- | | + | |
- | | + | |
- | | + | |
} | } | ||
- | | + | function get_pages($tns='' |
- | return _getlist($tns, | + | return _getlist($tns, |
- | } | + | } |
- | + | ||
- | + | ||
- | | + | |
- | return _getlist($tns, | + | |
- | } | + | |
- | // inspired from addnewpageplugin: | + | |
- | | + | |
- | require_once(DOKU_INC.' | + | |
- | global $conf; | + | |
- | + | ||
- | if ($tns == ' | + | |
- | if (!is_dir($tns)) | + | |
- | $tns = str_replace(':','/', | + | function get_namespaces($tns='' |
- | + | return _getlist($tns, | |
- | $data = array(); | + | } |
- | + | ||
- | + | // inspired from addnewpageplugin: | |
- | search($data, | + | function _getlist ($tns='', |
- | + | require_once(DOKU_INC.' | |
- | $data2 = array(); | + | global $conf; |
- | foreach($data as $k => $v) { | + | |
- | if ($v[' | + | if ($tns == ' |
- | | + | |
- | | + | |
- | if ($recursive) { | + | |
- | $r=_getlist($tns.'/' | + | $data = array(); |
- | foreach ($r as $vv) { | + | |
- | array_push($data2, | + | search($data, |
- | } | + | |
- | } | + | $data2 = array(); |
- | } elseif ($v[' | + | foreach($data as $k => $v) { |
- | | + | if ($v[' |
- | | + | if ($namespaces) array_push($data2, |
- | } | + | |
- | } | + | |
- | return $data2; | + | $r=_getlist($tns.'/' |
- | } | + | foreach ($r as $vv) { |
+ | array_push($data2, | ||
+ | } | ||
+ | } | ||
+ | } elseif ($v[' | ||
+ | if ($pages) array_push($data2, | ||
+ | } | ||
+ | } | ||
+ | return $data2; | ||
+ | } | ||
?> | ?> | ||
</ | </ | ||
Line 907: | Line 902: | ||
if (!id || id.length< | if (!id || id.length< | ||
label = parseInt(id.substring(4)); | label = parseInt(id.substring(4)); | ||
- | | + | //check lower rights, too |
- | | + | |
- | else if (! caller.checked && label > callerLabel) | + | //uncheck upper rights too |
- | | + | else if (! caller.checked && label > callerLabel) e.checked = false; |
} | } | ||
} | } | ||
Line 926: | Line 921: | ||
// fill namespace selector | // fill namespace selector | ||
if ($(' | if ($(' | ||
- | |||
var ajax_superaclns = new ajax_superacl_class(); | var ajax_superaclns = new ajax_superacl_class(); | ||
- | |||
ajax_superaclns.sack = new sack(DOKU_BASE + ' | ajax_superaclns.sack = new sack(DOKU_BASE + ' | ||
ajax_superaclns.sack.AjaxFailedAlert = ''; | ajax_superaclns.sack.AjaxFailedAlert = ''; | ||
ajax_superaclns.sack.encodeURIString = false; | ajax_superaclns.sack.encodeURIString = false; | ||
- | |||
ajax_superaclns.exec = function() { | ajax_superaclns.exec = function() { | ||
pageid = $(" | pageid = $(" | ||
Line 938: | Line 930: | ||
ajax_superaclns.sack.runAJAX(' | ajax_superaclns.sack.runAJAX(' | ||
}; | }; | ||
- | |||
ajax_superaclns.sack.onCompletion = function() { | ajax_superaclns.sack.onCompletion = function() { | ||
var data = eval(ajax_superaclns.sack.response); | var data = eval(ajax_superaclns.sack.response); | ||
- | if(data === '' | + | if(data === '' |
- | return; | + | |
- | } | + | |
- | + | ||
- | | + | |
// add namespaces to select box | // add namespaces to select box | ||
select = $(' | select = $(' | ||
for(i = 0; i < data.length; | for(i = 0; i < data.length; | ||
- | | + | option = new Option(data[i].text, |
- | | + | select.options[i] = option; |
} | } | ||
}; | }; | ||
- | |||
ajax_superaclns.exec(); | ajax_superaclns.exec(); | ||
} | } | ||
Line 960: | Line 946: | ||
if ($(' | if ($(' | ||
var ajax_superaclpage = new ajax_superacl_class(); | var ajax_superaclpage = new ajax_superacl_class(); | ||
- | |||
ajax_superaclpage.sack = new sack(DOKU_BASE + ' | ajax_superaclpage.sack = new sack(DOKU_BASE + ' | ||
ajax_superaclpage.sack.AjaxFailedAlert = ''; | ajax_superaclpage.sack.AjaxFailedAlert = ''; | ||
ajax_superaclpage.sack.encodeURIString = false; | ajax_superaclpage.sack.encodeURIString = false; | ||
- | |||
ajax_superaclpage.exec = function() { | ajax_superaclpage.exec = function() { | ||
acl_id = $(" | acl_id = $(" | ||
Line 970: | Line 954: | ||
page_text = $(" | page_text = $(" | ||
ns_text = $(" | ns_text = $(" | ||
- | ajax_superaclpage.sack.runAJAX(' | + | ajax_superaclpage.sack.runAJAX( |
- | '& | + | ' |
- | '& | + | '& |
- | '& | + | '& |
+ | '& | ||
+ | ); | ||
}; | }; | ||
- | |||
ajax_superaclpage.sack.onCompletion = function() { | ajax_superaclpage.sack.onCompletion = function() { | ||
var data = eval(ajax_superaclpage.sack.response); | var data = eval(ajax_superaclpage.sack.response); | ||
- | if(data === '' | + | if(data === '' |
- | return; | + | |
- | } | + | |
- | + | ||
- | | + | |
// add namespaces to select box | // add namespaces to select box | ||
select = $(' | select = $(' | ||
for(i = 0; i < data.length; | for(i = 0; i < data.length; | ||
- | | + | option = new Option(data[i].text, |
- | | + | select.options[i] = option; |
} | } | ||
}; | }; | ||
- | |||
ajax_superaclpage.exec(); | ajax_superaclpage.exec(); | ||
} | } | ||
Line 999: | Line 979: | ||
==== Patches ==== | ==== Patches ==== | ||
+ | |||
+ | === Incompatible with " | ||
+ | https:// | ||
Line 1019: | Line 1002: | ||
< | < | ||
+ | > Ok, fixed | ||
+ | |||
+ | |||
+ | === Overriding the ACL Admin Task === | ||
+ | Would it be possible to override the ACL task item in the first section of the Administration screen (the list with the big icons) ? --- [[user> |
plugin/superacl.1297335628.txt.gz · Last modified: 2011-02-10 12:00 by 94.69.81.2