Index: trunk/phase3/includes/ProtectionForm.php |
— | — | @@ -133,7 +133,7 @@ |
134 | 134 | // Prevent users from setting levels that they cannot later unset |
135 | 135 | if( $val == 'sysop' ) { |
136 | 136 | // Special case, rewrite sysop to either protect and editprotected |
137 | | - if( !$wgUser->isAllowed('protect') && !$wgUser->isAllowed('editprotected') ) |
| 137 | + if( !$wgUser->isAllowed( 'protect', 'editprotected' ) ) |
138 | 138 | continue; |
139 | 139 | } else { |
140 | 140 | if( !$wgUser->isAllowed($val) ) |
— | — | @@ -527,7 +527,7 @@ |
528 | 528 | //don't let them choose levels above their own (aka so they can still unprotect and edit the page). but only when the form isn't disabled |
529 | 529 | if( $key == 'sysop' ) { |
530 | 530 | //special case, rewrite sysop to protect and editprotected |
531 | | - if( !$wgUser->isAllowed('protect') && !$wgUser->isAllowed('editprotected') && !$this->disabled ) |
| 531 | + if( !$wgUser->isAllowed( 'protect', 'editprotected' ) && !$this->disabled ) |
532 | 532 | continue; |
533 | 533 | } else { |
534 | 534 | if( !$wgUser->isAllowed($key) && !$this->disabled ) |
Index: trunk/phase3/includes/User.php |
— | — | @@ -2245,10 +2245,39 @@ |
2246 | 2246 | |
2247 | 2247 | /** |
2248 | 2248 | * Check if user is allowed to access a feature / make an action |
2249 | | - * @param $action String action to be checked |
2250 | | - * @return Boolean: True if action is allowed, else false |
| 2249 | + * @param varargs String permissions to test |
| 2250 | + * @return Boolean: True if user is allowed to perform *any* of the given actions |
2251 | 2251 | */ |
2252 | | - function isAllowed( $action = '' ) { |
| 2252 | + public function isAllowed( /*...*/ ){ |
| 2253 | + $permissions = func_get_args(); |
| 2254 | + foreach( $permissions as $permission ){ |
| 2255 | + if( $this->isAllowedInternal( $permission ) ){ |
| 2256 | + return true; |
| 2257 | + } |
| 2258 | + } |
| 2259 | + return false; |
| 2260 | + } |
| 2261 | + |
| 2262 | + /** |
| 2263 | + * @param varargs String |
| 2264 | + * @return bool True if the user is allowed to perform *all* of the given actions |
| 2265 | + */ |
| 2266 | + public function isAllowedAll( /*...*/ ){ |
| 2267 | + $permissions = func_get_args(); |
| 2268 | + foreach( $permissions as $permission ){ |
| 2269 | + if( !$this->isAllowedInternal( $permission ) ){ |
| 2270 | + return false; |
| 2271 | + } |
| 2272 | + } |
| 2273 | + return true; |
| 2274 | + } |
| 2275 | + |
| 2276 | + /** |
| 2277 | + * Internal mechanics of testing a permission |
| 2278 | + * @param $action String |
| 2279 | + * @return bool |
| 2280 | + */ |
| 2281 | + private function isAllowedInternal( $action = '' ) { |
2253 | 2282 | if ( $action === '' ) { |
2254 | 2283 | return true; // In the spirit of DWIM |
2255 | 2284 | } |
— | — | @@ -2269,7 +2298,7 @@ |
2270 | 2299 | */ |
2271 | 2300 | public function useRCPatrol() { |
2272 | 2301 | global $wgUseRCPatrol; |
2273 | | - return( $wgUseRCPatrol && ( $this->isAllowed( 'patrol' ) || $this->isAllowed( 'patrolmarks' ) ) ); |
| 2302 | + return $wgUseRCPatrol && $this->isAllowedAny( 'patrol', 'patrolmarks' ); |
2274 | 2303 | } |
2275 | 2304 | |
2276 | 2305 | /** |
— | — | @@ -2278,7 +2307,7 @@ |
2279 | 2308 | */ |
2280 | 2309 | public function useNPPatrol() { |
2281 | 2310 | global $wgUseRCPatrol, $wgUseNPPatrol; |
2282 | | - return( ( $wgUseRCPatrol || $wgUseNPPatrol ) && ( $this->isAllowed( 'patrol' ) || $this->isAllowed( 'patrolmarks' ) ) ); |
| 2311 | + return( ( $wgUseRCPatrol || $wgUseNPPatrol ) && ( $this->isAllowedAny( 'patrol', 'patrolmarks' ) ) ); |
2283 | 2312 | } |
2284 | 2313 | |
2285 | 2314 | /** |
Index: trunk/phase3/includes/Article.php |
— | — | @@ -3458,7 +3458,7 @@ |
3459 | 3459 | $flags |= EDIT_MINOR; |
3460 | 3460 | } |
3461 | 3461 | |
3462 | | - if ( $bot && ( $wgUser->isAllowed( 'markbotedits' ) || $wgUser->isAllowed( 'bot' ) ) ) { |
| 3462 | + if ( $bot && ( $wgUser->isAllowed( 'markbotedits', 'bot' ) ) ) { |
3463 | 3463 | $flags |= EDIT_FORCE_BOT; |
3464 | 3464 | } |
3465 | 3465 | |
Index: trunk/phase3/includes/ImagePage.php |
— | — | @@ -930,7 +930,7 @@ |
931 | 931 | . $navLinks . "\n" |
932 | 932 | . Xml::openElement( 'table', array( 'class' => 'wikitable filehistory' ) ) . "\n" |
933 | 933 | . '<tr><td></td>' |
934 | | - . ( $this->current->isLocal() && ( $wgUser->isAllowed( 'delete' ) || $wgUser->isAllowed( 'deletedhistory' ) ) ? '<td></td>' : '' ) |
| 934 | + . ( $this->current->isLocal() && ( $wgUser->isAllowed( 'delete', 'deletedhistory' ) ) ? '<td></td>' : '' ) |
935 | 935 | . '<th>' . wfMsgHtml( 'filehist-datetime' ) . '</th>' |
936 | 936 | . ( $this->showThumb ? '<th>' . wfMsgHtml( 'filehist-thumb' ) . '</th>' : '' ) |
937 | 937 | . '<th>' . wfMsgHtml( 'filehist-dimensions' ) . '</th>' |
— | — | @@ -961,7 +961,7 @@ |
962 | 962 | $row = $selected = ''; |
963 | 963 | |
964 | 964 | // Deletion link |
965 | | - if ( $local && ( $wgUser->isAllowed( 'delete' ) || $wgUser->isAllowed( 'deletedhistory' ) ) ) { |
| 965 | + if ( $local && ( $wgUser->isAllowed( 'delete', 'deletedhistory' ) ) ) { |
966 | 966 | $row .= '<td>'; |
967 | 967 | # Link to remove from history |
968 | 968 | if ( $wgUser->isAllowed( 'delete' ) ) { |
Index: trunk/phase3/includes/HistoryPage.php |
— | — | @@ -510,7 +510,7 @@ |
511 | 511 | |
512 | 512 | $del = ''; |
513 | 513 | // Show checkboxes for each revision |
514 | | - if ( $wgUser->isAllowed( 'deleterevision' ) || $wgUser->isAllowed( 'revisionmove' ) ) { |
| 514 | + if ( $wgUser->isAllowed( 'deleterevision', 'revisionmove' ) ) { |
515 | 515 | $this->preventClickjacking(); |
516 | 516 | // If revision was hidden from sysops, disable the checkbox |
517 | 517 | // However, if the user has revisionmove rights, we cannot disable the checkbox |
Index: trunk/phase3/includes/api/ApiFileRevert.php |
— | — | @@ -78,7 +78,7 @@ |
79 | 79 | * @param $user User The user to check. |
80 | 80 | */ |
81 | 81 | protected function checkPermissions( $user ) { |
82 | | - $permission = $user->isAllowed( 'edit' ) && $user->isAllowed( 'upload' ); |
| 82 | + $permission = $user->isAllowedAll( 'edit', 'upload' ); |
83 | 83 | |
84 | 84 | if ( $permission !== true ) { |
85 | 85 | if ( !$user->isLoggedIn() ) { |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -1999,7 +1999,7 @@ |
2000 | 2000 | */ |
2001 | 2001 | public function userCanEditCssSubpage() { |
2002 | 2002 | global $wgUser; |
2003 | | - return ( ( $wgUser->isAllowed( 'editusercssjs' ) && $wgUser->isAllowed( 'editusercss' ) ) |
| 2003 | + return ( ( $wgUser->isAllowedAll( 'editusercssjs', 'editusercss' ) ) |
2004 | 2004 | || preg_match( '/^' . preg_quote( $wgUser->getName(), '/' ) . '\//', $this->mTextform ) ); |
2005 | 2005 | } |
2006 | 2006 | |
— | — | @@ -2012,7 +2012,7 @@ |
2013 | 2013 | */ |
2014 | 2014 | public function userCanEditJsSubpage() { |
2015 | 2015 | global $wgUser; |
2016 | | - return ( ( $wgUser->isAllowed( 'editusercssjs' ) && $wgUser->isAllowed( 'edituserjs' ) ) |
| 2016 | + return ( ( $wgUser->isAllowedAll( 'editusercssjs', 'edituserjs' ) ) |
2017 | 2017 | || preg_match( '/^' . preg_quote( $wgUser->getName(), '/' ) . '\//', $this->mTextform ) ); |
2018 | 2018 | } |
2019 | 2019 | |
Index: trunk/phase3/includes/specials/SpecialImport.php |
— | — | @@ -144,7 +144,7 @@ |
145 | 145 | |
146 | 146 | private function showForm() { |
147 | 147 | global $wgUser, $wgOut, $wgImportSources, $wgExportMaxLinkDepth; |
148 | | - if( !$wgUser->isAllowed( 'import' ) && !$wgUser->isAllowed( 'importupload' ) ) |
| 148 | + if( !$wgUser->isAllowed( 'import', 'importupload' ) ) |
149 | 149 | return $wgOut->permissionRequired( 'import' ); |
150 | 150 | |
151 | 151 | $action = $this->getTitle()->getLocalUrl( array( 'action' => 'submit' ) ); |