问题
How to check if user have sysop or other permission (in file LocalSettings.php
or extension)?
回答1:
Ok found:
$wgHooks['ParserFirstCallInit'][] = 'ifUserSysop';
function ifUserSysop() {
global $wgUser;
if (in_array("sysop", $wgUser->getEffectiveGroups())) {
// if sysop
}
if($wgUser->isLoggedIn()) {
// is logged in
}
return true;
}
Full contents of $wgUser->getEffectiveGroups()
for sysop:
Array
(
[0] => bureaucrat
[1] => editor
[2] => sysop
[3] => *
[4] => user
)
For user:
Array
(
[0] => *
[1] => user
)
For anon:
Array
(
[0] => *
)
More intresting things ($wgUser->isAnon(), isLoggedIn(), isBlocked()
) available here
来源:https://stackoverflow.com/questions/17027076/check-if-user-is-sysop