Jump to content

手册:$wgAutopromote

From mediawiki.org
This page is a translated version of the page Manual:$wgAutopromote and the translation is 82% complete.
访问: $wgAutopromote
将用户自动提升到特定组的条件
引进版本:1.12.0 (r28797)
移除版本:仍在使用
允许的值:(数组)
默认值:(參見下方)

详情

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

$wgAutopromote = [
    'groupname' => cond,
    'group2' => cond,
];

这里cond可以是:

可能的条件

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

条件 描述 参数
APCOND_EDITCOUNT 必要的最少编辑次数
If null or missing $wgAutoConfirmCount will be used
整数
APCOND_AGE 自注册以来的最小秒数 If null or missing $wgAutoConfirmAge will be used 整数
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 )   # 有参数的条件

条件集

条件集具有以下语法:

[ 'operand', cond1, cond2, ... ];

共有4种操作可选:

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

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

敬告

Autopromotion does not 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.

Since MediaWiki 1.18 you can use AutopromoteOnce instead, which adds users normally to a group, if they match the given criteria and have not been demoted before. Alternatively, $wgRevokePermissions (MW 1.16+) might be useful for you.

Temporary users cannot be autopromoted, since they cannot be assigned to user groups.


預設值

MediaWiki版本:
1.38
$wgAutopromote = [
	'autoconfirmed' => [ '&',
		[ APCOND_EDITCOUNT, null],
		[ APCOND_AGE, null ],
	],
];
MediaWiki版本:
1.13 – 1.37
$wgAutopromote = [
	'autoconfirmed' => [ '&',
		[ APCOND_EDITCOUNT, &$wgAutoConfirmCount ],
		[ APCOND_AGE, &$wgAutoConfirmAge ],
	],
];
MediaWiki版本:
1.12
$wgAutopromote = array(
	'autoconfirmed' => array( '&',
		array( APCOND_EDITCOUNT, &$wgAutoConfirmCount ),
		array( APCOND_AGE, &$wgAutoConfirmAge ),
	),
	'emailconfirmed' => APCOND_EMAILCONFIRMED,
);

示例

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

$wgAutopromote = [
	'captain' => [
		'&',
		APCOND_EMAILCONFIRMED,
		[
			'|',
			[ APCOND_EDITCOUNT, 100 ],
			[ 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'] = [
	'&',
	APCOND_EMAILCONFIRMED,
	[
		'|',
		[ APCOND_EDITCOUNT, 100 ],
		[ APCOND_AGE, 60*86400 ],
	],
];

参阅