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 * 11*67b479b2SGerrit Uitslag * @return array Information about all provided methods. {@see RemoteAPI} 1242ea7f44SGerrit Uitslag */ 1342ea7f44SGerrit Uitslag public function _getMethods() { 149f8068d2SMohamed Amine BERGAOUI return array( 151b7fc214SMohamed Amine BERGAOUI 'addAcl' => array( 169f8068d2SMohamed Amine BERGAOUI 'args' => array('string','string','int'), 179f8068d2SMohamed Amine BERGAOUI 'return' => 'int', 189f8068d2SMohamed Amine BERGAOUI 'name' => 'addAcl', 199f8068d2SMohamed Amine BERGAOUI 'doc' => 'Adds a new ACL rule.' 201b7fc214SMohamed Amine BERGAOUI ), 'delAcl' => array( 219f8068d2SMohamed Amine BERGAOUI 'args' => array('string','string'), 229f8068d2SMohamed Amine BERGAOUI 'return' => 'int', 239f8068d2SMohamed Amine BERGAOUI 'name' => 'delAcl', 249f8068d2SMohamed Amine BERGAOUI 'doc' => 'Delete an existing ACL rule.' 259f8068d2SMohamed Amine BERGAOUI ), 269f8068d2SMohamed Amine BERGAOUI ); 279f8068d2SMohamed Amine BERGAOUI } 289f8068d2SMohamed Amine BERGAOUI 2942ea7f44SGerrit Uitslag /** 3042ea7f44SGerrit Uitslag * Add a new entry to ACL config 3142ea7f44SGerrit Uitslag * 3242ea7f44SGerrit Uitslag * @param string $scope 3342ea7f44SGerrit Uitslag * @param string $user 3442ea7f44SGerrit Uitslag * @param int $level see also inc/auth.php 359cbf80e6SAndreas Gohr * @throws RemoteAccessDeniedException 3642ea7f44SGerrit Uitslag * @return bool 3742ea7f44SGerrit Uitslag */ 3842ea7f44SGerrit Uitslag public function addAcl($scope, $user, $level){ 399cbf80e6SAndreas Gohr if(!auth_isadmin()) { 409cbf80e6SAndreas Gohr throw new RemoteAccessDeniedException('You are not allowed to access ACLs, superuser permission is required', 114); 419cbf80e6SAndreas Gohr } 429cbf80e6SAndreas Gohr 4359bc3b48SGerrit Uitslag /** @var admin_plugin_acl $apa */ 441b7fc214SMohamed Amine BERGAOUI $apa = plugin_load('admin', 'acl'); 459f8068d2SMohamed Amine BERGAOUI return $apa->_acl_add($scope, $user, $level); 469f8068d2SMohamed Amine BERGAOUI } 479f8068d2SMohamed Amine BERGAOUI 4842ea7f44SGerrit Uitslag /** 4942ea7f44SGerrit Uitslag * Remove an entry from ACL config 5042ea7f44SGerrit Uitslag * 5142ea7f44SGerrit Uitslag * @param string $scope 5242ea7f44SGerrit Uitslag * @param string $user 539cbf80e6SAndreas Gohr * @throws RemoteAccessDeniedException 5442ea7f44SGerrit Uitslag * @return bool 5542ea7f44SGerrit Uitslag */ 5642ea7f44SGerrit Uitslag public function delAcl($scope, $user){ 579cbf80e6SAndreas Gohr if(!auth_isadmin()) { 589cbf80e6SAndreas Gohr throw new RemoteAccessDeniedException('You are not allowed to access ACLs, superuser permission is required', 114); 599cbf80e6SAndreas Gohr } 609cbf80e6SAndreas Gohr 6159bc3b48SGerrit Uitslag /** @var admin_plugin_acl $apa */ 621b7fc214SMohamed Amine BERGAOUI $apa = plugin_load('admin', 'acl'); 639f8068d2SMohamed Amine BERGAOUI return $apa->_acl_del($scope, $user); 649f8068d2SMohamed Amine BERGAOUI } 659f8068d2SMohamed Amine BERGAOUI} 669f8068d2SMohamed Amine BERGAOUI 67