Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -440,6 +440,8 @@ |
441 | 441 | |
442 | 442 | # Actually register special pages |
443 | 443 | $wgHooks['SpecialPage_initList'][] = 'efLoadFlaggedRevsSpecialPages'; |
| 444 | +# Special auto-promote |
| 445 | +$wgHooks['GetAutoPromoteGroups'][] = 'FlaggedRevsHooks::checkAutoPromote'; |
444 | 446 | |
445 | 447 | ######### |
446 | 448 | |
— | — | @@ -461,18 +463,9 @@ |
462 | 464 | global $wgHooks; |
463 | 465 | $wgHooks['userCan'][] = 'FlaggedRevsHooks::userCanView'; |
464 | 466 | } |
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'; |
477 | 470 | } |
478 | 471 | |
479 | 472 | /* |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php |
— | — | @@ -832,6 +832,44 @@ |
833 | 833 | } |
834 | 834 | return true; |
835 | 835 | } |
| 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 | + } |
836 | 874 | |
837 | 875 | /** |
838 | 876 | * Callback that autopromotes user according to the setting in |