Skip to content
Snippets Groups Projects
Commit 48ca2703 authored by Andreas Gohr's avatar Andreas Gohr
Browse files

isAccessibleByCurrentUser() can run without $INFO

Because the isAccessibleByUser method can be run in contexts where $INFO
is not available, an explicit check is needed.
parent b058d418
No related branches found
No related tags found
No related merge requests found
...@@ -32,9 +32,7 @@ class template_pagetitle_test extends DokuWikiTest { ...@@ -32,9 +32,7 @@ class template_pagetitle_test extends DokuWikiTest {
} }
function test_adminPluginTitle() { function test_adminPluginTitle() {
global $ID,$ACT,$INPUT,$conf,$INFO; global $ID,$ACT,$INPUT,$conf,$USERINFO;
$INFO['isadmin'] = true;
$INFO['ismanager'] = true;
if (!plugin_load('admin','revert')) { if (!plugin_load('admin','revert')) {
$this->markTestSkipped('Revert plugin not found, unable to test admin plugin titles'); $this->markTestSkipped('Revert plugin not found, unable to test admin plugin titles');
...@@ -46,6 +44,7 @@ class template_pagetitle_test extends DokuWikiTest { ...@@ -46,6 +44,7 @@ class template_pagetitle_test extends DokuWikiTest {
$conf['lang'] = 'en'; $conf['lang'] = 'en';
$INPUT->set('page','revert'); $INPUT->set('page','revert');
$INPUT->server->set('REMOTE_USER', 'testuser'); // this user is admin
$this->assertEquals('Revert Manager', tpl_pagetitle(null, true)); $this->assertEquals('Revert Manager', tpl_pagetitle(null, true));
} }
......
...@@ -78,8 +78,6 @@ class DokuWiki_Admin_Plugin extends DokuWiki_Plugin { ...@@ -78,8 +78,6 @@ class DokuWiki_Admin_Plugin extends DokuWiki_Plugin {
* @return bool true if the current user may access this admin plugin * @return bool true if the current user may access this admin plugin
*/ */
public function isAccessibleByCurrentUser() { public function isAccessibleByCurrentUser() {
global $INFO;
$data = []; $data = [];
$data['instance'] = $this; $data['instance'] = $this;
$data['hasAccess'] = false; $data['hasAccess'] = false;
...@@ -87,9 +85,9 @@ class DokuWiki_Admin_Plugin extends DokuWiki_Plugin { ...@@ -87,9 +85,9 @@ class DokuWiki_Admin_Plugin extends DokuWiki_Plugin {
$event = new Doku_Event('ADMINPLUGIN_ACCESS_CHECK', $data); $event = new Doku_Event('ADMINPLUGIN_ACCESS_CHECK', $data);
if($event->advise_before()) { if($event->advise_before()) {
if ($this->forAdminOnly()) { if ($this->forAdminOnly()) {
$data['hasAccess'] = $INFO['isadmin']; $data['hasAccess'] = auth_isadmin();
} else { } else {
$data['hasAccess'] = $INFO['ismanager']; $data['hasAccess'] = auth_ismanager();
} }
} }
$event->advise_after(); $event->advise_after();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment