Programming

MediaWiki Hack

For one of my projects i needed to show some links on the left bar in mediawiki only if the admin is logged in.
Following are the steps how i achieved this.
1) Create a new page in MediaWiki namespace called [[MediaWiki:AdminLinks]]
2) put all the links for admin in this page
3) now in the template i add a new function
function isSysOp()
{
global $wgUser;

for( $i =0; $imRights); $i++)
{
if( $wgUser->mRights[$i] == 'userrights' ) return true;
}
return false;
}
This function returns true if the current logged in user is an Admin.
4) In my template i add in the location i wanted the admin menu

<?
if( $this->isSysOp() )
{ ?>
Admin Tools
<?
$this->msgWiki( 'AdminLinks' );
}

?>

Thats it, and the admin tools menu option will be showed only when the admin logs in.

Syndicate content