r47252 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47251‎ | r47252 | r47253 >
Date:08:52, 14 February 2009
Author:aaron
Status:deferred
Tags:
Comment:
Re-did autoreview right. Did away with FIRST_EDIT condition query spam and fixed bug where it didn't show in user prefs.
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -440,6 +440,8 @@
441441
442442 # Actually register special pages
443443 $wgHooks['SpecialPage_initList'][] = 'efLoadFlaggedRevsSpecialPages';
 444+# Special auto-promote
 445+$wgHooks['GetAutoPromoteGroups'][] = 'FlaggedRevsHooks::checkAutoPromote';
444446
445447 #########
446448
@@ -461,18 +463,9 @@
462464 global $wgHooks;
463465 $wgHooks['userCan'][] = 'FlaggedRevsHooks::userCanView';
464466 }
465 - # Grant implicit autoreview rights to some users.
466 - # This will include older users that choose not to be Editors.
467 - global $wgAutopromote, $wgFlaggedRevsAutopromote, $wgImplicitGroups;
468 - if( is_array($wgFlaggedRevsAutopromote) ) {
469 - $wgAutopromote['autoreview'] = array( '&',
470 - array( APCOND_EDITCOUNT, max($wgFlaggedRevsAutopromote['edits'],3000) ),
471 - array( APCOND_AGE, max($wgFlaggedRevsAutopromote['days'],365)*24*3600 ),
472 - array( APCOND_AGE_FROM_EDIT, max($wgFlaggedRevsAutopromote['days'],365)*24*3600 ),
473 - array( APCOND_EMAILCONFIRMED, $wgFlaggedRevsAutopromote['email'] )
474 - );
475 - $wgImplicitGroups[] = 'autoreview';
476 - }
 467+ # Don't show autoreview group everywhere
 468+ global $wgImplicitGroups;
 469+ $wgImplicitGroups[] = 'autoreview';
477470 }
478471
479472 /*
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -832,6 +832,44 @@
833833 }
834834 return true;
835835 }
 836+
 837+ /**
 838+ * Check for 'autoreview' permission. This lets people who opt-out as
 839+ * Editors still have their own edits automatically reviewed.
 840+ */
 841+ public static function checkAutoPromote( $user, &$promote ) {
 842+ global $wgFlaggedRevsAutopromote;
 843+ wfProfileIn( __METHOD__ );
 844+ if( empty($wgFlaggedRevsAutopromote) || !$user->getId() || $user->isAllowed('autoreview') ) {
 845+ wfProfileOut( __METHOD__ );
 846+ return true; // not needed
 847+ }
 848+ # Check user email
 849+ if( $wgFlaggedRevsAutopromote['email'] && !$user->isEmailConfirmed() ) {
 850+ wfProfileOut( __METHOD__ );
 851+ return true;
 852+ }
 853+ # Get requirments
 854+ $editsReq = max($wgFlaggedRevsAutopromote['edits'],3000);
 855+ $timeReq = max($wgFlaggedRevsAutopromote['days'],365);
 856+ # Check account age
 857+ $now = time();
 858+ $usercreation = wfTimestampOrNull( TS_UNIX, $user->getRegistration() );
 859+ $userage = $usercreation ? floor(($now - $usercreation) / 86400) : NULL;
 860+ if( !is_null($userage) && $userage < $timeReq ) {
 861+ wfProfileOut( __METHOD__ );
 862+ return true;
 863+ }
 864+ # Check user edit count. Should be stored.
 865+ if( $user->getEditCount() < $editsReq ) {
 866+ wfProfileOut( __METHOD__ );
 867+ return true;
 868+ }
 869+ # Add the right
 870+ $promote[] = 'autoreview';
 871+ wfProfileOut( __METHOD__ );
 872+ return true;
 873+ }
836874
837875 /**
838876 * Callback that autopromotes user according to the setting in

Status & tagging log