plugin:superacl
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
plugin:superacl [2009-02-26 16:25] – minor fix: you're => your 200.49.224.88 | 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, access, users, groups | + | tags : acl, users, groups |
+ | downloadurl: | ||
---- | ---- | ||
Line 18: | Line 19: | ||
//If you're looking for the SuperACL plugin for pre-2008-05-05 DokuWiki, please scroll down.// | //If you're looking for the SuperACL plugin for pre-2008-05-05 DokuWiki, please scroll down.// | ||
- | This plugin is based on [[plugin: | + | This plugin is based on [[plugin: |
==== 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 29: | Line 30: | ||
//The following only corresponds to the SuperACL-version for DokuWiki releases 2006-11-06 and 2007-06-26// | //The following only corresponds to the SuperACL-version for DokuWiki releases 2006-11-06 and 2007-06-26// | ||
- | This plugin is based on [[plugin: | + | This plugin is based on [[plugin: |
Since in big wikis it takes some time to display all namespaces and all the pages of the selected namespace, the new version of SuperACL offers the configuration option to enable "Use AJAX". This will speedup all roundtrip processes (e.g. set an ACL) by deferring the population of the dropdown-selectors. | Since in big wikis it takes some time to display all namespaces and all the pages of the selected namespace, the new version of SuperACL offers the configuration option to enable "Use AJAX". This will speedup all roundtrip processes (e.g. set an ACL) by deferring the population of the dropdown-selectors. | ||
Line 43: | Line 44: | ||
**admin.php: | **admin.php: | ||
- | <code php> | + | < |
<?php | <?php | ||
/** | /** | ||
* Global ACL overview | * Global ACL overview | ||
- | | + | * |
* Borrowed a lot of code from the aclPlugin | * Borrowed a lot of code from the aclPlugin | ||
* | * | ||
Line 65: | Line 66: | ||
*/ | */ | ||
class admin_plugin_superacl extends DokuWiki_Admin_Plugin { | class admin_plugin_superacl extends DokuWiki_Admin_Plugin { | ||
- | |||
- | function admin_plugin_superacl(){ | ||
- | $this-> | ||
- | } | ||
- | |||
+ | function admin_plugin_superacl(){ | ||
+ | $this-> | ||
+ | } | ||
/** | /** | ||
Line 76: | Line 75: | ||
*/ | */ | ||
function getInfo(){ | function getInfo(){ | ||
- | | + | |
- | ' | + | ' |
- | ' | + | ' |
- | ' | + | ' |
- | ' | + | ' |
- | ' | + | ' |
- | ' | + | ' |
- | ); | + | ); |
} | } | ||
Line 104: | Line 103: | ||
*/ | */ | ||
function getMenuSort() { | function getMenuSort() { | ||
- | | + | |
} | } | ||
Line 111: | Line 110: | ||
*/ | */ | ||
function handle() { | function handle() { | ||
- | | + | |
- | | + | |
- | $scope = $_REQUEST[' | + | $scope = $_REQUEST[' |
- | $type = $_REQUEST[' | + | $type = $_REQUEST[' |
- | $user = $_REQUEST[' | + | $user = $_REQUEST[' |
- | $perm = $_REQUEST[' | + | $perm = $_REQUEST[' |
- | | + | |
- | //use the maximum | + | //use the maximum |
- | sort($perm); | + | sort($perm); |
- | $perm = array_pop($perm); | + | $perm = array_pop($perm); |
- | }else{ | + | }else{ |
- | $perm = 0; | + | $perm = 0; |
- | } | + | } |
- | | + | |
- | $user = auth_nameencode($user); | + | $user = auth_nameencode($user); |
- | if($type == ' | + | if($type == ' |
- | if($user == ' | + | if($user == ' |
- | $perm = (int) $perm; | + | $perm = (int) $perm; |
- | if($perm > AUTH_DELETE) $perm = AUTH_DELETE; | + | if($perm > AUTH_DELETE) $perm = AUTH_DELETE; |
- | //FIXME sanitize scope!!! | + | //FIXME sanitize scope!!! |
- | | + | |
- | if(empty($cmd) || empty($scope) || empty($user)) return; | + | if(empty($cmd) || empty($scope) || empty($user)) return; |
- | | + | |
- | $this-> | + | $this-> |
- | $this-> | + | $this-> |
- | }elseif($cmd == ' | + | }elseif($cmd == ' |
- | $this-> | + | $this-> |
- | } | + | } |
- | | + | |
- | $AUTH_ACL = file(DOKU_CONF.' | + | $AUTH_ACL = file(DOKU_CONF.' |
} | } | ||
Line 161: | Line 160: | ||
function html() { | function html() { | ||
- | | + | |
- | + | ||
- | ptln('< | + | |
- | ptln('< | + | |
- | //namespace selector | + | ptln('< |
- | $this->admin_superacl_select_ns(); | + | |
- | + | ||
- | //new | + | |
- | $this->admin_superacl_html_new(); | + | |
- | | + | |
- | $acls = $this-> | + | $this->admin_superacl_select_ns(); |
- | foreach ($acls as $id => $acl){ | + | |
- | $this->admin_superacl_html_current($id,$acl); | + | |
- | } | + | |
- | | + | |
- | | + | //new |
- | ptln('</ | + | $this-> |
+ | |||
+ | //current config | ||
+ | $acls = $this-> | ||
+ | foreach ($acls as $id => $acl){ | ||
+ | $this-> | ||
+ | } | ||
+ | |||
+ | |||
+ | | ||
+ | ptln('</ | ||
} | } | ||
/** | /** | ||
- | * | + | * |
* Get current selected namespace (or namespace of $ID as alternative) | * Get current selected namespace (or namespace of $ID as alternative) | ||
- | * | + | * |
*/ | */ | ||
- | function get_selected_ns() { | + | |
- | global $ID; | + | global $ID; |
- | + | ||
- | | + | $id = $_REQUEST[' |
- | + | ||
- | if (! $id) $id = getNS($ID); | + | if (! $id) $id = getNS($ID); |
- | if (! $id) $id = ' | + | if (! $id) $id = ' |
- | + | ||
- | return $id; | + | return $id; |
- | } | + | } |
/** | /** | ||
- | * | + | * |
* Get current selected acl_scope (or namespace of Selected NS as alternative) | * Get current selected acl_scope (or namespace of Selected NS as alternative) | ||
- | * | + | * |
*/ | */ | ||
- | function get_acl_scope() { | + | |
- | + | ||
- | | + | $scope |
- | + | ||
- | if (! $scope) $scope = $this-> | + | if (! $scope) $scope = $this-> |
- | if (! $scope) $scope = ' | + | if (! $scope) $scope = ' |
- | + | ||
- | return $scope; | + | return $scope; |
- | } | + | } |
/** | /** | ||
Line 225: | Line 224: | ||
*/ | */ | ||
function get_superacl_config($id){ | function get_superacl_config($id){ | ||
- | | + | |
- | | + | |
- | $acl_config=array(); | ||
- | // match exact name | + | $acl_config=array(); |
- | $pages = $this-> | + | |
- | + | ||
- | foreach ($pages as $page_id) { | + | |
- | if ($id != ' | + | |
- | $page_id = $id . ':' | + | |
- | $matches = preg_grep('/ | + | |
- | if(count($matches)){ | + | |
- | | + | |
- | $match = preg_replace('/# | + | |
- | $acl = preg_split('/ | + | |
- | //0 is pagename, 1 is user, 2 is acl | + | |
- | | + | |
- | } | + | |
- | } | + | |
- | } | + | |
- | $specific_found=array(); | + | |
- | + | $pages = $this-> | |
- | | + | |
- | for(;$id !== false; | + | foreach ($pages as $page_id) { |
- | | + | if ($id != ' |
- | $matches = preg_grep('/ | + | $matches = preg_grep('/ |
- | + | if(count($matches)){ | |
- | | + | foreach($matches as $match){ |
- | foreach($matches as $match){ | + | $match = preg_replace('/# |
- | $match = preg_replace('/# | + | $acl = preg_split('/ |
- | $acl = preg_split('/ | + | //0 is pagename, 1 is user, 2 is acl |
- | //0 is pagename, 1 is user, 2 is acl | + | $acl_config[$acl[0]][] = array( ' |
- | $acl_config[$acl[0]][] = array( ' | + | } |
- | | + | } |
- | | + | |
} | } | ||
- | } | ||
- | | + | $specific_found=array(); |
- | $matches = preg_grep('/ | + | |
- | if(count($matches)){ | + | // match ns |
- | foreach($matches as $match){ | + | for(;$id !== false; $id = getNS($id)){ |
- | $match = preg_replace('/# | + | $id_pattern = str_replace(' |
- | $acl = preg_split('/ | + | $matches = preg_grep('/ |
- | // only include * for this user if not already found in ns | + | |
- | if(!in_array($acl[1], | + | if(count($matches)){ |
- | //0 is pagename, 1 is user, 2 is acl | + | foreach($matches as $match){ |
- | $acl_config[$acl[0]][] = array( ' | + | $match = preg_replace('/# |
- | } | + | $acl = preg_split('/ |
+ | //0 is pagename, 1 is user, 2 is acl | ||
+ | $acl_config[$acl[0]][] = array( ' | ||
+ | $specific_found[]=$acl[1]; | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | | ||
+ | $matches = preg_grep('/ | ||
+ | if(count($matches)){ | ||
+ | foreach($matches as $match){ | ||
+ | $match = preg_replace('/# | ||
+ | $acl = preg_split('/ | ||
+ | // only include * for this user if not already found in ns | ||
+ | if(!in_array($acl[1], | ||
+ | //0 is pagename, 1 is user, 2 is acl | ||
+ | $acl_config[$acl[0]][] = array( ' | ||
+ | } | ||
+ | | ||
} | } | ||
- | } | ||
- | | + | |
- | //FIXME: better sort algo: first sort by key, then sort by first value | + | //FIXME: better sort algo: first sort by key, then sort by first value |
- | krsort($acl_config, | + | krsort($acl_config, |
- | | + | |
} | } | ||
Line 293: | Line 291: | ||
*/ | */ | ||
function admin_acl_add($acl_scope, | function admin_acl_add($acl_scope, | ||
- | | + | |
- | | + | |
- | if(strpos($acl_scope,' | + | if(strpos($acl_scope,' |
- | if($acl_level > AUTH_EDIT) $acl_level = AUTH_EDIT; | + | if($acl_level > AUTH_EDIT) $acl_level = AUTH_EDIT; |
- | } | + | } |
- | | + | |
- | | + | |
- | | + | |
} | } | ||
Line 313: | Line 311: | ||
*/ | */ | ||
function admin_acl_del($acl_scope, | function admin_acl_del($acl_scope, | ||
- | | + | |
- | | + | |
- | | + | |
- | $new_config = preg_grep("/ | + | $new_config = preg_grep("/ |
- | | + | |
} | } | ||
Line 335: | Line 333: | ||
*/ | */ | ||
function admin_superacl_html_dropdown($id){ | function admin_superacl_html_dropdown($id){ | ||
- | | + | |
- | $ret = ''; | + | $ret = ''; |
- | $selected_id = $this-> | + | $selected_id = $this-> |
- | $opt = array(); | + | $opt = array(); |
- | | + | |
- | $pages = array(); | + | $pages = array(); |
- | if ($this-> | + | if ($this-> |
- | $ret .= sprintf('< | + | $ret .= sprintf('< |
- | $ret .= sprintf('< | + | $ret .= sprintf('< |
- | $ret .= sprintf('< | + | $ret .= sprintf('< |
- | $ret .= sprintf('< | + | $ret .= sprintf('< |
- | + | } else { | |
- | | + | // pages in this namespace |
- | | + | $pages = array_reverse($this-> |
- | | + | } |
- | } | + | |
- | | + | |
- | foreach ($pages as $page_id) { | + | foreach ($pages as $page_id) { |
- | $page_id = ($id != ' | + | $page_id = ($id != ' |
- | $opt[] = array(' | + | $opt[] = array( |
- | | + | |
- | if ($page_id == $selected_id) | + | ' |
- | | + | |
- | } | + | if ($page_id == $selected_id) $opt[count($opt)-1][' |
- | + | } | |
- | // add selected page (if not in list above) | + | |
- | if (!($pages) && ($this-> | + | |
- | | + | |
- | ' | + | |
- | ' | + | |
- | } | + | |
- | + | ||
- | + | ||
- | // additional namespaces | + | |
- | for(; $id !== false && $id != ' | + | |
- | | + | |
- | if ($id.': | + | |
- | $opt[count($opt)-1][' | + | |
- | + | ||
- | | + | |
- | | + | |
- | $opt[] = array(' | + | if (!($pages) && ($this-> |
+ | $opt[] = array( | ||
+ | | ||
+ | | ||
+ | ' | ||
+ | | ||
+ | } | ||
- | | ||
- | | + | |
- | $opt = array_reverse($opt); | + | for(; $id !== false && $id != ' |
+ | | ||
+ | if ($id.': | ||
+ | } | ||
- | | + | |
- | $att = array( | + | $opt[] = array( |
- | 'id' => 'superacl__pageselect', | + | 'value'=> '*', |
- | 'class' => 'edit', | + | 'text'=> '* (' |
- | ' | + | ); |
- | $ret .= '<select ' | + | |
- | foreach($opt as $o){ | + | |
- | | + | |
- | } | + | |
- | $ret .= '</ | + | |
- | | + | |
+ | |||
+ | // flip options | ||
+ | $opt = array_reverse($opt); | ||
+ | |||
+ | // create HTML | ||
+ | $att = array( | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | |||
+ | $ret .= '< | ||
+ | foreach($opt as $o){ | ||
+ | $ret .= '< | ||
+ | } | ||
+ | $ret .= '</ | ||
+ | |||
+ | | ||
} | } | ||
- | | + | |
/** | /** | ||
* Decides, if a id is a page | * Decides, if a id is a page | ||
* */ | * */ | ||
function is_page($id){ | function is_page($id){ | ||
- | | + | |
} | } | ||
- | | + | |
/** | /** | ||
* creates dropdown with all namespaces | * creates dropdown with all namespaces | ||
Line 413: | Line 417: | ||
*/ | */ | ||
function admin_superacl_html_ns_dropdown($id){ | function admin_superacl_html_ns_dropdown($id){ | ||
- | | + | |
- | $ret = ''; | + | $ret = ''; |
- | $opt = array(); | + | $opt = array(); |
- | + | ||
- | + | ||
- | $namespaces = array(); | + | |
- | + | ||
- | if ($this-> | + | |
- | $ret .= sprintf('< | + | |
- | $ret .= sprintf('< | + | |
- | } else { | + | |
- | $namespaces = $this-> | + | |
- | } | + | |
- | + | ||
- | // add namespaces of current page to the list of namespaces (even if the namespaces doesn' | + | |
- | $ns_id = getNS($ID); | + | |
- | for(;$ns_id !== false; $ns_id = getNS($ns_id)){ | + | |
- | if (array_search($ns_id, | + | |
- | | + | |
- | } | + | |
- | + | ||
- | // add selected namespace, if not in list above | + | |
- | if ($id && (array_search($id, | + | |
- | | + | |
- | + | ||
- | sort($namespaces); | + | |
- | + | ||
- | $namespaces = array_reverse($namespaces); | + | |
- | foreach ($namespaces as $ns_id) { | + | |
- | if ($ns_id == " | + | |
- | + | ||
- | $opt[] = array(' | + | |
- | if ($ns_id == $id) // set sel on current selected namespcase | + | |
- | $opt[count($opt)-1][' | + | |
- | } | + | |
- | + | ||
- | $opt[] = array(' | + | |
- | // flip options | + | |
- | | + | |
- | | + | |
- | // create HTML | + | if ($this->getConf('use_ajax')) { |
- | $att = array( ' | + | $ret .= sprintf('<input type="hidden" |
- | ' | + | $ret .= sprintf('<input type="hidden" |
- | ' | + | } else { |
- | ' | + | $namespaces |
- | $ret .= '<select ' | + | } |
- | foreach($opt as $o){ | + | |
- | $ret .= '<option value="' | + | |
- | } | + | |
- | $ret .= '</ | + | |
- | | + | // 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, | ||
+ | } | ||
+ | |||
+ | // add selected namespace, if not in list above | ||
+ | if ($id && !in_array($id, | ||
+ | |||
+ | sort($namespaces); | ||
+ | |||
+ | $namespaces = array_reverse($namespaces); | ||
+ | foreach ($namespaces as $ns_id) { | ||
+ | if ($ns_id == " | ||
+ | |||
+ | $opt[] = array(' | ||
+ | if ($ns_id == $id) { // set sel on current selected namespcase | ||
+ | $opt[count($opt)-1][' | ||
+ | } | ||
+ | } | ||
+ | |||
+ | $opt[] = array(' | ||
+ | |||
+ | |||
+ | // flip options | ||
+ | $opt = array_reverse($opt); | ||
+ | |||
+ | |||
+ | // create HTML | ||
+ | $att = array( | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | |||
+ | $ret .= '< | ||
+ | foreach($opt as $o){ | ||
+ | $ret .= '< | ||
+ | } | ||
+ | $ret .= '</ | ||
+ | |||
+ | | ||
} | } | ||
- | | + | |
/** | /** | ||
- | * print form to select namespace to modify | + | * print form to select namespace to modify |
- | | + | * |
* @author Pascal Bihler < | * @author Pascal Bihler < | ||
- | | + | * |
*/ | */ | ||
| | ||
- | global $ID; | + | |
- | | + | global $lang; |
- | | + | |
- | ptln('< | + | ptln('< |
- | ptln(' | + | ptln(' |
- | ptln('</ | + | ptln('</ |
- | | + | |
- | | + | |
- | | + | |
- | ptln(' | + | ptln(' |
- | ptln(' | + | ptln(' |
- | ptln(' | + | ptln(' |
- | + | ||
- | //scope select | + | //scope select |
- | ptln($this-> | + | ptln($this-> |
- | ptln($this-> | + | ptln($this-> |
- | + | ||
- | ptln(' | + | ptln(' |
- | ptln(' | + | ptln(' |
- | ptln('</ | + | ptln('</ |
- | ptln('</ | + | ptln('</ |
- | + | ||
} | } | ||
- | + | ||
/** | /** | ||
Line 514: | Line 518: | ||
*/ | */ | ||
function admin_superacl_html_new(){ | function admin_superacl_html_new(){ | ||
- | | + | |
- | global $lang; | + | global $lang; |
- | + | ||
- | // table headers | + | |
- | ptln('< | + | |
- | ptln(' | + | |
- | ptln('</ | + | |
- | + | ||
- | ptln('< | + | |
- | + | ||
- | ptln('< | + | |
- | + | ||
- | ptln(' | + | |
- | ptln(' | + | |
- | ptln(' | + | |
- | ptln(' | + | |
- | ptln(' | + | |
+ | // table headers | ||
+ | ptln('< | ||
+ | ptln(' | ||
+ | ptln('</ | ||
+ | ptln('< | ||
+ | ptln('< | ||
+ | ptln(' | ||
+ | ptln(' | ||
+ | ptln(' | ||
+ | ptln(' | ||
+ | ptln(' | ||
- | | + | |
- | ptln($this-> | + | ptln($this-> |
- | ptln($this-> | + | ptln($this-> |
- | | + | |
- | ' | + | |
- | ' | + | ' |
- | ptln(' | + | ' |
- | ptln(' | + | |
- | ptln(' | + | ptln(' |
- | ptln(' | + | ptln(' |
+ | ptln(' | ||
+ | ptln(' | ||
- | | + | |
- | ' | + | |
- | ' | + | ' |
- | ' | + | ' |
- | ptln(' | + | ' |
- | ptln(' | + | |
- | + | ptln(' | |
- | | + | ptln(' |
- | + | ptln( | |
- | | + | ptln(' |
- | ptln(' | + | ptln(' |
- | ptln('</ | + | ptln('</ |
- | ptln('</ | + | ptln('</ |
} | } | ||
Line 571: | Line 573: | ||
*/ | */ | ||
function admin_superacl_html_current($id, | function admin_superacl_html_current($id, | ||
- | | + | |
- | global $ID; | + | global $ID; |
- | | + | |
- | $idpage | + | $ispage |
- | | + | |
- | ptln(' | + | ptln(' |
- | ptln(' | + | ptln(' |
- | ptln($this-> | + | ptln($this-> |
- | if($ispage){ | + | if($ispage){ |
- | ptln($this-> | + | ptln($this-> |
- | }else{ | + | }else{ |
- | ptln($this-> | + | ptln($this-> |
- | } | + | } |
- | ptln('< | + | ptln('< |
- | ptln(' | + | ptln(' |
- | ptln(' | + | ptln(' |
- | | + | |
- | | + | |
// | // | ||
$conf[' | $conf[' | ||
if(substr($conf[' | if(substr($conf[' | ||
- | | + | |
- | $name = substr($conf[' | + | $name = substr($conf[' |
- | $type = ' | + | $type = ' |
}else{ | }else{ | ||
- | | + | |
- | $name = $conf[' | + | $name = $conf[' |
- | $type = ''; | + | $type = ''; |
} | } | ||
Line 642: | Line 644: | ||
ptln('</ | ptln('</ | ||
- | | + | |
} | } | ||
Line 654: | Line 656: | ||
*/ | */ | ||
function admin_acl_html_checkboxes($setperm, | function admin_acl_html_checkboxes($setperm, | ||
- | | + | |
- | | + | |
- | $ret = ''; | + | $ret = ''; |
- | | + | |
- | $label += 1; | + | $label += 1; |
- | | + | |
- | $atts = array( ' | + | $atts = array( |
- | | + | |
- | | + | ' |
- | | + | ' |
- | //dynamic attributes | + | ' |
- | if($setperm >= $perm) $atts[' | + | |
- | $atts[' | + | //dynamic attributes |
- | if($ispage && $perm > AUTH_EDIT) $atts[' | + | if($setperm >= $perm) $atts[' |
+ | $atts[' | ||
+ | if($ispage && $perm > AUTH_EDIT) $atts[' | ||
- | | + | |
- | $ret .= '< | + | $ret .= '< |
- | $ret .= '< | + | $ret .= '< |
- | $ret .= $this-> | + | $ret .= $this-> |
- | $ret .= "</ | + | $ret .= "</ |
- | } | + | } |
- | return $ret; | + | return $ret; |
} | } | ||
- | | + | |
function get_pages($tns='' | function get_pages($tns='' | ||
return $this-> | return $this-> | ||
} | } | ||
- | | + | |
function get_namespaces($tns='' | function get_namespaces($tns='' | ||
return $this-> | return $this-> | ||
} | } | ||
- | // inspired from addnewpageplugin: | + | /** |
- | | + | |
- | require_once(DOKU_INC.' | + | */ |
- | global $conf; | + | |
- | + | require_once(DOKU_INC.' | |
+ | global $conf; | ||
if ($tns == ' | if ($tns == ' | ||
- | + | ||
- | if (!is_dir($tns)) | + | if (!is_dir($tns)) $tns = str_replace(':','/', |
- | $tns = str_replace(':','/', | + | |
- | + | $data = array(); | |
- | $data = array(); | + | |
- | + | ||
- | + | search($data, | |
- | search($data, | + | |
- | + | $data2 = array(); | |
- | $data2 = array(); | + | foreach($data as $k => $v) { |
- | foreach($data as $k => $v) { | + | if ($v[' |
- | if ($v[' | + | if ($namespaces) array_push($data2, |
- | | + | |
- | | + | |
- | if ($recursive) { | + | $r=$this-> |
- | $r=$this-> | + | foreach ($r as $vv) { |
- | foreach ($r as $vv) { | + | array_push($data2, |
- | array_push($data2, | + | } |
- | } | + | } |
- | } | + | } elseif ($v[' |
- | } elseif ($v[' | + | if ($pages) array_push($data2, |
- | | + | } |
- | | + | } |
- | } | + | return $data2; |
- | } | + | } |
- | return $data2; | + | |
- | } | + | |
} | } | ||
Line 727: | Line 731: | ||
**ajax.php: | **ajax.php: | ||
- | <code php> | + | FIXME move this to action.php where it can hook the [[devel: |
+ | |||
+ | < | ||
<?php | <?php | ||
/** | /** | ||
Line 737: | 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 748: | 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' | + | |
- | $ns_id = getNS($ID); | + | |
- | for(;$ns_id !== false; $ns_id = getNS($ns_id)){ | + | |
- | if (array_search($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); | ||
- | // flip options | + | |
- | $opt = array_reverse($opt); | + | $json = new JSON(); |
- | + | ||
- | + | // | |
- | /* now construct a json */ | + | header(' |
- | | + | print $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 892: | Line 890: | ||
**script.js: | **script.js: | ||
- | <code javascript> | + | <code javascript |
function superacl_autoselect_permissions(caller) { | function superacl_autoselect_permissions(caller) { | ||
callerLabel = parseInt(caller.id.substring(4)); | callerLabel = parseInt(caller.id.substring(4)); | ||
Line 904: | 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 923: | 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 935: | 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 957: | 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 967: | 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 996: | Line 979: | ||
==== Patches ==== | ==== Patches ==== | ||
+ | |||
+ | === Incompatible with " | ||
+ | https:// | ||
Line 1016: | 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.1235661929.txt.gz · Last modified: 2009-09-10 22:43 (external edit)