plugin:superacl
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
plugin:superacl [2010-10-12 00:58] – [Current edition] grammar: loose --> lose 96.49.203.55 | plugin:superacl [2013-10-24 17:56] – qianhd | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | test!!! can i edit this page with out check by admin?? | ||
+ | |||
====== DokuWiki Plugin: superacl ====== | ====== DokuWiki Plugin: superacl ====== | ||
Line 7: | Line 9: | ||
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 | ||
Line 24: | Line 26: | ||
==== 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 48: | Line 50: | ||
/** | /** | ||
* Global ACL overview | * Global ACL overview | ||
- | | + | * |
* Borrowed a lot of code from the aclPlugin | * Borrowed a lot of code from the aclPlugin | ||
* | * | ||
Line 66: | Line 68: | ||
*/ | */ | ||
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 77: | Line 77: | ||
*/ | */ | ||
function getInfo(){ | function getInfo(){ | ||
- | | + | |
- | ' | + | ' |
- | ' | + | ' |
- | ' | + | ' |
- | ' | + | ' |
- | ' | + | ' |
- | ' | + | ' |
- | ); | + | ); |
} | } | ||
Line 105: | Line 105: | ||
*/ | */ | ||
function getMenuSort() { | function getMenuSort() { | ||
- | | + | |
} | } | ||
Line 112: | Line 112: | ||
*/ | */ | ||
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 162: | Line 162: | ||
function html() { | function html() { | ||
- | | + | |
- | + | ||
- | ptln('< | + | |
- | ptln('< | + | |
- | | + | ptln('< |
- | $this-> | + | ptln('< |
- | + | ||
- | //new | + | |
- | $this-> | + | $this-> |
+ | |||
+ | //new | ||
+ | $this-> | ||
+ | |||
+ | //current config | ||
+ | $acls = $this-> | ||
+ | foreach ($acls as $id => $acl){ | ||
+ | $this-> | ||
+ | } | ||
- | //current config | ||
- | $acls = $this-> | ||
- | foreach ($acls as $id => $acl){ | ||
- | $this-> | ||
- | } | ||
- | | ||
- | | + | |
- | ptln('</ | + | 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 226: | Line 226: | ||
*/ | */ | ||
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 294: | Line 293: | ||
*/ | */ | ||
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 314: | Line 313: | ||
*/ | */ | ||
function admin_acl_del($acl_scope, | function admin_acl_del($acl_scope, | ||
- | | + | |
- | | + | |
- | | + | |
- | $new_config = preg_grep("/ | + | $new_config = preg_grep("/ |
- | | + | |
} | } | ||
Line 336: | Line 335: | ||
*/ | */ | ||
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 414: | Line 419: | ||
*/ | */ | ||
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' | + | |
- | 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 | + | |
- | | + | |
- | | + | |
- | // 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 520: | ||
*/ | */ | ||
function admin_superacl_html_new(){ | function admin_superacl_html_new(){ | ||
- | | + | |
- | global $lang; | + | global $lang; |
- | | + | |
- | ptln('< | + | ptln('< |
- | ptln(' | + | ptln(' |
- | ptln('</ | + | ptln('</ |
- | | + | |
- | | + | |
- | | + | |
- | ptln(' | + | ptln(' |
- | ptln(' | + | ptln(' |
- | ptln(' | + | ptln(' |
- | ptln(' | + | ptln(' |
+ | //scope select | ||
+ | ptln($this-> | ||
+ | ptln($this-> | ||
+ | $att = array( | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | ptln(' | ||
+ | ptln(' | ||
+ | ptln(' | ||
+ | ptln(' | ||
- | + | | |
- | + | ' | |
- | //scope select | + | ' |
- | ptln($this-> | + | ' |
- | ptln($this-> | + | ' |
- | + | | |
- | | + | ptln(' |
- | ' | + | ptln(' |
- | ' | + | ptln( |
- | ptln(' | + | ptln(' |
- | ptln(' | + | ptln(' |
- | ptln(' | + | ptln('</ |
- | ptln(' | + | ptln('</ |
- | + | ||
- | $att = array( | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ptln(' | + | |
- | ptln(' | + | |
- | + | ||
- | | + | |
- | + | ||
- | | + | |
- | ptln(' | + | |
- | ptln('</ | + | |
- | ptln('</ | + | |
} | } | ||
Line 571: | Line 575: | ||
*/ | */ | ||
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 646: | ||
ptln('</ | ptln('</ | ||
- | | + | |
} | } | ||
Line 654: | Line 658: | ||
*/ | */ | ||
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 726: | Line 732: | ||
**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 737: | Line 745: | ||
//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 756: | ||
//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); | ||
- | // 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 903: | Line 904: | ||
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 922: | Line 923: | ||
// 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 934: | Line 932: | ||
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 956: | Line 948: | ||
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 966: | Line 956: | ||
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 995: | Line 981: | ||
==== Patches ==== | ==== Patches ==== | ||
+ | |||
+ | === Incompatible with " | ||
+ | https:// | ||
Line 1015: | Line 1004: | ||
< | < | ||
+ | > 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.txt · Last modified: 2014-03-20 18:23 by Aleksandr