Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -200,6 +200,7 @@ |
201 | 201 | 'benchmarks' => 15, # how many edit intervals are needed? |
202 | 202 | 'recentContentEdits' => 10, # $wgContentNamespaces edits in recent changes |
203 | 203 | 'totalContentEdits' => 300, # $wgContentNamespaces edits |
| 204 | + 'reviewedEdits' => 200, # Sighted edits (not used yet) |
204 | 205 | 'uniqueContentPages' => 10, # $wgContentNamespaces unique pages edited |
205 | 206 | 'editComments' => 50, # how many edit comments used? |
206 | 207 | 'email' => false, # user must be emailconfirmed? |
Index: trunk/extensions/FlaggedRevs/maintenance/updateAutoPromote.inc |
— | — | @@ -43,7 +43,7 @@ |
44 | 44 | ); |
45 | 45 | $p['totalContentEdits'] = $db->numRows( $sres ); |
46 | 46 | # Get unique content pages edited |
47 | | - $sres = $db->select( array('revision','page'), 'DISTINCT (rev_page)', |
| 47 | + $sres = $db->select( array('revision','page'), 'DISTINCT(rev_page)', |
48 | 48 | array( 'rev_user' => $user->getID(), |
49 | 49 | 'page_id = rev_page', |
50 | 50 | 'page_namespace' => $wgContentNamespaces ), |
— | — | @@ -51,6 +51,15 @@ |
52 | 52 | array( 'LIMIT' => $wgFlaggedRevsAutopromote['uniqueContentPages'] ) |
53 | 53 | ); |
54 | 54 | $p['uniqueContentPages'] = $db->numRows( $sres ); |
| 55 | + # Get reviewed edits |
| 56 | + $sres = $db->select( array('revision','flaggedrevs'), '1', |
| 57 | + array( 'rev_user' => $user->getID(), |
| 58 | + 'fr_page_id = rev_page', |
| 59 | + 'fr_rev_id = rev_id' ), |
| 60 | + __METHOD__, |
| 61 | + array( 'LIMIT' => $wgFlaggedRevsAutopromote['reviewedEdits'] ) |
| 62 | + ); |
| 63 | + $p['reviewedEdits'] = $db->numRows( $sres ); |
55 | 64 | |
56 | 65 | if( $oldp != $p ) { |
57 | 66 | FlaggedRevs::saveUserParams( $user, $p ); |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php |
— | — | @@ -887,12 +887,12 @@ |
888 | 888 | |
889 | 889 | /** |
890 | 890 | * Get params for a user |
891 | | - * @param User $user |
| 891 | + * @param int $uid |
892 | 892 | */ |
893 | | - public static function getUserParams( $user ) { |
| 893 | + public static function getUserParams( $uid ) { |
894 | 894 | $dbw = wfGetDB( DB_MASTER ); |
895 | 895 | $row = $dbw->selectRow( 'flaggedrevs_promote', 'frp_user_params', |
896 | | - array( 'frp_user_id' => $user->getId() ), |
| 896 | + array( 'frp_user_id' => $uid ), |
897 | 897 | __METHOD__ ); |
898 | 898 | # Parse params |
899 | 899 | $params = array(); |
— | — | @@ -910,10 +910,10 @@ |
911 | 911 | |
912 | 912 | /** |
913 | 913 | * Save params for a user |
914 | | - * @param User $user |
| 914 | + * @param int $uid |
915 | 915 | * @param Array $params |
916 | 916 | */ |
917 | | - public static function saveUserParams( $user, $params ) { |
| 917 | + public static function saveUserParams( $uid, $params ) { |
918 | 918 | $flatParams = ''; |
919 | 919 | foreach( $params as $key => $value ) { |
920 | 920 | $flatParams .= "{$key}={$value}\n"; |
— | — | @@ -921,10 +921,9 @@ |
922 | 922 | $dbw = wfGetDB( DB_MASTER ); |
923 | 923 | $row = $dbw->replace( 'flaggedrevs_promote', |
924 | 924 | array( 'frp_user_id' ), |
925 | | - array( 'frp_user_id' => $user->getId(), |
926 | | - 'frp_user_params' => trim($flatParams) ), |
927 | | - __METHOD__ ); |
928 | | - |
| 925 | + array( 'frp_user_id' => $uid, 'frp_user_params' => trim($flatParams) ), |
| 926 | + __METHOD__ |
| 927 | + ); |
929 | 928 | return ( $dbw->affectedRows() > 0 ); |
930 | 929 | } |
931 | 930 | |
Index: trunk/extensions/FlaggedRevs/specialpages/RevisionReview_body.php |
— | — | @@ -656,6 +656,16 @@ |
657 | 657 | } |
658 | 658 | # Update link tracking. This will trigger our hook to add stable links too... |
659 | 659 | $u->doUpdate(); |
| 660 | + |
| 661 | + # Update user stats if this rev was not flagged |
| 662 | + if( !$oldfrev && $rev->getRawUser() ) { |
| 663 | + global $wgFlaggedRevsAutopromote; |
| 664 | + $p = FlaggedRevs::getUserParams( $rev->getRawUser() ); |
| 665 | + $p['reviewedEdits'] = isset($p['reviewedEdits']) ? $p['reviewedEdits'] : 0; |
| 666 | + $p['reviewedEdits']++; |
| 667 | + if( $wgFlaggedRevsAutopromote['reviewedEdits'] > $p['reviewedEdits'] ) |
| 668 | + FlaggedRevs::saveUserParams( $rev->getRawUser(), $p ); |
| 669 | + } |
660 | 670 | |
661 | 671 | $dbw->commit(); |
662 | 672 | # Purge cache/squids for this page and any page that uses it |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php |
— | — | @@ -790,12 +790,12 @@ |
791 | 791 | # Grab current groups |
792 | 792 | $groups = $user->getGroups(); |
793 | 793 | # Do not give this to current holders or bots |
794 | | - if( $user->isAllowed('bot') || in_array('bot',$groups) || in_array('editor',$groups) ) { |
| 794 | + if( $user->isAllowed('bot') || in_array('editor',$groups) ) { |
795 | 795 | wfProfileOut( __METHOD__ ); |
796 | 796 | return true; |
797 | 797 | } |
798 | 798 | # Do not re-add status if it was previously removed! |
799 | | - $p = FlaggedRevs::getUserParams( $user ); |
| 799 | + $p = FlaggedRevs::getUserParams( $user->getId() ); |
800 | 800 | if( isset($p['demoted']) && $p['demoted'] ) { |
801 | 801 | wfProfileOut( __METHOD__ ); |
802 | 802 | return true; |
— | — | @@ -806,6 +806,7 @@ |
807 | 807 | $p['uniqueContentPages'] = isset($p['uniqueContentPages']) ? $p['uniqueContentPages'] : ''; |
808 | 808 | $p['totalContentEdits'] = isset($p['totalContentEdits']) ? $p['totalContentEdits'] : 0; |
809 | 809 | $p['editComments'] = isset($p['editComments']) ? $p['editComments'] : 0; |
| 810 | + $p['reviewedEdits'] = isset($p['reviewedEdits']) ? $p['reviewedEdits'] : 0; |
810 | 811 | if( $article->getTitle()->isContentPage() ) { |
811 | 812 | $pages = explode( ',', trim($p['uniqueContentPages']) ); // page IDs |
812 | 813 | # Don't let this get bloated for no reason |
— | — | @@ -822,7 +823,7 @@ |
823 | 824 | } |
824 | 825 | # Save any updates to user params |
825 | 826 | if( $changed ) { |
826 | | - FlaggedRevs::saveUserParams( $user, $p ); |
| 827 | + FlaggedRevs::saveUserParams( $user->getId(), $p ); |
827 | 828 | } |
828 | 829 | # Check if user edited enough content pages |
829 | 830 | if( $wgFlaggedRevsAutopromote['totalContentEdits'] > $p['totalContentEdits'] ) { |
— | — | @@ -1022,9 +1023,9 @@ |
1023 | 1024 | */ |
1024 | 1025 | public static function recordDemote( $u, $addgroup, $removegroup ) { |
1025 | 1026 | if( $removegroup && in_array('editor',$removegroup) ) { |
1026 | | - $params = FlaggedRevs::getUserParams( $u ); |
| 1027 | + $params = FlaggedRevs::getUserParams( $u->getId() ); |
1027 | 1028 | $params['demoted'] = 1; |
1028 | | - FlaggedRevs::saveUserParams( $u, $params ); |
| 1029 | + FlaggedRevs::saveUserParams( $u->getId(), $params ); |
1029 | 1030 | } |
1030 | 1031 | return true; |
1031 | 1032 | } |