1<?php
2
3// must be run within Dokuwiki
4
5if(!defined('DOKU_INC')) die();
6
7class action_plugin_ireadit_auth extends DokuWiki_Action_Plugin {
8
9    /**
10     * Registers a callback function for a given event
11     *
12     * @param Doku_Event_Handler $controller DokuWiki's event controller object
13     * @return void
14     */
15    public function register(Doku_Event_Handler $controller) {
16        $controller->register_hook('AUTH_USER_CHANGE','AFTER', $this, 'handle_auth_user_change');
17    }
18
19    public function handle_auth_user_change(Doku_Event $event) {
20        // update the index
21        global $conf;
22        $data = array();
23        search($data, $conf['datadir'], 'search_allpages', array('skipacl' => true));
24        foreach($data as $val) {
25            // if we use ireadit on the page, invalidate index
26            if (p_get_metadata($val['id'], 'plugin_ireadit=0.2')) {
27                $idxtag = metaFN($val['id'],'.indexed');
28                @unlink($idxtag);
29            }
30        }
31    }
32}
33