手册:$wgAutopromote

From MediaWiki.org
Jump to navigation Jump to search
This page is a translated version of the page Manual:$wgAutopromote and the translation is 40% 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可以是:

Possible conditions

Possible conditions (defined in Defines.php ; extensions may add more through the AutopromoteCondition hook):

条件 描述 Argument(s)
APCOND_EDITCOUNT Minimum number of edits necessary 整数
APCOND_AGE 自注册以来的最小秒数 整数
APCOND_EMAILCONFIRMED Email address has been confirmed (不适用)
APCOND_INGROUPS List of groups the user must be in 例如, 'sysop', 'bureaucrat', 'bot'
APCOND_ISIP User has a specific IP address 例如, '1.2.3.4' or '2001:0db8:85a3::7344'
APCOND_IPINRANGE User is in a specific IP range 参见Manual:IP ranges
APCOND_AGE_FROM_EDIT Minimum number of seconds since first edit 整数
APCOND_BLOCKED Account is blocked (added in v1.16: r52083) (Not applicable)
APCOND_ISBOT Account is a bot (不适用)


Conditions with and without arguments

Each condition can be written in two forms:

APCOND_EMAILCONFIRMED   # condition with no arguments
array( APCOND_EDITCOUNT, 100 )   # condition with arguments

Set of conditions

Sets of conditions have the following syntax:

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

There are 4 operands available:

  • & (AND) — promote if user matches all conditions
  • | (OR) — promote if user matches any condition
  • ^ (XOR) — promote if user matches only one of two conditions
  • ! (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 seconds ago, you would use:

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

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 ),
);

参见