Index: trunk/phase3/includes/Title.php |
— | — | @@ -1113,7 +1113,9 @@ |
1114 | 1114 | else if( $result === false ) |
1115 | 1115 | $errors[] = array('badaccess-group0'); # a generic "We don't want them to do that" |
1116 | 1116 | } |
1117 | | - if( $doExpensiveQueries && !wfRunHooks( 'getUserPermissionsErrorsExpensive', array(&$this,&$user,$action,&$result) ) ) { |
| 1117 | + if( $doExpensiveQueries && !wfRunHooks( 'getUserPermissionsErrorsExpensive', |
| 1118 | + array(&$this,&$user,$action,&$result) ) ) |
| 1119 | + { |
1118 | 1120 | if( is_array($result) && count($result) && !is_array($result[0]) ) |
1119 | 1121 | $errors[] = $result; # A single array representing an error |
1120 | 1122 | else if( is_array($result) && is_array($result[0]) ) |
— | — | @@ -1139,7 +1141,8 @@ |
1140 | 1142 | |
1141 | 1143 | # protect css/js subpages of user pages |
1142 | 1144 | # XXX: this might be better using restrictions |
1143 | | - # XXX: Find a way to work around the php bug that prevents using $this->userCanEditCssJsSubpage() from working |
| 1145 | + # XXX: Find a way to work around the php bug that prevents using |
| 1146 | + # $this->userCanEditCssJsSubpage() from working |
1144 | 1147 | if( $this->isCssJsSubpage() && !$user->isAllowed('editusercssjs') |
1145 | 1148 | && !preg_match('/^'.preg_quote($user->getName(), '/').'\//', $this->mTextform) ) |
1146 | 1149 | { |
— | — | @@ -1161,39 +1164,41 @@ |
1162 | 1165 | $right = ( $right == 'sysop' ) ? 'protect' : $right; |
1163 | 1166 | if( '' != $right && !$user->isAllowed( $right ) ) { |
1164 | 1167 | $pages = ''; |
1165 | | - foreach( $cascadingSources as $page ) |
| 1168 | + foreach( $cascadingSources as $page ) { |
1166 | 1169 | $pages .= '* [[:' . $page->getPrefixedText() . "]]\n"; |
| 1170 | + } |
1167 | 1171 | $errors[] = array( 'cascadeprotected', count( $cascadingSources ), $pages ); |
1168 | 1172 | } |
1169 | 1173 | } |
1170 | 1174 | } |
1171 | 1175 | } |
1172 | 1176 | |
1173 | | - foreach( $this->getRestrictions($action) as $right ) { |
1174 | | - // Backwards compatibility, rewrite sysop -> protect |
1175 | | - if( $right == 'sysop' ) { |
1176 | | - $right = 'protect'; |
1177 | | - } |
1178 | | - if( '' != $right && !$user->isAllowed( $right ) ) { |
1179 | | - // Users with 'editprotected' permission can edit protected pages |
1180 | | - if( $action=='edit' && $user->isAllowed( 'editprotected' ) ) { |
1181 | | - // Users with 'editprotected' permission cannot edit protected pages |
1182 | | - // with cascading option turned on. |
1183 | | - if( $this->mCascadeRestriction ) { |
| 1177 | + # Get restrictions on each action, 'create' handled below |
| 1178 | + if( $action != 'create' ) { |
| 1179 | + foreach( $this->getRestrictions($action) as $right ) { |
| 1180 | + // Backwards compatibility, rewrite sysop -> protect |
| 1181 | + if( $right == 'sysop' ) { |
| 1182 | + $right = 'protect'; |
| 1183 | + } |
| 1184 | + if( '' != $right && !$user->isAllowed( $right ) ) { |
| 1185 | + // Users with 'editprotected' permission can edit protected pages |
| 1186 | + if( $action=='edit' && $user->isAllowed( 'editprotected' ) ) { |
| 1187 | + // Users with 'editprotected' permission cannot edit protected pages |
| 1188 | + // with cascading option turned on. |
| 1189 | + if( $this->mCascadeRestriction ) { |
| 1190 | + $errors[] = array( 'protectedpagetext', $right ); |
| 1191 | + } else { |
| 1192 | + // Nothing, user can edit! |
| 1193 | + } |
| 1194 | + } else { |
1184 | 1195 | $errors[] = array( 'protectedpagetext', $right ); |
1185 | | - } else { |
1186 | | - // Nothing, user can edit! |
1187 | 1196 | } |
1188 | | - } else { |
1189 | | - $errors[] = array( 'protectedpagetext', $right ); |
1190 | 1197 | } |
1191 | 1198 | } |
1192 | 1199 | } |
1193 | 1200 | |
1194 | | - if( $action == 'protect' ) { |
1195 | | - if( $this->getUserPermissionsErrors('edit', $user) != array() ) { |
1196 | | - $errors[] = array( 'protect-cantedit' ); // If they can't edit, they shouldn't protect. |
1197 | | - } |
| 1201 | + if( $action == 'protect' && $this->getUserPermissionsErrors('edit',$user) != array() ) { |
| 1202 | + $errors[] = array( 'protect-cantedit' ); // If they can't edit, they shouldn't protect. |
1198 | 1203 | } |
1199 | 1204 | |
1200 | 1205 | if( $action == 'create' ) { |