I'm creating a mediawiki theme for my wiki. It is more than just css, I'm changing the layout too, as described in the mediawiki docs.
I would like to make the interface very simple, so I want to only show certain sidebars and other content if a user is logged in or is an "admin" user (or whatever they are called in mediawiki).
Changing the layout is done via php functions that I create in my skins php to output various page elements.
How do you check if a user is logged in? Or what rights/role they have? Is there some kind of function I can check, or constant set by mediawiki?
I have found the answer, incase anyone else needs it, it is:
$this->getSkin()->getUser()->isLoggedIn()
and with this function you can check if the user is admin:
/**
* Returns true if user is admin.
*/
protected function userIsAdmin() {
$isAdmin = FALSE;
if ($this->getSkin()->getUser()->isLoggedIn() === TRUE) {
foreach ($this->getSkin()->getUser()->getGroups() as $key => $group) {
if ($group == 'sysop') {
$isAdmin = TRUE;
break;
}
}
}
return $isAdmin;
}