1<?php
2
3/**
4 * DokuWiki WebDAV Helper Class
5 *
6 * @author  Giuseppe Di Terlizzi <giuseppe.diterlizzi@gmail.com>
7 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
8 * @link    https://dokuwiki.org/plugin:webdav
9 */
10
11class helper_plugin_webdav extends DokuWiki_Plugin
12{
13
14    /**
15     * Perform access check for current user
16     *
17     * @return bool true if the current user has access to WebDAV
18     */
19    public function hasAccess()
20    {
21        global $conf;
22        global $USERINFO;
23        /** @var Input $INPUT */
24        global $INPUT;
25
26        if (!$this->getConf('remote')) {
27            return false;
28        }
29        if (trim($this->getConf('remoteuser')) == '!!not set!!') {
30            return false;
31        }
32        if (!$conf['useacl']) {
33            return true;
34        }
35        if (trim($this->getConf('remoteuser')) == '') {
36            return true;
37        }
38
39        return auth_isMember($this->getConf('remoteuser'), $INPUT->server->str('REMOTE_USER'), (array) $USERINFO['grps']);
40    }
41}
42