Index: trunk/phase3/includes/Title.php |
— | — | @@ -1142,16 +1142,23 @@ |
1143 | 1143 | } |
1144 | 1144 | |
1145 | 1145 | /** |
1146 | | - * Determines if $wgUser is unable to edit this page because it has been protected |
| 1146 | + * Determines if $user is unable to edit this page because it has been protected |
1147 | 1147 | * by $wgNamespaceProtection. |
1148 | 1148 | * |
| 1149 | + * @param $user User object, $wgUser will be used if not passed |
1149 | 1150 | * @return \type{\bool} |
1150 | 1151 | */ |
1151 | | - public function isNamespaceProtected() { |
1152 | | - global $wgNamespaceProtection, $wgUser; |
| 1152 | + public function isNamespaceProtected( User $user = null ) { |
| 1153 | + global $wgNamespaceProtection; |
| 1154 | + |
| 1155 | + if ( $user === null ) { |
| 1156 | + global $wgUser; |
| 1157 | + $user = $wgUser; |
| 1158 | + } |
| 1159 | + |
1153 | 1160 | if ( isset( $wgNamespaceProtection[$this->mNamespace] ) ) { |
1154 | 1161 | foreach ( (array)$wgNamespaceProtection[$this->mNamespace] as $right ) { |
1155 | | - if ( $right != '' && !$wgUser->isAllowed( $right ) ) { |
| 1162 | + if ( $right != '' && !$user->isAllowed( $right ) ) { |
1156 | 1163 | return true; |
1157 | 1164 | } |
1158 | 1165 | } |
— | — | @@ -1352,7 +1359,7 @@ |
1353 | 1360 | } |
1354 | 1361 | |
1355 | 1362 | # Check $wgNamespaceProtection for restricted namespaces |
1356 | | - if ( $this->isNamespaceProtected() ) { |
| 1363 | + if ( $this->isNamespaceProtected( $user ) ) { |
1357 | 1364 | $ns = $this->mNamespace == NS_MAIN ? |
1358 | 1365 | wfMsg( 'nstab-main' ) : $this->getNsText(); |
1359 | 1366 | $errors[] = $this->mNamespace == NS_MEDIAWIKI ? |