* part of bug 23119: removed WikiError stuff for Special:Userrights, also updated CentralAuth extension
* fixed E_NOTICE in Special:GlobalGroupMembership when the user cannot change global permissions
This commit is contained in:
parent
1b6fde57ed
commit
ce2e172307
2 changed files with 24 additions and 18 deletions
|
|
@ -117,10 +117,12 @@ class ApiUserrights extends ApiBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
$form = new UserrightsPage;
|
$form = new UserrightsPage;
|
||||||
$user = $form->fetchUser( $params['user'] );
|
$status = $form->fetchUser( $params['user'] );
|
||||||
if ( $user instanceof WikiErrorMsg ) {
|
if ( !$status->isOK() ) {
|
||||||
$this->dieUsageMsg( array_merge(
|
$errors = $status->getErrorsArray();
|
||||||
(array)$user->getMessageKey(), $user->getMessageArgs() ) );
|
$this->dieUsageMsg( $errors[0] );
|
||||||
|
} else {
|
||||||
|
$user = $status->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->mUser = $user;
|
$this->mUser = $user;
|
||||||
|
|
|
||||||
|
|
@ -141,10 +141,12 @@ class UserrightsPage extends SpecialPage {
|
||||||
function saveUserGroups( $username, $reason = '' ) {
|
function saveUserGroups( $username, $reason = '' ) {
|
||||||
global $wgRequest, $wgUser, $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf;
|
global $wgRequest, $wgUser, $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf;
|
||||||
|
|
||||||
$user = $this->fetchUser( $username );
|
$status = $this->fetchUser( $username );
|
||||||
if( $user instanceof WikiErrorMsg ) {
|
if( !$status->isOK() ) {
|
||||||
$wgOut->addWikiMsgArray( $user->getMessageKey(), $user->getMessageArgs() );
|
$wgOut->addWikiText( $status->getWikiText() );
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
$user = $status->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
$allgroups = $this->getAllGroups();
|
$allgroups = $this->getAllGroups();
|
||||||
|
|
@ -247,10 +249,12 @@ class UserrightsPage extends SpecialPage {
|
||||||
function editUserGroupsForm( $username ) {
|
function editUserGroupsForm( $username ) {
|
||||||
global $wgOut;
|
global $wgOut;
|
||||||
|
|
||||||
$user = $this->fetchUser( $username );
|
$status = $this->fetchUser( $username );
|
||||||
if( $user instanceof WikiErrorMsg ) {
|
if( !$status->isOK() ) {
|
||||||
$wgOut->addWikiMsgArray( $user->getMessageKey(), $user->getMessageArgs() );
|
$wgOut->addWikiText( $status->getWikiText() );
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
$user = $status->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
$groups = $user->getGroups();
|
$groups = $user->getGroups();
|
||||||
|
|
@ -267,7 +271,7 @@ class UserrightsPage extends SpecialPage {
|
||||||
* return a user (or proxy) object for manipulating it.
|
* return a user (or proxy) object for manipulating it.
|
||||||
*
|
*
|
||||||
* Side effects: error output for invalid access
|
* Side effects: error output for invalid access
|
||||||
* @return mixed User, UserRightsProxy, or WikiErrorMsg
|
* @return Status object
|
||||||
*/
|
*/
|
||||||
public function fetchUser( $username ) {
|
public function fetchUser( $username ) {
|
||||||
global $wgUser, $wgUserrightsInterwikiDelimiter;
|
global $wgUser, $wgUserrightsInterwikiDelimiter;
|
||||||
|
|
@ -283,16 +287,16 @@ class UserrightsPage extends SpecialPage {
|
||||||
$database = '';
|
$database = '';
|
||||||
} else {
|
} else {
|
||||||
if( !$wgUser->isAllowed( 'userrights-interwiki' ) ) {
|
if( !$wgUser->isAllowed( 'userrights-interwiki' ) ) {
|
||||||
return new WikiErrorMsg( 'userrights-no-interwiki' );
|
return Status::newFatal( 'userrights-no-interwiki' );
|
||||||
}
|
}
|
||||||
if( !UserRightsProxy::validDatabase( $database ) ) {
|
if( !UserRightsProxy::validDatabase( $database ) ) {
|
||||||
return new WikiErrorMsg( 'userrights-nodatabase', $database );
|
return Status::newFatal( 'userrights-nodatabase', $database );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( $name === '' ) {
|
if( $name === '' ) {
|
||||||
return new WikiErrorMsg( 'nouserspecified' );
|
return Status::newFatal( 'nouserspecified' );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( $name{0} == '#' ) {
|
if( $name{0} == '#' ) {
|
||||||
|
|
@ -307,13 +311,13 @@ class UserrightsPage extends SpecialPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !$name ) {
|
if( !$name ) {
|
||||||
return new WikiErrorMsg( 'noname' );
|
return Status::newFatal( 'noname' );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$name = User::getCanonicalName( $name );
|
$name = User::getCanonicalName( $name );
|
||||||
if( $name === false ) {
|
if( $name === false ) {
|
||||||
// invalid name
|
// invalid name
|
||||||
return new WikiErrorMsg( 'nosuchusershort', $username );
|
return Status::newFatal( 'nosuchusershort', $username );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -324,10 +328,10 @@ class UserrightsPage extends SpecialPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !$user || $user->isAnon() ) {
|
if( !$user || $user->isAnon() ) {
|
||||||
return new WikiErrorMsg( 'nosuchusershort', $username );
|
return Status::newFatal( 'nosuchusershort', $username );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $user;
|
return Status::newGood( $user );
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeGroupNameList( $ids ) {
|
function makeGroupNameList( $ids ) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue