Go to the documentation of this file.
43 if ( self::recCheckCondition( $cond, $user ) ) {
48 Hooks::run(
'GetAutoPromoteGroups', [ $user, &$promote ] );
75 if ( in_array( $group, $currentGroups ) ) {
79 if ( in_array( $group, $formerGroups ) ) {
83 if ( self::recCheckCondition( $cond, $user ) ) {
109 $validOps = [
'&',
'|',
'^',
'!' ];
111 if ( is_array( $cond ) && count( $cond ) >= 2 && in_array( $cond[0], $validOps ) ) {
112 # Recursive condition
113 if ( $cond[0] ==
'&' ) {
114 foreach ( array_slice( $cond, 1 ) as $subcond ) {
115 if ( !self::recCheckCondition( $subcond, $user ) ) {
121 } elseif ( $cond[0] ==
'|' ) {
122 foreach ( array_slice( $cond, 1 ) as $subcond ) {
123 if ( self::recCheckCondition( $subcond, $user ) ) {
129 } elseif ( $cond[0] ==
'^' ) {
130 if ( count( $cond ) > 3 ) {
131 wfWarn(
'recCheckCondition() given XOR ("^") condition on three or more conditions.' .
132 ' Check your $wgAutopromote and $wgAutopromoteOnce settings.' );
136 } elseif ( $cond[0] ==
'!' ) {
137 foreach ( array_slice( $cond, 1 ) as $subcond ) {
138 if ( self::recCheckCondition( $subcond, $user ) ) {
148 if ( !is_array( $cond ) ) {
167 if ( count( $cond ) < 1 ) {
171 switch ( $cond[0] ) {
173 if ( Sanitizer::validateEmail( $user->
getEmail() ) ) {
182 $reqEditCount = $cond[1];
185 if ( $reqEditCount <= 0 ) {
191 return $age >= $cond[1];
194 return $age >= $cond[1];
196 $groups = array_slice( $cond, 1 );
197 return count( array_intersect( $groups, $user->
getGroups() ) ) == count( $groups );
199 return $cond[1] == $user->
getRequest()->getIP();
205 return in_array(
'bot', MediaWikiServices::getInstance()
207 ->getGroupPermissions( $user->
getGroups() ) );
210 Hooks::run(
'AutopromoteCondition', [ $cond[0],
211 array_slice( $cond, 1 ), $user, &$result ] );
212 if ( $result ===
null ) {
213 throw new MWException(
"Unrecognized condition {$cond[0]} for autopromotion!" );
216 return (
bool)$result;
getEditCount()
Get the user's edit count.
$wgEmailAuthentication
Require email authentication before sending mail to an email address.
getGroups()
Get the list of explicit group memberships this user has.
getEmailAuthenticationTimestamp()
Get the timestamp of the user's e-mail authentication.
getRequest()
Get the WebRequest object to use with this object.
getEmail()
Get the user's e-mail address.
$wgAutopromote
Array containing the conditions of automatic promotion of a user to specific groups.
const APCOND_AGE_FROM_EDIT
wfTimestampOrNull( $outputtype=TS_UNIX, $ts=null)
Return a formatted timestamp, or null if input is null.
static isInRange( $addr, $range)
Determine if a given IPv4/IPv6 address is in a given CIDR network.
getBlock( $fromReplica=true)
Get the block affecting the user, or null if the user is not blocked.
getFirstEditTimestamp()
Get the timestamp of the first edit.
getFormerGroups()
Returns the groups the user has belonged to.
getRegistration()
Get the timestamp of account creation.
wfWarn( $msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
$wgAutopromoteOnce
Automatically add a usergroup to any user who matches certain conditions.
const APCOND_EMAILCONFIRMED