xref: /dokuwiki/lib/plugins/acl/remote.php (revision 6d2588b68360cafc455923a1374f061329b08640)
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            'listAcls' => array(
16                'args' => array(),
17                'return' => 'Array of ACLs {scope, user, permission}',
18                'name' => 'listAcl',
19                'doc' => 'Get the list of all ACLs'
20            )'addAcl' => array(
21                'args' => array('string','string','int'),
22                'return' => 'int',
23                'name' => 'addAcl',
24                'doc' => 'Adds a new ACL rule.'
25            ), 'delAcl' => array(
26                'args' => array('string','string'),
27                'return' => 'int',
28                'name' => 'delAcl',
29                'doc' => 'Delete an existing ACL rule.'
30            ),
31        );
32    }
33
34    /**
35     * List all ACL config entries
36     *
37     * @return array [{scope, user, permission}]
38     */
39    public function listAcls(){
40        /** @var admin_plugin_acl $apa */
41        $apa = plugin_load('admin', 'acl');
42        return $apa->_acl_list();
43    }
44
45    /**
46     * Add a new entry to ACL config
47     *
48     * @param string $scope
49     * @param string $user
50     * @param int    $level see also inc/auth.php
51     * @return bool
52     */
53    public function addAcl($scope, $user, $level){
54        /** @var admin_plugin_acl $apa */
55        $apa = plugin_load('admin', 'acl');
56        return $apa->_acl_add($scope, $user, $level);
57    }
58
59    /**
60     * Remove an entry from ACL config
61     *
62     * @param string $scope
63     * @param string $user
64     * @return bool
65     */
66    public function delAcl($scope, $user){
67        /** @var admin_plugin_acl $apa */
68        $apa = plugin_load('admin', 'acl');
69        return $apa->_acl_del($scope, $user);
70    }
71}
72
73