19f8068d2SMohamed Amine BERGAOUI<?php 29f8068d2SMohamed Amine BERGAOUI 342ea7f44SGerrit Uitslag/** 442ea7f44SGerrit Uitslag * Class remote_plugin_acl 542ea7f44SGerrit Uitslag */ 69f8068d2SMohamed Amine BERGAOUIclass remote_plugin_acl extends DokuWiki_Remote_Plugin { 742ea7f44SGerrit Uitslag 842ea7f44SGerrit Uitslag /** 942ea7f44SGerrit Uitslag * Returns details about the remote plugin methods 1042ea7f44SGerrit Uitslag * 1167b479b2SGerrit Uitslag * @return array Information about all provided methods. {@see RemoteAPI} 1242ea7f44SGerrit Uitslag */ 1342ea7f44SGerrit Uitslag public function _getMethods() { 149f8068d2SMohamed Amine BERGAOUI return array( 156d2588b6SCyril Duchon-Doris 'listAcls' => array( 166d2588b6SCyril Duchon-Doris 'args' => array(), 176d2588b6SCyril Duchon-Doris 'return' => 'Array of ACLs {scope, user, permission}', 1832b2e368SDharmik 'name' => 'listAcls', 191fa1d6bcSCyril Duchon-Doris 'doc' => 'Get the list of all ACLs', 201fa1d6bcSCyril Duchon-Doris ),'addAcl' => array( 219f8068d2SMohamed Amine BERGAOUI 'args' => array('string','string','int'), 229f8068d2SMohamed Amine BERGAOUI 'return' => 'int', 239f8068d2SMohamed Amine BERGAOUI 'name' => 'addAcl', 249f8068d2SMohamed Amine BERGAOUI 'doc' => 'Adds a new ACL rule.' 251b7fc214SMohamed Amine BERGAOUI ), 'delAcl' => array( 269f8068d2SMohamed Amine BERGAOUI 'args' => array('string','string'), 279f8068d2SMohamed Amine BERGAOUI 'return' => 'int', 289f8068d2SMohamed Amine BERGAOUI 'name' => 'delAcl', 299f8068d2SMohamed Amine BERGAOUI 'doc' => 'Delete an existing ACL rule.' 309f8068d2SMohamed Amine BERGAOUI ), 319f8068d2SMohamed Amine BERGAOUI ); 329f8068d2SMohamed Amine BERGAOUI } 339f8068d2SMohamed Amine BERGAOUI 3442ea7f44SGerrit Uitslag /** 356d2588b6SCyril Duchon-Doris * List all ACL config entries 366d2588b6SCyril Duchon-Doris * 3742f3fd0aSCyril Duchon-Doris * @throws RemoteAccessDeniedException 3842f3fd0aSCyril Duchon-Doris * @return dictionary {Scope: ACL}, where ACL = dictionnary {user/group: permissions_int} 396d2588b6SCyril Duchon-Doris */ 406d2588b6SCyril Duchon-Doris public function listAcls(){ 4142f3fd0aSCyril Duchon-Doris if(!auth_isadmin()) { 42*64159a61SAndreas Gohr throw new RemoteAccessDeniedException( 43*64159a61SAndreas Gohr 'You are not allowed to access ACLs, superuser permission is required', 44*64159a61SAndreas Gohr 114 45*64159a61SAndreas Gohr ); 4642f3fd0aSCyril Duchon-Doris } 476d2588b6SCyril Duchon-Doris /** @var admin_plugin_acl $apa */ 486d2588b6SCyril Duchon-Doris $apa = plugin_load('admin', 'acl'); 4942f3fd0aSCyril Duchon-Doris $apa->_init_acl_config(); 5042f3fd0aSCyril Duchon-Doris return $apa->acl; 516d2588b6SCyril Duchon-Doris } 526d2588b6SCyril Duchon-Doris 536d2588b6SCyril Duchon-Doris /** 5442ea7f44SGerrit Uitslag * Add a new entry to ACL config 5542ea7f44SGerrit Uitslag * 5642ea7f44SGerrit Uitslag * @param string $scope 5742ea7f44SGerrit Uitslag * @param string $user 5842ea7f44SGerrit Uitslag * @param int $level see also inc/auth.php 599cbf80e6SAndreas Gohr * @throws RemoteAccessDeniedException 6042ea7f44SGerrit Uitslag * @return bool 6142ea7f44SGerrit Uitslag */ 6242ea7f44SGerrit Uitslag public function addAcl($scope, $user, $level){ 639cbf80e6SAndreas Gohr if(!auth_isadmin()) { 64*64159a61SAndreas Gohr throw new RemoteAccessDeniedException( 65*64159a61SAndreas Gohr 'You are not allowed to access ACLs, superuser permission is required', 66*64159a61SAndreas Gohr 114 67*64159a61SAndreas Gohr ); 689cbf80e6SAndreas Gohr } 699cbf80e6SAndreas Gohr 7059bc3b48SGerrit Uitslag /** @var admin_plugin_acl $apa */ 711b7fc214SMohamed Amine BERGAOUI $apa = plugin_load('admin', 'acl'); 729f8068d2SMohamed Amine BERGAOUI return $apa->_acl_add($scope, $user, $level); 739f8068d2SMohamed Amine BERGAOUI } 749f8068d2SMohamed Amine BERGAOUI 7542ea7f44SGerrit Uitslag /** 7642ea7f44SGerrit Uitslag * Remove an entry from ACL config 7742ea7f44SGerrit Uitslag * 7842ea7f44SGerrit Uitslag * @param string $scope 7942ea7f44SGerrit Uitslag * @param string $user 809cbf80e6SAndreas Gohr * @throws RemoteAccessDeniedException 8142ea7f44SGerrit Uitslag * @return bool 8242ea7f44SGerrit Uitslag */ 8342ea7f44SGerrit Uitslag public function delAcl($scope, $user){ 849cbf80e6SAndreas Gohr if(!auth_isadmin()) { 85*64159a61SAndreas Gohr throw new RemoteAccessDeniedException( 86*64159a61SAndreas Gohr 'You are not allowed to access ACLs, superuser permission is required', 87*64159a61SAndreas Gohr 114 88*64159a61SAndreas Gohr ); 899cbf80e6SAndreas Gohr } 909cbf80e6SAndreas Gohr 9159bc3b48SGerrit Uitslag /** @var admin_plugin_acl $apa */ 921b7fc214SMohamed Amine BERGAOUI $apa = plugin_load('admin', 'acl'); 939f8068d2SMohamed Amine BERGAOUI return $apa->_acl_del($scope, $user); 949f8068d2SMohamed Amine BERGAOUI } 959f8068d2SMohamed Amine BERGAOUI} 969f8068d2SMohamed Amine BERGAOUI 97