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();
201 return IP::isInRange( $user->
getRequest()->getIP(), $cond[1] );
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;
$wgAutopromote
Array containing the conditions of automatic promotion of a user to specific groups.
$wgEmailAuthentication
Require email authentication before sending mail to an email address.
$wgAutopromoteOnce
Automatically add a usergroup to any user who matches certain conditions.
wfWarn( $msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
wfTimestampOrNull( $outputtype=TS_UNIX, $ts=null)
Return a formatted timestamp, or null if input is null.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
getRequest()
Get the WebRequest object to use with this object.
getEmailAuthenticationTimestamp()
Get the timestamp of the user's e-mail authentication.
getFirstEditTimestamp()
Get the timestamp of the first edit.
getRegistration()
Get the timestamp of account creation.
getGroups()
Get the list of explicit group memberships this user has.
getEditCount()
Get the user's edit count.
getFormerGroups()
Returns the groups the user has belonged to.
getEmail()
Get the user's e-mail address.
getBlock( $fromReplica=true)
Get the block affecting the user, or null if the user is not blocked.
const APCOND_EMAILCONFIRMED
const APCOND_AGE_FROM_EDIT