Hello,
I've created an action plugin that should allow users to edit (and create) a page matching their name in some specific namespaces.
However, it seems that my plugin never gets called. I followed the plugin file structure The plugin shows up in the list and is activated. The allowdebug parameter is set to true (1) but nothing about my plugin shows up in the log. What should I do ? Do I miss something ?
Thanks in advance for your help.
here is the code for my plugin
class action_plugin_userpageedit_acl_check extends DokuWiki_Action_Plugin {
public function register(Doku_Event_Handler $controller) {
dbglog("REGISTER MY PLUGIN !");
$controller->register_hook('AUTH_ACL_CHECK', 'AFTER', $this, 'handle_auth_acl_check');
$controller->register_hook('TPL_CONTENT_DISPLAY', 'BEFORE', $this, 'handle_content_display');
}
public function handle_content_display(Doku_Event &$event, $param) {
dbglog("PLUGIN CALLED !");
$event->data.="<hr/><p style=\"font-size: 40px\">PLUGIN CALLED !</p>";
}
public function handle_auth_acl_check(Doku_Event &$event, $param) {
dbg("HANDLING AUTH !");
$auth = $event->result;
if ($auth >= AUTH_CREATE) return; // If the user already has the permission, skip processing
$id = $event->data['id'];
$ns = getNS($id);
$userNS = $this->getConfArray('userNS');
dbglog("IN_USER_NS: ".$inUserNS);
if (!in_array($ns, $userNS)) return; // If we're not in the user namespaces skip further processing
$user = $event->data['user'];
$userGroups = $event->data['groups'];
$groupConstraint = $this->getConfArray('userPageEditGroups');
$colonPos = strrpos($id, ':');
$pageBasename = $id;
if ($colonPos!==false) $pageBasename = substr($id, $colonPos+1);
if ($pageBasename==$user) { // If page name matches user name
dbglog("USERPAGE: true");
if (count($groupConstraint)) { // If user must be in a group
dbglog("CHECKING IS_IN_GROUPS...");
$isInGroups = false;
foreach ($userGroups as $uGroup) {
if (in_array($uGroup, $groupConstraints)) {
$isInGroups = true;
break;
}
}
dbglog("IS_IN_GROUPS: ".$isInGroups);
if (!$isInGroups) return; // Skip if not in group
}
$event->result = AUTH_CREATE; // Give create permission
}
dbglog("AUTH: ".$event->result);
}
private function getConfArray($key) {
$val = $this->getConf($key);
$res = array();
if (strlen($val)>0) {
$res = explode(',', $val);
}
return res;
}
}