1<?php
2
3/**
4 * DokuWiki DAVCal PlugIn - Disable component
5 */
6
7if(!defined('DOKU_INC')) die();
8
9class action_plugin_davcal_disable extends DokuWiki_Action_Plugin {
10
11    /**
12     * @var helper_plugin_davcal
13     */
14    private $hlp = null;
15
16    function __construct() {
17        $this->hlp =& plugin_load('helper','davcal');
18    }
19
20    function register(Doku_Event_Handler $controller) {
21        $controller->register_hook('IO_WIKIPAGE_WRITE', 'BEFORE', $this, 'handle_wikipage_write');
22    }
23
24    function handle_wikipage_write(&$event, $param)
25    {
26        $data = $event->data;
27        if(strpos($data[0][1], '{{davcal') !== false) return; // Plugin is still enabled
28
29        $id = ltrim($data[1].':'.$data[2], ':');
30
31        $this->hlp->disableCalendarForPage($id);
32    }
33};
34