1<?php
2/**
3 * projects Action Plugin: manage the projects namespace
4 *
5 * @author     Junling Ma <junlingm@gmail.com>
6 */
7
8require_once(dirname(__FILE__).'/../lib/project.php');
9require_once DOKU_PLUGIN.'action.php';
10
11class action_plugin_projects_namespace extends DokuWiki_Action_Plugin {
12
13	function getInfo(){
14		return array(
15		 'author' => 'Junling Ma',
16		 'email'  => 'junlingm@gmail.com',
17		 'date'   => '2010-12-15',
18		 'name'   => 'Projects',
19		 'desc'   => 'Manage the projects namespaces',
20		 'url'    => 'http://www.math.uvic.ca/~jma'
21		 );
22	}
23
24    /**
25     * Register its handlers with the DokuWiki's event controller
26     */
27    function register(&$controller) {
28        $controller->register_hook('IO_NAMESPACE_CREATED', 'AFTER', $this,
29                                   'created');
30        $controller->register_hook('IO_NAMESPACE_DELETED', 'AFTER', $this,
31                                   'deleted');
32    }
33
34    /**
35     * a namespace has been created
36     *
37     */
38    function created(&$event, $param) {
39    	$wiki_path = $event->data[0];
40    	$project = Project::project($wiki_path, true);
41    }
42
43    /**
44     * a namespace has been deleted
45     *
46     */
47    function deleted(&$event, $param) {
48    	$wiki_path = $event->data[0];
49    	$project = Project::project($wiki_path);
50    	if ($project != NULL) $project->delete();
51	}
52
53}
54
55?>