1<?php
2/**
3 * DokuWiki Plugin toucher (Admin Component)
4 *
5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
6 * @author  Andriy Nych <nych.andriy@gmail.com>
7 */
8
9// must be run within Dokuwiki
10if (!defined('DOKU_INC')) die();
11
12if (!defined('DOKU_LF')) define('DOKU_LF', "\n");
13if (!defined('DOKU_TAB')) define('DOKU_TAB', "\t");
14if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
15
16require_once DOKU_PLUGIN.'admin.php';
17
18class admin_plugin_toucher extends DokuWiki_Admin_Plugin {
19
20    public function getMenuSort() {
21        return 13;
22    }
23
24    public function forAdminOnly() {
25        return $this->getConf('admin_only');
26    }
27
28    function touchFiles() {
29        touch(DOKU_CONF."local.php"); // this is the core of this plugin
30    }
31
32    public function handle() {
33        global $INFO;
34
35        if ($this->getConf('admin_only')) {
36            if (!$INFO[isadmin]) {
37                msg('Plugin toucher failed: you must be admin to touch configuration',-1);
38                return false;
39            }
40        }
41        $this->touchFiles();
42        msg('Plugin toucher touched configuration files',1);
43        return true;
44    }
45
46    public function html() {
47        ptln('<h1>' . $this->getLang('menu') . '</h1>');
48        ptln('<p>Configuration files have been just touched.</p>');
49    }
50}
51
52// vim:ts=4:sw=4:et:
53