isAccessibleByCurrentUser() can run without $INFO
Because the isAccessibleByUser method can be run in contexts where $INFO is not available, an explicit check is needed.
This commit is contained in:
parent
b058d418d9
commit
48ca2703a1
|
@ -32,9 +32,7 @@ class template_pagetitle_test extends DokuWikiTest {
|
|||
}
|
||||
|
||||
function test_adminPluginTitle() {
|
||||
global $ID,$ACT,$INPUT,$conf,$INFO;
|
||||
$INFO['isadmin'] = true;
|
||||
$INFO['ismanager'] = true;
|
||||
global $ID,$ACT,$INPUT,$conf,$USERINFO;
|
||||
|
||||
if (!plugin_load('admin','revert')) {
|
||||
$this->markTestSkipped('Revert plugin not found, unable to test admin plugin titles');
|
||||
|
@ -46,6 +44,7 @@ class template_pagetitle_test extends DokuWikiTest {
|
|||
$conf['lang'] = 'en';
|
||||
$INPUT->set('page','revert');
|
||||
|
||||
$INPUT->server->set('REMOTE_USER', 'testuser'); // this user is admin
|
||||
$this->assertEquals('Revert Manager', tpl_pagetitle(null, true));
|
||||
}
|
||||
|
||||
|
|
|
@ -78,8 +78,6 @@ class DokuWiki_Admin_Plugin extends DokuWiki_Plugin {
|
|||
* @return bool true if the current user may access this admin plugin
|
||||
*/
|
||||
public function isAccessibleByCurrentUser() {
|
||||
global $INFO;
|
||||
|
||||
$data = [];
|
||||
$data['instance'] = $this;
|
||||
$data['hasAccess'] = false;
|
||||
|
@ -87,9 +85,9 @@ class DokuWiki_Admin_Plugin extends DokuWiki_Plugin {
|
|||
$event = new Doku_Event('ADMINPLUGIN_ACCESS_CHECK', $data);
|
||||
if($event->advise_before()) {
|
||||
if ($this->forAdminOnly()) {
|
||||
$data['hasAccess'] = $INFO['isadmin'];
|
||||
$data['hasAccess'] = auth_isadmin();
|
||||
} else {
|
||||
$data['hasAccess'] = $INFO['ismanager'];
|
||||
$data['hasAccess'] = auth_ismanager();
|
||||
}
|
||||
}
|
||||
$event->advise_after();
|
||||
|
|
Loading…
Reference in New Issue