File: ap_enable.class.php

package info (click to toggle)
dokuwiki 0.0.20091225c-10%2Bsqueeze2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 19,292 kB
  • ctags: 11,043
  • sloc: php: 93,871; sh: 385; perl: 193; makefile: 27
file content (49 lines) | stat: -rw-r--r-- 1,558 bytes parent folder | download | duplicates (3)
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();
        }
    }

}