summaryrefslogtreecommitdiff
path: root/lib/plugins/plugin/classes/ap_enable.class.php
blob: 35450a9073dd43768f3896007fbc9743f0cef386 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php

class ap_enable extends ap_manage {

    var $enabled = array();

    function process() {
        global $plugin_protected;
        $count_enabled = $count_disabled = 0;

        $this->enabled = isset($_REQUEST['enabled']) ? $_REQUEST['enabled'] : array();

        foreach ($this->manager->plugin_list as $plugin) {
            if (in_array($plugin, $plugin_protected)) continue;

            $new = in_array($plugin, $this->enabled);
            $old = !plugin_isdisabled($plugin);

            if ($new != $old) {
                switch ($new) {
                    // enable plugin
                    case true :
                        if(plugin_enable($plugin)){
                            msg(sprintf($this->lang['enabled'],$plugin),1);
                            $count_enabled++;
                        }else{
                            msg(sprintf($this->lang['notenabled'],$plugin),-1);
                        }
                        break;
                    case false:
                        if(plugin_disable($plugin)){
                            msg(sprintf($this->lang['disabled'],$plugin),1);
                            $count_disabled++;
                        }else{
                            msg(sprintf($this->lang['notdisabled'],$plugin),-1);
                        }
                        break;
                }
            }
        }

        // refresh plugins, including expiring any dokuwiki cache(s)
        if ($count_enabled || $count_disabled) {
            $this->refresh();
        }
    }

}