xref: /dokuwiki/lib/plugins/acl/remote.php (revision fa4038c7f40f348e1335253ce6fb5600106b0233)
1<?php
2
3/**
4 * Class remote_plugin_acl
5 */
6class remote_plugin_acl extends DokuWiki_Remote_Plugin {
7
8    /**
9     * Returns details about the remote plugin methods
10     *
11     * @return array
12     */
13    public function _getMethods() {
14        return array(
15            'addAcl' => array(
16                'args' => array('string','string','int'),
17                'return' => 'int',
18                'name' => 'addAcl',
19                'doc' => 'Adds a new ACL rule.'
20            ), 'delAcl' => array(
21                'args' => array('string','string'),
22                'return' => 'int',
23                'name' => 'delAcl',
24                'doc' => 'Delete an existing ACL rule.'
25            ),
26        );
27    }
28
29    /**
30     * Add a new entry to ACL config
31     *
32     * @param string $scope
33     * @param string $user
34     * @param int    $level see also inc/auth.php
35     * @throws RemoteAccessDeniedException
36     * @return bool
37     */
38    public function addAcl($scope, $user, $level){
39        if(!auth_isadmin()) {
40            throw new RemoteAccessDeniedException('You are not allowed to access ACLs, superuser permission is required', 114);
41        }
42
43        /** @var admin_plugin_acl $apa */
44        $apa = plugin_load('admin', 'acl');
45        return $apa->_acl_add($scope, $user, $level);
46    }
47
48    /**
49     * Remove an entry from ACL config
50     *
51     * @param string $scope
52     * @param string $user
53     * @throws RemoteAccessDeniedException
54     * @return bool
55     */
56    public function delAcl($scope, $user){
57        if(!auth_isadmin()) {
58            throw new RemoteAccessDeniedException('You are not allowed to access ACLs, superuser permission is required', 114);
59        }
60
61        /** @var admin_plugin_acl $apa */
62        $apa = plugin_load('admin', 'acl');
63        return $apa->_acl_del($scope, $user);
64    }
65}
66
67