1<?php
2
3use dokuwiki\Remote\AccessDeniedException;
4
5/**
6 * Class remote_plugin_confmanager
7 */
8class remote_plugin_confmanager extends DokuWiki_Remote_Plugin {
9
10    /**
11     * @var helper_plugin_confmanager
12     */
13    private $helper;
14
15    /**
16     * Constructor
17     */
18    public function __construct() {
19        parent::__construct();
20
21        $this->helper = $this->loadHelper('confmanager', null);
22    }
23
24    /**
25     * Get all available methods with remote access.
26     *
27     * @return array Information about all provided methods.
28     */
29    public function _getMethods() {
30        return [
31            'getConfigs' => [
32                'args' => [],
33                'return' => 'array'
34            ]
35        ];
36    }
37
38    /**
39     * @return mixed
40     * @throws AccessDeniedException
41     */
42    public function getConfigs() {
43        $this->ensureAdmin();
44        $this->helper->getConfigFiles();
45        return $this->getApi()->toDate(time());
46    }
47
48    /**
49     * @throws AccessDeniedException
50     */
51    private function ensureAdmin() {
52        if (!auth_isadmin()) {
53            throw new AccessDeniedException();
54        }
55    }
56}
57