You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

76 lines
2.2 KiB

  1. <?php
  2. use dokuwiki\Extension\RemotePlugin;
  3. use dokuwiki\Remote\AccessDeniedException;
  4. /**
  5. * Class remote_plugin_acl
  6. */
  7. class remote_plugin_acl extends RemotePlugin
  8. {
  9. /**
  10. * Get the list all ACL config entries
  11. *
  12. * @return array {Scope: ACL}, where ACL = dictionnary {user/group: permissions_int}
  13. * @throws AccessDeniedException
  14. */
  15. public function listAcls()
  16. {
  17. if (!auth_isadmin()) {
  18. throw new AccessDeniedException(
  19. 'You are not allowed to access ACLs, superuser permission is required',
  20. 114
  21. );
  22. }
  23. /** @var admin_plugin_acl $apa */
  24. $apa = plugin_load('admin', 'acl');
  25. $apa->initAclConfig();
  26. return $apa->acl;
  27. }
  28. /**
  29. * Add a new ACL rule to the config
  30. *
  31. * @param string $scope The page or namespace to apply the ACL to
  32. * @param string $user The user or group to apply the ACL to
  33. * @param int $level The permission level to set
  34. * @return bool If adding the ACL rule was successful
  35. * @throws AccessDeniedException
  36. */
  37. public function addAcl($scope, $user, $level)
  38. {
  39. if (!auth_isadmin()) {
  40. throw new AccessDeniedException(
  41. 'You are not allowed to access ACLs, superuser permission is required',
  42. 114
  43. );
  44. }
  45. /** @var admin_plugin_acl $apa */
  46. $apa = plugin_load('admin', 'acl');
  47. return $apa->addOrUpdateACL($scope, $user, $level);
  48. }
  49. /**
  50. * Remove an entry from ACL config
  51. *
  52. * @param string $scope The page or namespace the ACL applied to
  53. * @param string $user The user or group the ACL applied to
  54. * @return bool If removing the ACL rule was successful
  55. * @throws AccessDeniedException
  56. */
  57. public function delAcl($scope, $user)
  58. {
  59. if (!auth_isadmin()) {
  60. throw new AccessDeniedException(
  61. 'You are not allowed to access ACLs, superuser permission is required',
  62. 114
  63. );
  64. }
  65. /** @var admin_plugin_acl $apa */
  66. $apa = plugin_load('admin', 'acl');
  67. return $apa->deleteACL($scope, $user);
  68. }
  69. }