如何使用Mediawiki中的Php检查用户是否为Sysop? [英] How to check if user is Sysop using Php in Mediawiki?

查看:83
本文介绍了如何使用Mediawiki中的Php检查用户是否为Sysop?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将div添加到我的侧边栏,并且我只希望此块显示给管理员.如何检查用户是否是php中的管理员?我正在尝试将其添加到myskin.php文件,但不知道该怎么做.我一直在使用类似的方法来检查用户是否已登录,

I am trying to add a div to my sidebar and I only want this block to show to administrators. How can I check if a user is an administrator in php? I am trying to add this to myskin.php file and dont know how to do it. I have been using something like this to check if a user is logged in,

<?php if($this->data['loggedin']) { ?> 

是否有类似的方法来检查该用户是否为sysop?

Is there anything similar to that to check if that user is a sysop?

推荐答案

* blackops_programmer *给出的答案中的代码检查用户是否可以保护页面.默认情况下,这将是sysops,但是可以从任何组中分配或删除该权限.

The code in the answer by *blackops_programmer* checks whether the user can protect pages. Per default, that would be sysops, but the permission can be assigned or removed from any group.

如果您要执行的操作取决于保护页面的权限,则检查权限是正确的方法(除非您应使用$ this-> getUser(),而不是$ wgUser). 但是,如果您确实要检查sysop组,请使用以下命令:

If what you want to do depends on the right to protect pages, then checking the permission is the correct way (except you should use $this->getUser(), not $wgUser). However, if you really want to check for the sysop group, use this:

if ( in_array( 'sysop', $this->getUser()->getEffectiveGroups() ) {
  echo 'Hello People';
}

这篇关于如何使用Mediawiki中的Php检查用户是否为Sysop?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆