Note that restrictions are rights, not groups. So now, cascading protection will...
[lhc/web/wiklou.git] / includes / Title.php
index 49c0780..616cc3d 100644 (file)
@@ -1219,15 +1219,10 @@ class Title {
                                $right = 'protect';
                        }
                        if( '' != $right && !$user->isAllowed( $right ) ) {
-                               //Users with 'editprotected' permission can edit protected pages
-                               if( $action=='edit' && $user->isAllowed( 'editprotected' ) ) {
-                                       //Users with 'editprotected' permission cannot edit protected pages
-                                       //with cascading option turned on.
-                                       if($this->mCascadeRestriction) {
-                                               $errors[] = array( 'protectedpagetext', $right );
-                                       } else {
-                                               //Nothing, user can edit!
-                                       }
+                               // Users with 'editprotected' permission can edit protected
+                               // pages if protection is not with cascading option turned on.
+                               if( $action=='edit' && $user->isAllowed( 'editprotected' ) && !$this->areRestrictionsCascading() ) {
+                                       // Nothing, user can edit!
                                } else {
                                        $errors[] = array( 'protectedpagetext', $right );
                                }
@@ -1611,16 +1606,13 @@ class Title {
         * The restriction array is an array of each type, each of which contains an array of unique groups
         */
        public function getCascadeProtectionSources( $get_pages = true ) {
-               global $wgEnableCascadingProtection, $wgRestrictionTypes;
+               global $wgRestrictionTypes;
 
                # Define our dimension of restrictions types
                $pagerestrictions = array();
                foreach( $wgRestrictionTypes as $action )
                        $pagerestrictions[$action] = array();
 
-               if (!$wgEnableCascadingProtection)
-                       return array( false, $pagerestrictions );
-
                if ( isset( $this->mCascadeSources ) && $get_pages ) {
                        return array( $this->mCascadeSources, $this->mCascadingRestrictions );
                } else if ( isset( $this->mHasCascadingRestrictions ) && !$get_pages ) {
@@ -1629,7 +1621,7 @@ class Title {
 
                wfProfileIn( __METHOD__ );
 
-               $dbr = wfGetDb( DB_SLAVE );
+               $dbr = wfGetDB( DB_SLAVE );
 
                if ( $this->getNamespace() == NS_IMAGE ) {
                        $tables = array ('imagelinks', 'page_restrictions');
@@ -1930,7 +1922,7 @@ class Title {
                if ($this->mLatestID !== false)
                        return $this->mLatestID;
 
-               $db = ($flags & GAID_FOR_UPDATE) ? wfGetDB(DB_MASTER) : wfGetDB(DB_SLAVE);
+               $db = ($flags & GAID_FOR_UPDATE) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
                return $this->mLatestID = $db->selectField( 'revision',
                        "max(rev_id)",
                        array('rev_page' => $this->getArticleID($flags)),