From c78fa7d720d5e30e1386708d475b5fece1378431 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sun, 26 Jun 2011 04:12:05 +0000 Subject: [PATCH] * Core: ** Made addAutopromoteOnceGroups() put in a user rights log entry ** Added APCOND_ISBOT cond to autopromote and updated some docs * FlaggedRevs: ** (bug 24948) Made $wgFlaggedRevsAutopromote a wrapper around $wgAutopromoteOnce and removed maybeMakeEditor()/recordDemote() (uses r90749) ** Split off new efSetFlaggedRevsOldAutopromoteConfig function ** Removed calls to FlaggedRevs class in setup function to avoid overhead ** Made cache keys in checkAutoPromoteCond() properly unique ** Made wasPreviouslyBlocked() protected and tweaked editSpacingCheck() param order --- includes/Autopromote.php | 4 +++- includes/DefaultSettings.php | 3 ++- includes/Defines.php | 1 + includes/User.php | 19 +++++++++++++++---- languages/messages/MessagesEn.php | 9 +++++---- maintenance/language/messages.inc | 1 + 6 files changed, 27 insertions(+), 10 deletions(-) diff --git a/includes/Autopromote.php b/includes/Autopromote.php index 9e8c049a1b..bdb2cb066c 100644 --- a/includes/Autopromote.php +++ b/includes/Autopromote.php @@ -68,7 +68,7 @@ class Autopromote { /** * Recursively check a condition. Conditions are in the form - * array( '&' or '|' or '^', cond1, cond2, ... ) + * array( '&' or '|' or '^' or '!', cond1, cond2, ... ) * where cond1, cond2, ... are themselves conditions; *OR* * APCOND_EMAILCONFIRMED, *OR* * array( APCOND_EMAILCONFIRMED ), *OR* @@ -176,6 +176,8 @@ class Autopromote { return IP::isInRange( wfGetIP(), $cond[1] ); case APCOND_BLOCKED: return $user->isBlocked(); + case APCOND_ISBOT: + return in_array( 'bot', User::getGroupPermissions( $user->getGroups() ) ); default: $result = null; wfRunHooks( 'AutopromoteCondition', array( $cond[0], array_slice( $cond, 1 ), $user, &$result ) ); diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 723ef4e8e7..85a0a9e50a 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -3498,7 +3498,7 @@ $wgAutoConfirmCount = 0; /** * Automatically add a usergroup to any user who matches certain conditions. * The format is - * array( '&' or '|' or '^', cond1, cond2, ... ) + * array( '&' or '|' or '^' or '!', cond1, cond2, ... ) * where cond1, cond2, ... are themselves conditions; *OR* * APCOND_EMAILCONFIRMED, *OR* * array( APCOND_EMAILCONFIRMED ), *OR* @@ -3509,6 +3509,7 @@ $wgAutoConfirmCount = 0; * array( APCOND_IPINRANGE, range ), *OR* * array( APCOND_AGE_FROM_EDIT, seconds since first edit ), *OR* * array( APCOND_BLOCKED ), *OR* + * array( APCOND_ISBOT ), *OR* * similar constructs defined by extensions. * * If $wgEmailAuthentication is off, APCOND_EMAILCONFIRMED will be true for any diff --git a/includes/Defines.php b/includes/Defines.php index b4a8d7b41d..4b52bf930d 100644 --- a/includes/Defines.php +++ b/includes/Defines.php @@ -249,4 +249,5 @@ define( 'APCOND_ISIP', 5 ); define( 'APCOND_IPINRANGE', 6 ); define( 'APCOND_AGE_FROM_EDIT', 7 ); define( 'APCOND_BLOCKED', 8 ); +define( 'APCOND_ISBOT', 9 ); /**@}*/ diff --git a/includes/User.php b/includes/User.php index 9e648122dd..26603562e5 100644 --- a/includes/User.php +++ b/includes/User.php @@ -1117,14 +1117,25 @@ class User { * @see $wgAutopromoteOnce */ public function addAutopromoteOnceGroups( $event ) { + $toPromote = array(); if ( $this->getId() ) { $toPromote = Autopromote::getAutopromoteOnceGroups( $this, $event ); - foreach ( $toPromote as $group ) { - $this->addGroup( $group ); + if ( count( $toPromote ) ) { + $oldGroups = $this->getGroups(); // previous groups + foreach ( $toPromote as $group ) { + $this->addGroup( $group ); + } + $newGroups = array_merge( $oldGroups, $toPromote ); // all groups + + $log = new LogPage( 'rights', false /* not in RC */ ); + $log->addEntry( 'rights', + $this->getUserPage(), + wfMsgForContent( 'rightsautocomment' ), + array( implode( ', ', $oldGroups ), implode( ', ', $newGroups ) ) + ); } - return $toPromote; } - return array(); + return $toPromote; } /** diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 61f1f7d034..b9325a7621 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -1978,10 +1978,11 @@ Your e-mail address is not revealed when other users contact you.', 'right-sendemail' => 'Send e-mail to other users', # User rights log -'rightslog' => 'User rights log', -'rightslogtext' => 'This is a log of changes to user rights.', -'rightslogentry' => 'changed group membership for $1 from $2 to $3', -'rightsnone' => '(none)', +'rightslog' => 'User rights log', +'rightslogtext' => 'This is a log of changes to user rights.', +'rightslogentry' => 'changed group membership for $1 from $2 to $3', +'rightsnone' => '(none)', +'rightsautocomment' => 'automatically promoted', # Associated actions - in the sentence "You do not have permission to X" 'action-read' => 'read this page', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 2474420721..d620d76819 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -1143,6 +1143,7 @@ $wgMessageStructure = array( 'rightslogtext', 'rightslogentry', 'rightsnone', + 'rightsautocomment', ), 'action' => array( 'action-read', -- 2.20.1