2

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?

svick
  • 236,525
  • 50
  • 385
  • 514
RISC OS
  • 149
  • 11
  • This question appears to be offtopic because it's about a documentation that is not even fully read from the OP (http://www.mediawiki.org/wiki/Manual:User_rights) – Royal Bg Jan 07 '14 at 10:02
  • http://www.mediawiki.org/wiki/Manual:User_rights – RISC OS Jan 07 '14 at 17:36
  • Nothinng to do with what I asked, your comment is offtopic because it's about settings for mediawiki. you have not even fully read the original post. – RISC OS Jan 07 '14 at 17:37

1 Answers1

0

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;
}
RISC OS
  • 149
  • 11