1<?php
2if(!defined('DOKU_INC')) die();
3if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
4require_once(DOKU_PLUGIN.'action.php');
5
6class action_plugin_maintenance extends DokuWiki_Action_Plugin {
7
8    function __construct() {
9        $this->helper =& plugin_load('helper', 'maintenance');
10        $this->helper->script_updatelockall();
11        $this->disallowed = array('register','resendpwd','profile','edit','draft','draftdel','preview','save','subscribe','unsubscribe');
12    }
13
14    /**
15     * register the eventhandlers
16     */
17    function register(&$contr){
18        if ($this->helper->is_locked()) {
19            $contr->register_hook('DOKUWIKI_STARTED', 'BEFORE', $this, 'before_start', array());
20            $contr->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'before_action', array());
21        }
22        else if ($this->getConf('script_auto')) {
23            $contr->register_hook('DOKUWIKI_DONE', 'AFTER', $this, 'after_done', array());
24        }
25    }
26
27    function before_start() {
28        msg($this->getConf('msg_lock'));
29    }
30
31    function before_action(&$event, $param) {
32        global $ACT;
33        $act = act_clean($ACT);
34        if (!in_array($act, $this->disallowed)) return;
35        msg('Command disabled: '.htmlspecialchars($act),-1);
36        $ACT = 'show';
37        $event->preventDefault();
38    }
39
40    function after_done(&$event, $param) {
41        if ($this->helper->is_locked()) return;
42        if ($this->helper->script_autocheck()) $this->helper->script_start($this->helper->get_script());
43    }
44}
45