diff options
author | Andreas Gohr <andi@splitbrain.org> | 2009-08-07 11:46:07 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2009-08-07 11:46:07 +0200 |
commit | a8900dc9bb90521364ddb83a687175277ff5fa58 (patch) | |
tree | 09921f580ad1b4a6e57bbc8d29799ac8e32bbb7c /lib/plugins/acl/admin.php | |
parent | 831be45d6eb73357108a082896ebe060f9b9ad8a (diff) | |
download | rpg-a8900dc9bb90521364ddb83a687175277ff5fa58.tar.gz rpg-a8900dc9bb90521364ddb83a687175277ff5fa58.tar.bz2 |
Show media namespaces in ACL manager
Ignore-this: b46799f7d65081eaa364ecaab8a2c7f9
Namespaces that only exist within the media directory are now merged with the
page namespaces in tree explorer of the namespace manager
darcs-hash:20090807094607-7ad00-3ce30cffc528e7e20a4b19d8f30d1f3725806162.gz
Diffstat (limited to 'lib/plugins/acl/admin.php')
-rw-r--r-- | lib/plugins/acl/admin.php | 51 |
1 files changed, 45 insertions, 6 deletions
diff --git a/lib/plugins/acl/admin.php b/lib/plugins/acl/admin.php index 5014c282c..977bfc883 100644 --- a/lib/plugins/acl/admin.php +++ b/lib/plugins/acl/admin.php @@ -31,8 +31,8 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin { return array( 'author' => 'Andreas Gohr', 'email' => 'andi@splitbrain.org', - 'date' => '2008-12-16', - 'name' => 'ACL', + 'date' => '2009-08-07', + 'name' => 'ACL Manager', 'desc' => 'Manage Page Access Control Lists', 'url' => 'http://dokuwiki.org/plugin:acl', ); @@ -221,10 +221,7 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin { } $ns = utf8_encodeFN(str_replace(':','/',$ns)); - - $data = array(); - search($data,$conf['datadir'],'search_index',array('ns' => $ns)); - + $data = $this->_get_tree($ns); // wrap a list with the root level around the other namespaces $item = array( 'level' => 0, 'id' => '*', 'type' => 'd', @@ -244,6 +241,48 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin { } /** + * get a combined list of media and page files + * + * @param string $folder an already converted filesystem folder of the current namespace + * @param string $limit limit the search to this folder + */ + function _get_tree($folder,$limit=''){ + global $conf; + + // read tree structure from pages and media + $data = array(); + search($data,$conf['datadir'],'search_index',array('ns' => $folder),$limit); + $media = array(); + search($media,$conf['mediadir'],'search_index',array('ns' => $folder, 'nofiles' => true),$limit); + $data = array_merge($data,$media); + unset($media); + + // combine by sorting and removing duplicates + usort($data,array($this,'_tree_sort')); + $count = count($data); + if($count>0) for($i=1; $i<$count; $i++){ + if($data[$i]['type'] == 'f') break; // namespaces come first, we're done + if($data[$i-1]['id'] == $data[$i]['id']) unset($data[$i]); + } + return $data; + } + + /** + * usort callback + * + * Sorts the combined trees of media and page files + */ + function _tree_sort($a,$b){ + if($a['type'] == 'd' && $b['type'] == 'f'){ + return -1; + }elseif($a['type'] == 'f' && $b['type'] == 'd'){ + return 1; + }else{ + return strcmp($a['id'],$b['id']); + } + } + + /** * Display the current ACL for selected where/who combination with * selectors and modification form * |