https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113389

Revision: 113389
Author:   aaron
Date:     2012-03-08 19:42:54 +0000 (Thu, 08 Mar 2012)
Log Message:
-----------
* Renamed misleading onUserCan fuction to onGetUserPermissionsErrors as it 
hooks on 'getUserPermissionsErrors'.
* Cleaned up inconsistent checking of 'edit' permissions to determing 'review' 
permissions. It is now checked for automatic review checks and not just manual 
review attempts.
* (bug 33385) Narrowed down "review right requires edit right" to just checking 
edit restrictions, which better aligns with the original point of the check, 
which is to handle "edit wars" and "review wars". This should work better with 
the Translate extension.

Modified Paths:
--------------
    trunk/extensions/FlaggedRevs/FlaggedRevs.setup.php
    trunk/extensions/FlaggedRevs/backend/FlaggedRevs.hooks.php
    trunk/extensions/FlaggedRevs/business/RevisionReviewForm.php

Modified: trunk/extensions/FlaggedRevs/FlaggedRevs.setup.php
===================================================================
--- trunk/extensions/FlaggedRevs/FlaggedRevs.setup.php  2012-03-08 19:42:24 UTC 
(rev 113388)
+++ trunk/extensions/FlaggedRevs/FlaggedRevs.setup.php  2012-03-08 19:42:54 UTC 
(rev 113389)
@@ -211,7 +211,7 @@
 
                # ######## Other #########
                # Determine what pages can be moved and patrolled
-               $wgHooks['getUserPermissionsErrors'][] = 
'FlaggedRevsHooks::onUserCan';
+               $wgHooks['getUserPermissionsErrors'][] = 
'FlaggedRevsHooks::onGetUserPermissionsErrors';
                # Implicit autoreview rights group
                $wgHooks['AutopromoteCondition'][] = 
'FlaggedRevsHooks::checkAutoPromoteCond';
                $wgHooks['UserLoadAfterLoadFromSession'][] = 
'FlaggedRevsHooks::setSessionKey';

Modified: trunk/extensions/FlaggedRevs/backend/FlaggedRevs.hooks.php
===================================================================
--- trunk/extensions/FlaggedRevs/backend/FlaggedRevs.hooks.php  2012-03-08 
19:42:24 UTC (rev 113388)
+++ trunk/extensions/FlaggedRevs/backend/FlaggedRevs.hooks.php  2012-03-08 
19:42:54 UTC (rev 113389)
@@ -295,7 +295,7 @@
        /**
         * Check page move and patrol permissions for FlaggedRevs
         */
-       public static function onUserCan( Title $title, $user, $action, 
&$result ) {
+       public static function onGetUserPermissionsErrors( Title $title, $user, 
$action, &$result ) {
                if ( $result === false ) {
                        return true; // nothing to do
                }
@@ -336,6 +336,20 @@
                                $result = false;
                                return false;
                        }
+                       # Respect page protection to handle cases of "review 
wars".
+                       # If a page is restricted from editing such that a user 
cannot
+                       # edit it, then said user should not be able to review 
it.
+                       foreach ( $title->getRestrictions( 'edit' ) as $right ) 
{
+                               // Backwards compatibility, rewrite sysop -> 
protect
+                               $right = ( $right === 'sysop' ) ? 'protect' : 
$right;
+                               if ( $right != '' && !$user->isAllowed( $right 
) ) {
+                                       // 'editprotected' bypasses this 
restriction
+                                       if ( !$user->isAllowed( 'editprotected' 
) ) {
+                                               $result = false;
+                                               return false;
+                                       }
+                               }
+                       }
                }
                return true;
        }

Modified: trunk/extensions/FlaggedRevs/business/RevisionReviewForm.php
===================================================================
--- trunk/extensions/FlaggedRevs/business/RevisionReviewForm.php        
2012-03-08 19:42:24 UTC (rev 113388)
+++ trunk/extensions/FlaggedRevs/business/RevisionReviewForm.php        
2012-03-08 19:42:54 UTC (rev 113389)
@@ -228,10 +228,7 @@
 
        public function isAllowed() {
                // Basic permission check
-               return ( $this->page
-                       && $this->page->userCan( 'review' )
-                       && $this->page->userCan( 'edit' )
-               );
+               return ( $this->page && $this->page->userCan( 'review' ) );
        }
 
        // implicit dims for binary flag case


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to