}
$fetchedStatus = $this->fetchUser( $this->mTarget );
- if ( $fetchedStatus->isOk() ) {
+ if ( $fetchedStatus->isOK() ) {
$this->mFetchedUser = $fetchedStatus->value;
if ( $this->mFetchedUser instanceof User ) {
// Set the 'relevant user' in the skin, so it displays links like Contributions,
// @todo FIXME: There may be intermediate groups we can mention.
$msg = $user->isAnon() ? 'userrights-nologin' : 'userrights-notallowed';
- throw new PermissionsError( null, array( array( $msg ) ) );
+ throw new PermissionsError( null, [ [ $msg ] ] );
}
// show a successbox, if the user rights was saved successfully
if ( $request->getCheck( 'success' ) && $this->mFetchedUser !== null ) {
$out->wrapWikiMsg(
"<div class=\"successbox\">\n$1\n</div>",
- array( 'savedrights', $this->mFetchedUser->getName() )
+ [ 'savedrights', $this->mFetchedUser->getName() ]
);
}
}
function getSuccessURL() {
- return $this->getPageTitle( $this->mTarget )->getFullURL( array( 'success' => 1 ) );
+ return $this->getPageTitle( $this->mTarget )->getFullURL( [ 'success' => 1 ] );
}
/**
*/
function saveUserGroups( $username, $reason, $user ) {
$allgroups = $this->getAllGroups();
- $addgroup = array();
- $removegroup = array();
+ $addgroup = [];
+ $removegroup = [];
// This could possibly create a highly unlikely race condition if permissions are changed between
// when the form is loaded and when the form is saved. Ignoring it for the moment.
$isself = $user->getName() == $this->getUser()->getName();
$groups = $user->getGroups();
$changeable = $this->changeableGroups();
- $addable = array_merge( $changeable['add'], $isself ? $changeable['add-self'] : array() );
- $removable = array_merge( $changeable['remove'], $isself ? $changeable['remove-self'] : array() );
+ $addable = array_merge( $changeable['add'], $isself ? $changeable['add-self'] : [] );
+ $removable = array_merge( $changeable['remove'], $isself ? $changeable['remove-self'] : [] );
$remove = array_unique(
array_intersect( (array)$remove, $removable, $groups ) );
$user->invalidateCache();
// update groups in external authentication database
- Hooks::run( 'UserGroupsChanged', array( $user, $add, $remove, $this->getUser() ) );
+ Hooks::run( 'UserGroupsChanged', [ $user, $add, $remove, $this->getUser(), $reason ] );
$wgAuth->updateExternalDBGroups( $user, $add, $remove );
wfDebug( 'oldGroups: ' . print_r( $oldGroups, true ) . "\n" );
wfDebug( 'newGroups: ' . print_r( $newGroups, true ) . "\n" );
// Deprecated in favor of UserGroupsChanged hook
- Hooks::run( 'UserRights', array( &$user, $add, $remove ), '1.26' );
+ Hooks::run( 'UserRights', [ &$user, $add, $remove ], '1.26' );
if ( $newGroups != $oldGroups ) {
$this->addLogEntry( $user, $oldGroups, $newGroups, $reason );
}
- return array( $add, $remove );
+ return [ $add, $remove ];
}
/**
$logEntry->setPerformer( $this->getUser() );
$logEntry->setTarget( $user->getUserPage() );
$logEntry->setComment( $reason );
- $logEntry->setParameters( array(
+ $logEntry->setParameters( [
'4::oldgroups' => $oldGroups,
'5::newgroups' => $newGroups,
- ) );
+ ] );
$logid = $logEntry->insert();
$logEntry->publish( $logid );
}
}
}
- /**
- * Make a list of group names to be stored as parameter for log entries
- *
- * @deprecated since 1.21; use LogFormatter instead.
- * @param array $ids
- * @return string
- */
- function makeGroupNameListForLog( $ids ) {
- wfDeprecated( __METHOD__, '1.21' );
-
- if ( empty( $ids ) ) {
- return '';
- } else {
- return $this->makeGroupNameList( $ids );
- }
- }
-
/**
* Output a form to allow searching for a user
*/
$this->getOutput()->addHTML(
Html::openElement(
'form',
- array(
+ [
'method' => 'get',
'action' => wfScript(),
'name' => 'uluser',
'id' => 'mw-userrights-form1'
- )
+ ]
) .
Html::hidden( 'title', $this->getPageTitle()->getPrefixedText() ) .
Xml::fieldset( $this->msg( 'userrights-lookup-user' )->text() ) .
'username',
30,
str_replace( '_', ' ', $this->mTarget ),
- array(
+ [
'class' => 'mw-autocomplete-user', // used by mediawiki.userSuggest
- ) + (
+ ] + (
// Set autofocus on blank input and error input
- $this->mFetchedUser === null ? array( 'autofocus' => '' ) : array()
+ $this->mFetchedUser === null ? [ 'autofocus' => '' ] : []
)
) . ' ' .
Xml::submitButton(
list( $addable, $removable, $addself, $removeself ) = array_values( $this->changeableGroups() );
$removable = array_intersect(
- array_merge( $this->isself ? $removeself : array(), $removable ),
+ array_merge( $this->isself ? $removeself : [], $removable ),
$groups
); // Can't remove groups the user doesn't have
$addable = array_diff(
- array_merge( $this->isself ? $addself : array(), $addable ),
+ array_merge( $this->isself ? $addself : [], $addable ),
$groups
); // Can't add groups the user does have
- return array( $addable, $removable );
+ return [ $addable, $removable ];
}
/**
* @param array $groups Array of groups the user is in
*/
protected function showEditUserGroupsForm( $user, $groups ) {
- $list = array();
- $membersList = array();
+ $list = [];
+ $membersList = [];
foreach ( $groups as $group ) {
$list[] = self::buildGroupLink( $group );
$membersList[] = self::buildGroupMemberLink( $group );
}
- $autoList = array();
- $autoMembersList = array();
+ $autoList = [];
+ $autoMembersList = [];
if ( $user instanceof User ) {
foreach ( Autopromote::getAutopromoteGroups( $user ) as $group ) {
$autoList[] = self::buildGroupLink( $group );
$this->getOutput()->addHTML(
Xml::openElement(
'form',
- array(
+ [
'method' => 'post',
'action' => $this->getPageTitle()->getLocalURL(),
'name' => 'editGroup',
'id' => 'mw-userrights-form2'
- )
+ ]
) .
Html::hidden( 'user', $this->mTarget ) .
Html::hidden( 'wpEditToken', $this->getUser()->getEditToken( $this->mTarget ) ) .
Xml::openElement( 'fieldset' ) .
Xml::element(
'legend',
- array(),
+ [],
$this->msg( 'userrights-editusergroup', $user->getName() )->text()
) .
$this->msg( 'editinguser' )->params( wfEscapeWikiText( $user->getName() ) )
$this->msg( 'userrights-groups-help', $user->getName() )->parse() .
$grouplist .
$this->groupCheckboxes( $groups, $user ) .
- Xml::openElement( 'table', array( 'id' => 'mw-userrights-table-outer' ) ) .
+ Xml::openElement( 'table', [ 'id' => 'mw-userrights-table-outer' ] ) .
"<tr>
<td class='mw-label'>" .
Xml::label( $this->msg( 'userrights-reason' )->text(), 'wpReason' ) .
"</td>
<td class='mw-input'>" .
Xml::input( 'user-reason', 60, $this->getRequest()->getVal( 'user-reason', false ),
- array( 'id' => 'wpReason', 'maxlength' => 255 ) ) .
+ [ 'id' => 'wpReason', 'maxlength' => 255 ] ) .
"</td>
</tr>
<tr>
<td></td>
<td class='mw-submit'>" .
Xml::submitButton( $this->msg( 'saveusergroups', $user->getName() )->text(),
- array( 'name' => 'saveusergroups' ) +
+ [ 'name' => 'saveusergroups' ] +
Linker::tooltipAndAccesskeyAttribs( 'userrights-set' )
) .
"</td>
* @return string
*/
private static function buildGroupLink( $group ) {
- return User::makeGroupLinkHtml( $group, User::getGroupName( $group ) );
+ return User::makeGroupLinkHTML( $group, User::getGroupName( $group ) );
}
/**
* @return string
*/
private static function buildGroupMemberLink( $group ) {
- return User::makeGroupLinkHtml( $group, User::getGroupMember( $group ) );
+ return User::makeGroupLinkHTML( $group, User::getGroupMember( $group ) );
}
/**
// Put all column info into an associative array so that extensions can
// more easily manage it.
- $columns = array( 'unchangeable' => array(), 'changeable' => array() );
+ $columns = [ 'unchangeable' => [], 'changeable' => [] ];
foreach ( $allgroups as $group ) {
$set = in_array( $group, $usergroups );
( $set && !$this->canAdd( $group ) ) ||
( !$set && !$this->canRemove( $group ) ) );
- $checkbox = array(
+ $checkbox = [
'set' => $set,
'disabled' => $disabled,
'irreversible' => $irreversible
- );
+ ];
if ( $disabled ) {
$columns['unchangeable'][$group] = $checkbox;
}
// Build the HTML table
- $ret .= Xml::openElement( 'table', array( 'class' => 'mw-userrights-groups' ) ) .
+ $ret .= Xml::openElement( 'table', [ 'class' => 'mw-userrights-groups' ] ) .
"<tr>\n";
foreach ( $columns as $name => $column ) {
- if ( $column === array() ) {
+ if ( $column === [] ) {
continue;
}
// Messages: userrights-changeable-col, userrights-unchangeable-col
$ret .= "</tr>\n<tr>\n";
foreach ( $columns as $column ) {
- if ( $column === array() ) {
+ if ( $column === [] ) {
continue;
}
$ret .= "\t<td style='vertical-align:top;'>\n";
foreach ( $column as $group => $checkbox ) {
- $attr = $checkbox['disabled'] ? array( 'disabled' => 'disabled' ) : array();
+ $attr = $checkbox['disabled'] ? [ 'disabled' => 'disabled' ] : [];
$member = User::getGroupMember( $group, $user->getName() );
if ( $checkbox['irreversible'] ) {
$checkboxHtml = Xml::checkLabel( $text, "wpGroup-" . $group,
"wpGroup-" . $group, $checkbox['set'], $attr );
$ret .= "\t\t" . ( $checkbox['disabled']
- ? Xml::tags( 'span', array( 'class' => 'mw-userrights-disabled' ), $checkboxHtml )
+ ? Xml::tags( 'span', [ 'class' => 'mw-userrights-disabled' ], $checkboxHtml )
: $checkboxHtml
) . "<br />\n";
}
$user = User::newFromName( $search );
if ( !$user ) {
// No prefix suggestion for invalid user
- return array();
+ return [];
}
// Autocomplete subpage as user list - public to allow caching
return UserNamePrefixSearch::search( 'public', $search, $limit, $offset );