$flags |= EDIT_MINOR;
}
- if ( $bot && ( $wgUser->isAllowed( 'markbotedits' ) || $wgUser->isAllowed( 'bot' ) ) ) {
+ if ( $bot && ( $wgUser->isAllowed( 'markbotedits', 'bot' ) ) ) {
$flags |= EDIT_FORCE_BOT;
}
$del = '';
// Show checkboxes for each revision
- if ( $wgUser->isAllowed( 'deleterevision' ) || $wgUser->isAllowed( 'revisionmove' ) ) {
+ if ( $wgUser->isAllowed( 'deleterevision', 'revisionmove' ) ) {
$this->preventClickjacking();
// If revision was hidden from sysops, disable the checkbox
// However, if the user has revisionmove rights, we cannot disable the checkbox
. $navLinks . "\n"
. Xml::openElement( 'table', array( 'class' => 'wikitable filehistory' ) ) . "\n"
. '<tr><td></td>'
- . ( $this->current->isLocal() && ( $wgUser->isAllowed( 'delete' ) || $wgUser->isAllowed( 'deletedhistory' ) ) ? '<td></td>' : '' )
+ . ( $this->current->isLocal() && ( $wgUser->isAllowed( 'delete', 'deletedhistory' ) ) ? '<td></td>' : '' )
. '<th>' . wfMsgHtml( 'filehist-datetime' ) . '</th>'
. ( $this->showThumb ? '<th>' . wfMsgHtml( 'filehist-thumb' ) . '</th>' : '' )
. '<th>' . wfMsgHtml( 'filehist-dimensions' ) . '</th>'
$row = $selected = '';
// Deletion link
- if ( $local && ( $wgUser->isAllowed( 'delete' ) || $wgUser->isAllowed( 'deletedhistory' ) ) ) {
+ if ( $local && ( $wgUser->isAllowed( 'delete', 'deletedhistory' ) ) ) {
$row .= '<td>';
# Link to remove from history
if ( $wgUser->isAllowed( 'delete' ) ) {
// Prevent users from setting levels that they cannot later unset
if( $val == 'sysop' ) {
// Special case, rewrite sysop to either protect and editprotected
- if( !$wgUser->isAllowed('protect') && !$wgUser->isAllowed('editprotected') )
+ if( !$wgUser->isAllowed( 'protect', 'editprotected' ) )
continue;
} else {
if( !$wgUser->isAllowed($val) )
//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
if( $key == 'sysop' ) {
//special case, rewrite sysop to protect and editprotected
- if( !$wgUser->isAllowed('protect') && !$wgUser->isAllowed('editprotected') && !$this->disabled )
+ if( !$wgUser->isAllowed( 'protect', 'editprotected' ) && !$this->disabled )
continue;
} else {
if( !$wgUser->isAllowed($key) && !$this->disabled )
*/
public function userCanEditCssSubpage() {
global $wgUser;
- return ( ( $wgUser->isAllowed( 'editusercssjs' ) && $wgUser->isAllowed( 'editusercss' ) )
+ return ( ( $wgUser->isAllowedAll( 'editusercssjs', 'editusercss' ) )
|| preg_match( '/^' . preg_quote( $wgUser->getName(), '/' ) . '\//', $this->mTextform ) );
}
*/
public function userCanEditJsSubpage() {
global $wgUser;
- return ( ( $wgUser->isAllowed( 'editusercssjs' ) && $wgUser->isAllowed( 'edituserjs' ) )
+ return ( ( $wgUser->isAllowedAll( 'editusercssjs', 'edituserjs' ) )
|| preg_match( '/^' . preg_quote( $wgUser->getName(), '/' ) . '\//', $this->mTextform ) );
}
/**
* Check if user is allowed to access a feature / make an action
- * @param $action String action to be checked
- * @return Boolean: True if action is allowed, else false
+ * @param varargs String permissions to test
+ * @return Boolean: True if user is allowed to perform *any* of the given actions
*/
- function isAllowed( $action = '' ) {
+ public function isAllowed( /*...*/ ){
+ $permissions = func_get_args();
+ foreach( $permissions as $permission ){
+ if( $this->isAllowedInternal( $permission ) ){
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @param varargs String
+ * @return bool True if the user is allowed to perform *all* of the given actions
+ */
+ public function isAllowedAll( /*...*/ ){
+ $permissions = func_get_args();
+ foreach( $permissions as $permission ){
+ if( !$this->isAllowedInternal( $permission ) ){
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Internal mechanics of testing a permission
+ * @param $action String
+ * @return bool
+ */
+ private function isAllowedInternal( $action = '' ) {
if ( $action === '' ) {
return true; // In the spirit of DWIM
}
*/
public function useRCPatrol() {
global $wgUseRCPatrol;
- return( $wgUseRCPatrol && ( $this->isAllowed( 'patrol' ) || $this->isAllowed( 'patrolmarks' ) ) );
+ return $wgUseRCPatrol && $this->isAllowedAny( 'patrol', 'patrolmarks' );
}
/**
*/
public function useNPPatrol() {
global $wgUseRCPatrol, $wgUseNPPatrol;
- return( ( $wgUseRCPatrol || $wgUseNPPatrol ) && ( $this->isAllowed( 'patrol' ) || $this->isAllowed( 'patrolmarks' ) ) );
+ return( ( $wgUseRCPatrol || $wgUseNPPatrol ) && ( $this->isAllowedAny( 'patrol', 'patrolmarks' ) ) );
}
/**
* @param $user User The user to check.
*/
protected function checkPermissions( $user ) {
- $permission = $user->isAllowed( 'edit' ) && $user->isAllowed( 'upload' );
+ $permission = $user->isAllowedAll( 'edit', 'upload' );
if ( $permission !== true ) {
if ( !$user->isLoggedIn() ) {
private function showForm() {
global $wgUser, $wgOut, $wgImportSources, $wgExportMaxLinkDepth;
- if( !$wgUser->isAllowed( 'import' ) && !$wgUser->isAllowed( 'importupload' ) )
+ if( !$wgUser->isAllowed( 'import', 'importupload' ) )
return $wgOut->permissionRequired( 'import' );
$action = $this->getTitle()->getLocalUrl( array( 'action' => 'submit' ) );