Topic on Project:Support desk

[RESOLVED] Hiding toolbox except for admin and bureaucrat

5
94.196.106.150 (talkcontribs)

In skins/Vector.php I can hide toolbox from logged out thus:

if ( $wgUser->isLoggedIn() ) {
				case 'TOOLBOX':
                                   if ( $wgUser->isLoggedIn() ) {
					$this->renderPortal( 'tb', $this->getToolbox(), 'toolbox', 'SkinTemplateToolboxEnd' );
                   }

but User::isSysop() and similar are deprecated.

How would I use the recommended $user->isAllowed to specify the admin and bureaucrat group? I have not managed to find this, sorry.


  • MediaWiki 1.22.2
  • PHP 5.3.6-13ubuntu3.10 (apache2handler)
  • MySQL 5.1.69-0ubuntu0.11.10.1-log
Wgkderdicke (talkcontribs)

Maybe you can use this:

$wgUser->getGroups()

It will give you an array of all groups in which the current user is member.

88.130.77.163 (talkcontribs)

Hi!

You can go through the file includes/User.php to see, which methods are available for the user object. If there should be no method, which returns, if the user is an admin, then maybe you can work with the method getEffectiveGroups() somehow like so:

if ( in_array( 'sysop', $this->getUser()->getEffectiveGroups() ) {
 // code to show toolbox
}

Maybe you still have to adjust that somehow, like using $wgUser instead of $this->getUser and maybe by checking for _both_ groups, but I guess you get the basic idea.

94.196.238.197 (talkcontribs)
Reply to "[RESOLVED] Hiding toolbox except for admin and bureaucrat"