1<?php 2/** 3 * projects Action Plugin: hijack the page write events 4 * 5 * @author Junling Ma <junlingm@gmail.com> 6 */ 7 8require_once(dirname(__FILE__).'/../conf.php'); 9require_once DOKU_PLUGIN.'action.php'; 10 11class action_plugin_projects_page 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' => 'hijack page write events', 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_WIKIPAGE_WRITE', 'AFTER', $this, 29 'wrote'); 30 } 31 32 /** 33 * intercept page deletion 34 * 35 */ 36 function wrote(&$event, $param) { 37 $content = $event->data[0][1]; 38 if ($content) return; 39 $namespace = $event->data[1]; 40 $project = Project::project($namespace); 41 if ($project == NULL) return; 42 $name = $event->data[2]; 43 if ($project->file($name) == NULL) return; 44 if (!$project->remove_file($name)) 45 msg('Other users are currently updating the project. Please save this page later.'); 46 } 47 48} 49 50?>