diff --git a/lib/plugins/acl/admin.php b/lib/plugins/acl/admin.php index 814bbfe9c44ff27524cad7b2e6c87c43c5d1b63f..51872cafb0ba0ba6e67a6bc2f69a10ccc0d90636 100644 --- a/lib/plugins/acl/admin.php +++ b/lib/plugins/acl/admin.php @@ -649,7 +649,6 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin { echo '</div></form>'.NL; } - /** * Returns the permission which were set for exactly the given user/group * and page/namespace. Returns null if no exact match is available @@ -675,6 +674,50 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin { } } + /** + * return an array of all ACLs + * (meant to be use by XMLRC API) + * Mostly a copy of _init_acl_config, consider refactoring ? + * + * @author Cyril Duchon-Doris <cyril.duchon-doris@telecom-paristech.org> + */ + function _acl_list(){ + global $AUTH_ACL; + global $conf; + $acl_config = array(); + $usersgroups = array(); + + // get special users and groups + $this->specials[] = '@ALL'; + $this->specials[] = '@'.$conf['defaultgroup']; + if($conf['manager'] != '!!not set!!'){ + $this->specials = array_merge($this->specials, + array_map('trim', + explode(',',$conf['manager']))); + } + $this->specials = array_filter($this->specials); + $this->specials = array_unique($this->specials); + sort($this->specials); + + foreach($AUTH_ACL as $line){ + $line = trim(preg_replace('/#.*$/','',$line)); //ignore comments + if(!$line) continue; + + $acl = preg_split('/[ \t]+/',$line); + //0 is pagename, 1 is user, 2 is acl + + $acl[1] = rawurldecode($acl[1]); + $acl_config[$acl[0]][$acl[1]] = $acl[2]; + + // store non-special users and groups for later selection dialog + $ug = $acl[1]; + if(in_array($ug,$this->specials)) continue; + } + + ksort($acl_config); + return $acl_config; + } + /** * adds new acl-entry to conf/acl.auth.php * diff --git a/lib/plugins/acl/remote.php b/lib/plugins/acl/remote.php index b10c544eeb05bf5007952bbd8e5c257ce06e98d5..a3fe98a34158dbdb30205748f08e240228dd7e90 100644 --- a/lib/plugins/acl/remote.php +++ b/lib/plugins/acl/remote.php @@ -12,7 +12,12 @@ class remote_plugin_acl extends DokuWiki_Remote_Plugin { */ public function _getMethods() { return array( - 'addAcl' => array( + 'listAcls' => array( + 'args' => array(), + 'return' => 'Array of ACLs {scope, user, permission}', + 'name' => 'listAcl', + 'doc' => 'Get the list of all ACLs' + )'addAcl' => array( 'args' => array('string','string','int'), 'return' => 'int', 'name' => 'addAcl', @@ -26,6 +31,17 @@ class remote_plugin_acl extends DokuWiki_Remote_Plugin { ); } + /** + * List all ACL config entries + * + * @return array [{scope, user, permission}] + */ + public function listAcls(){ + /** @var admin_plugin_acl $apa */ + $apa = plugin_load('admin', 'acl'); + return $apa->_acl_list(); + } + /** * Add a new entry to ACL config *