Open main menu
This page is a translated version of the page Manual:$wgAutopromote and the translation is 83% complete.

Other languages:
Deutsch • ‎English • ‎français • ‎magyar • ‎polski • ‎русский • ‎中文 • ‎日本語
访问: $wgAutopromote
将用户自动提升到特定组的条件
引进版本:1.12.0 (r28797)
移除版本:仍在使用
允许的值:(数组)
默认值:
array(
    "autoconfirmed" => array( "&",
        array( APCOND_EDITCOUNT, &$wgAutoConfirmCount ),
        array( APCOND_AGE, &$wgAutoConfirmAge ),
    ),
    "emailconfirmed" => APCOND_EMAILCONFIRMED,
)

1.14+

[
	'autoconfirmed' => [ '&',
		[ APCOND_EDITCOUNT, &$wgAutoConfirmCount ],
		[ APCOND_AGE, &$wgAutoConfirmAge ],
	],
]

详情

此数组包含自动升级的标准。语法是:

$wgAutopromote = array(
    'groupname' => cond,
    'group2' => cond,
);

这里cond可以是:

可能的条件

可能的条件(在Defines.php 中定义;扩展可以通过AutopromoteCondition 钩子添加更多):

条件 描述 参数
APCOND_EDITCOUNT 必要的最少编辑次数 整数
APCOND_AGE 自注册以来的最小秒数 整数
APCOND_EMAILCONFIRMED 电子邮件地址已确认 (不适用)
APCOND_INGROUPS 用户必须在的用户组列表 例如, 'sysop', 'bureaucrat', 'bot'
APCOND_ISIP 用户具有特定的IP地址 例如, '1.2.3.4' or '2001:0db8:85a3::7344'
APCOND_IPINRANGE 用户处于特定的IP范围内 参见Manual:IP ranges
APCOND_AGE_FROM_EDIT 自首次编辑以来的最小秒数 整数
APCOND_BLOCKED 帐户被封禁(在v1.16:r52083中添加) (不适用)
APCOND_ISBOT 帐户是一个机器人 (不适用)

有和没有参数的条件

每种情况都可以用两种形式写成:

APCOND_EMAILCONFIRMED   # 没有参数的条件
array( APCOND_EDITCOUNT, 100 )   # 有参数的条件

条件集

条件集具有以下语法:

array( "operand", cond1, cond2, ... );

There are 4 operands available:

  • & (AND) — 如果用户符合所有条件,则授权
  • | (OR) — 如果用户符合任何条件,则授权
  • ^ (XOR) — 如果用户匹配两个条件中的一个,则授权
  • ! (NOT) — promote if user matches no conditions.

The sets of conditions are evaluated recursively, so you can use nested sets of conditions linked by operands.

敬告

Autopromotion doesn't actually add users to a group; MediaWiki will check whether a user meets the conditions for autopromotion whenever it checks the user's rights or effective groups. This means that a user will only appear to be in a group on Special:ListUsers if they were added to it through Special:UserRights. It also means you can't directly remove a user from an autopromotion group through Special:UserRights: $wgRevokePermissions might be useful for you, or if you're not using MediaWiki 1.16+, a workaround is available.

例子

The following examples need to be fixed since they create fatal errors.

If you wanted to autopromote each user to captain upon his having both confirmed his email address and either made at least 100 edits or registered his account at least 60 days ago, you would use:

$wgAutopromote = array(
	'captain' => array(
		'&',
		APCOND_EMAILCONFIRMED,
		'|',
		array( APCOND_EDITCOUNT, 100 ),
		array( APCOND_AGE, 60*86400 ),
	),
);

Note that this would get rid of all other autopromote groups; to instead add the captain autopromote group while keeping those autopromote groups that already exist, one would use:

$wgAutopromote['captain'] = array(
	'&',
	APCOND_EMAILCONFIRMED,
	'|',
	array( APCOND_EDITCOUNT, 100 ),
	array( APCOND_AGE, 60*86400 ),
);

参见