diff --git a/action.php b/action.php index 6e07ea3..325b50d 100644 --- a/action.php +++ b/action.php @@ -1,5 +1,10 @@ */ -class action_plugin_structacl extends \dokuwiki\Extension\ActionPlugin +class action_plugin_structacl extends ActionPlugin { /** @inheritDoc */ - public function register(Doku_Event_Handler $controller) + public function register(EventHandler $controller) { $mode = $this->getConf('run'); $controller->register_hook('AUTH_ACL_CHECK', $mode, $this, 'handleAclCheck', $mode); @@ -25,11 +30,11 @@ public function register(Doku_Event_Handler $controller) * If current user is found in a configured struct field of the current page, * upload permissions are granted. * - * @param Doku_Event $event event object by reference + * @param Event $event event object by reference * @param string $mode BEFORE|AFTER * @return void */ - public function handleAclCheck(Doku_Event $event, $mode) + public function handleAclCheck(Event $event, $mode) { global $ID; global $REV; @@ -52,12 +57,12 @@ public function handleAclCheck(Doku_Event $event, $mode) continue; } try { - $schema = new \dokuwiki\plugin\struct\meta\Schema($schemaName); + $schema = new Schema($schemaName); $schemaData = AccessTable::getPageAccess($schemaName, $ID, (int)$REV); $data = $schemaData->getData(); foreach ($fields as $field) { $col = $schema->findColumn($field); - if ($col && is_a($col->getType(), \dokuwiki\plugin\struct\types\User::class)) { + if ($col && is_a($col->getType(), User::class)) { $value = $data[$field]->getValue(); if (empty($value)) continue; // multivalue field? @@ -74,7 +79,7 @@ public function handleAclCheck(Doku_Event $event, $mode) } // grant upload permissions if current user is found in struct field - if (!empty($users) && in_array($event->data['user'], $users)) { + if ($users !== [] && in_array($event->data['user'], $users)) { $event->result = AUTH_UPLOAD; } @@ -84,4 +89,3 @@ public function handleAclCheck(Doku_Event $event, $mode) } } } - diff --git a/helper.php b/helper.php index 615886c..a5c9913 100644 --- a/helper.php +++ b/helper.php @@ -1,8 +1,10 @@