19f8068d2SMohamed Amine BERGAOUI<?php 29f8068d2SMohamed Amine BERGAOUI 38553d24dSAndreas Gohruse dokuwiki\Extension\RemotePlugin; 4dd87735dSAndreas Gohruse dokuwiki\Remote\AccessDeniedException; 5dd87735dSAndreas Gohr 642ea7f44SGerrit Uitslag/** 742ea7f44SGerrit Uitslag * Class remote_plugin_acl 842ea7f44SGerrit Uitslag */ 98553d24dSAndreas Gohrclass remote_plugin_acl extends RemotePlugin 10a4e3d556SAndreas Gohr{ 1142ea7f44SGerrit Uitslag /** 12*01052543SAndreas Gohr * Get the list all ACL config entries 1342ea7f44SGerrit Uitslag * 14*01052543SAndreas Gohr * @return array {Scope: ACL}, where ACL = dictionnary {user/group: permissions_int} 15dd87735dSAndreas Gohr * @throws AccessDeniedException 166d2588b6SCyril Duchon-Doris */ 17a4e3d556SAndreas Gohr public function listAcls() 18a4e3d556SAndreas Gohr { 1942f3fd0aSCyril Duchon-Doris if (!auth_isadmin()) { 20dd87735dSAndreas Gohr throw new AccessDeniedException( 2164159a61SAndreas Gohr 'You are not allowed to access ACLs, superuser permission is required', 2264159a61SAndreas Gohr 114 2364159a61SAndreas Gohr ); 2442f3fd0aSCyril Duchon-Doris } 256d2588b6SCyril Duchon-Doris /** @var admin_plugin_acl $apa */ 266d2588b6SCyril Duchon-Doris $apa = plugin_load('admin', 'acl'); 27a4e3d556SAndreas Gohr $apa->initAclConfig(); 2842f3fd0aSCyril Duchon-Doris return $apa->acl; 296d2588b6SCyril Duchon-Doris } 306d2588b6SCyril Duchon-Doris 316d2588b6SCyril Duchon-Doris /** 32*01052543SAndreas Gohr * Add a new ACL rule to the config 3342ea7f44SGerrit Uitslag * 34*01052543SAndreas Gohr * @param string $scope The page or namespace to apply the ACL to 35*01052543SAndreas Gohr * @param string $user The user or group to apply the ACL to 36*01052543SAndreas Gohr * @param int $level The permission level to set 37*01052543SAndreas Gohr * @return bool If adding the ACL rule was successful 38dd87735dSAndreas Gohr * @throws AccessDeniedException 3942ea7f44SGerrit Uitslag */ 40a4e3d556SAndreas Gohr public function addAcl($scope, $user, $level) 41a4e3d556SAndreas Gohr { 429cbf80e6SAndreas Gohr if (!auth_isadmin()) { 43dd87735dSAndreas Gohr throw new AccessDeniedException( 4464159a61SAndreas Gohr 'You are not allowed to access ACLs, superuser permission is required', 4564159a61SAndreas Gohr 114 4664159a61SAndreas Gohr ); 479cbf80e6SAndreas Gohr } 489cbf80e6SAndreas Gohr 4959bc3b48SGerrit Uitslag /** @var admin_plugin_acl $apa */ 501b7fc214SMohamed Amine BERGAOUI $apa = plugin_load('admin', 'acl'); 5155cc5b99SAndreas Gohr return $apa->addOrUpdateACL($scope, $user, $level); 529f8068d2SMohamed Amine BERGAOUI } 539f8068d2SMohamed Amine BERGAOUI 5442ea7f44SGerrit Uitslag /** 5542ea7f44SGerrit Uitslag * Remove an entry from ACL config 5642ea7f44SGerrit Uitslag * 57*01052543SAndreas Gohr * @param string $scope The page or namespace the ACL applied to 58*01052543SAndreas Gohr * @param string $user The user or group the ACL applied to 59*01052543SAndreas Gohr * @return bool If removing the ACL rule was successful 60dd87735dSAndreas Gohr * @throws AccessDeniedException 6142ea7f44SGerrit Uitslag */ 62a4e3d556SAndreas Gohr public function delAcl($scope, $user) 63a4e3d556SAndreas Gohr { 649cbf80e6SAndreas Gohr if (!auth_isadmin()) { 65dd87735dSAndreas Gohr throw new AccessDeniedException( 6664159a61SAndreas Gohr 'You are not allowed to access ACLs, superuser permission is required', 6764159a61SAndreas Gohr 114 6864159a61SAndreas Gohr ); 699cbf80e6SAndreas Gohr } 709cbf80e6SAndreas Gohr 7159bc3b48SGerrit Uitslag /** @var admin_plugin_acl $apa */ 721b7fc214SMohamed Amine BERGAOUI $apa = plugin_load('admin', 'acl'); 73a4e3d556SAndreas Gohr return $apa->deleteACL($scope, $user); 749f8068d2SMohamed Amine BERGAOUI } 759f8068d2SMohamed Amine BERGAOUI} 76