public function execute( $par ) {
// If the visitor doesn't have permissions to assign or remove
// any groups, it's a bit silly to give them the user search prompt.
public function execute( $par ) {
// If the visitor doesn't have permissions to assign or remove
// any groups, it's a bit silly to give them the user search prompt.
/*
* If the user is blocked and they only have "partial" access
* (e.g. they don't have the userrights permission), then don't
* allow them to use Special:UserRights.
*/
/*
* If the user is blocked and they only have "partial" access
* (e.g. they don't have the userrights permission), then don't
* allow them to use Special:UserRights.
*/
- if( $wgUser->isBlocked() && !$wgUser->isAllowed( 'userrights' ) ) {
- $wgOut->blockedPage();
- return;
+ if( $user->isBlocked() && !$user->isAllowed( 'userrights' ) ) {
+ throw new UserBlockedError( $user->getBlock() );
+ }
+
+ $request = $this->getRequest();
+
+ if( $par !== null ) {
+ $this->mTarget = $par;
+ } else {
+ $this->mTarget = $request->getVal( 'user' );
- if( !$this->userCanChangeRights( $wgUser, true ) ) {
- // fixme... there may be intermediate groups we can mention.
- $wgOut->showPermissionsErrorPage( array( array(
- $wgUser->isAnon()
- ? 'userrights-nologin'
- : 'userrights-notallowed' ) ) );
- return;
+ if( !$this->userCanChangeRights( $user, true ) ) {
+ // @todo FIXME: There may be intermediate groups we can mention.
+ $msg = $user->isAnon() ? 'userrights-nologin' : 'userrights-notallowed';
+ throw new PermissionsError( null, array( array( $msg ) ) );
- if( $wgRequest->getCheck( 'saveusergroups' ) ) {
- $reason = $wgRequest->getVal( 'user-reason' );
- $tok = $wgRequest->getVal( 'wpEditToken' );
- if( $wgUser->matchEditToken( $tok, $this->mTarget ) ) {
+ if( $request->getCheck( 'saveusergroups' ) ) {
+ $reason = $request->getVal( 'user-reason' );
+ $tok = $request->getVal( 'wpEditToken' );
+ if( $user->matchEditToken( $tok, $this->mTarget ) ) {
foreach ( $allgroups as $group ) {
// We'll tell it to remove all unchecked groups, and add all checked groups.
// Later on, this gets filtered for what can actually be removed
foreach ( $allgroups as $group ) {
// We'll tell it to remove all unchecked groups, and add all checked groups.
// Later on, this gets filtered for what can actually be removed
* @return Array: Tuple of added, then removed groups
*/
function doSaveUserGroups( $user, $add, $remove, $reason = '' ) {
* @return Array: Tuple of added, then removed groups
*/
function doSaveUserGroups( $user, $add, $remove, $reason = '' ) {
$groups = $user->getGroups();
$changeable = $this->changeableGroups();
$addable = array_merge( $changeable['add'], $isself ? $changeable['add-self'] : array() );
$groups = $user->getGroups();
$changeable = $this->changeableGroups();
$addable = array_merge( $changeable['add'], $isself ? $changeable['add-self'] : array() );
$newGroups = array_merge( $newGroups, $add );
foreach( $add as $group ) {
$user->addGroup( $group );
$newGroups = array_merge( $newGroups, $add );
foreach( $add as $group ) {
$user->addGroup( $group );
// This isn't really ideal logging behavior, but let's not hide the
// interwiki logs if we're using them as is.
// This isn't really ideal logging behavior, but let's not hide the
// interwiki logs if we're using them as is.
$parts = explode( $wgUserrightsInterwikiDelimiter, $username );
if( count( $parts ) < 2 ) {
$parts = explode( $wgUserrightsInterwikiDelimiter, $username );
if( count( $parts ) < 2 ) {
return Status::newFatal( 'userrights-no-interwiki' );
}
if( !UserRightsProxy::validDatabase( $database ) ) {
return Status::newFatal( 'userrights-no-interwiki' );
}
if( !UserRightsProxy::validDatabase( $database ) ) {
// Numeric ID can be specified...
// We'll do a lookup for the name internally.
$id = intval( substr( $name, 1 ) );
// Numeric ID can be specified...
// We'll do a lookup for the name internally.
$id = intval( substr( $name, 1 ) );
Html::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'name' => 'uluser', 'id' => 'mw-userrights-form1' ) ) .
Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
Xml::fieldset( wfMsg( 'userrights-lookup-user' ) ) .
Html::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'name' => 'uluser', 'id' => 'mw-userrights-form1' ) ) .
Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
Xml::fieldset( wfMsg( 'userrights-lookup-user' ) ) .
* @param $groups Array: Array of groups the user is in
*/
protected function showEditUserGroupsForm( $user, $groups ) {
* @param $groups Array: Array of groups the user is in
*/
protected function showEditUserGroupsForm( $user, $groups ) {
- if( count( $list ) > 0 ) {
- $grouplist = wfMsgHtml( 'userrights-groupsmember' );
- $grouplist = '<p>' . $grouplist . ' ' . $wgLang->listToText( $list ) . "</p>\n";
+ $count = count( $list );
+ if( $count > 0 ) {
+ $grouplist = wfMessage( 'userrights-groupsmember', $count)->parse();
+ $grouplist = '<p>' . $grouplist . ' ' . $this->getLanguage()->listToText( $list ) . "</p>\n";
- if( count( $autolist ) > 0 ) {
- $autogrouplistintro = wfMsgHtml( 'userrights-groupsmember-auto' );
- $grouplist .= '<p>' . $autogrouplistintro . ' ' . $wgLang->listToText( $autolist ) . "</p>\n";
+ $count = count( $autolist );
+ if( $count > 0 ) {
+ $autogrouplistintro = wfMessage( 'userrights-groupsmember-auto', $count)->parse();
+ $grouplist .= '<p>' . $autogrouplistintro . ' ' . $this->getLanguage()->listToText( $autolist ) . "</p>\n";
+
+ $userToolLinks = Linker::userToolLinks(
+ $user->getId(),
+ $user->getName(),
+ false, /* default for redContribsWhenNoEdits */
+ Linker::TOOL_LINKS_EMAIL /* Add "send e-mail" link */
+ );
+
+ $this->getOutput()->addHTML(
Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getTitle()->getLocalURL(), 'name' => 'editGroup', 'id' => 'mw-userrights-form2' ) ) .
Html::hidden( 'user', $this->mTarget ) .
Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getTitle()->getLocalURL(), 'name' => 'editGroup', 'id' => 'mw-userrights-form2' ) ) .
Html::hidden( 'user', $this->mTarget ) .
- Xml::element( 'legend', array(), wfMsg( 'userrights-editusergroup' ) ) .
- wfMsgExt( 'editinguser', array( 'parse' ), wfEscapeWikiText( $user->getName() ) ) .
- wfMsgExt( 'userrights-groups-help', array( 'parse' ) ) .
+ Xml::element( 'legend', array(), wfMessage( 'userrights-editusergroup', $user->getName() )->text() ) .
+ wfMessage( 'editinguser' )->params( wfEscapeWikiText( $user->getName() ) )->rawParams( $userToolLinks )->parse() .
+ wfMessage( 'userrights-groups-help', $user->getName() )->parse() .
- Xml::tags( 'p', null, $this->groupCheckboxes( $groups ) ) .
+ Xml::tags( 'p', null, $this->groupCheckboxes( $groups, $user ) ) .
Xml::openElement( 'table', array( 'border' => '0', 'id' => 'mw-userrights-table-outer' ) ) .
"<tr>
<td class='mw-label'>" .
Xml::label( wfMsg( 'userrights-reason' ), 'wpReason' ) .
"</td>
<td class='mw-input'>" .
Xml::openElement( 'table', array( 'border' => '0', 'id' => 'mw-userrights-table-outer' ) ) .
"<tr>
<td class='mw-label'>" .
Xml::label( wfMsg( 'userrights-reason' ), 'wpReason' ) .
"</td>
<td class='mw-input'>" .
- Xml::input( 'user-reason', 60, false, array( 'id' => 'wpReason', 'maxlength' => 255 ) ) .
+ Xml::input( 'user-reason', 60, $this->getRequest()->getVal( 'user-reason', false ),
+ array( 'id' => 'wpReason', 'maxlength' => 255 ) ) .
"</td>
</tr>
<tr>
<td></td>
<td class='mw-submit'>" .
Xml::submitButton( wfMsg( 'saveusergroups' ),
"</td>
</tr>
<tr>
<td></td>
<td class='mw-submit'>" .
Xml::submitButton( wfMsg( 'saveusergroups' ),
- $ret .= Xml::element( 'th', null, wfMsg( 'userrights-' . $name . '-col' ) );
+ $ret .= Xml::element( 'th', null, wfMessage( 'userrights-' . $name . '-col', count( $column ) )->text() );
foreach( $column as $group => $checkbox ) {
$attr = $checkbox['disabled'] ? array( 'disabled' => 'disabled' ) : array();
foreach( $column as $group => $checkbox ) {
$attr = $checkbox['disabled'] ? array( 'disabled' => 'disabled' ) : array();
}
$checkboxHtml = Xml::checkLabel( $text, "wpGroup-" . $group,
"wpGroup-" . $group, $checkbox['set'], $attr );
}
$checkboxHtml = Xml::checkLabel( $text, "wpGroup-" . $group,
"wpGroup-" . $group, $checkbox['set'], $attr );
*
* @return Array array( 'add' => array( addablegroups ), 'remove' => array( removablegroups ) , 'add-self' => array( addablegroups to self), 'remove-self' => array( removable groups from self) )
*/
function changeableGroups() {
*
* @return Array array( 'add' => array( addablegroups ), 'remove' => array( removablegroups ) , 'add-self' => array( addablegroups to self), 'remove-self' => array( removable groups from self) )
*/
function changeableGroups() {
*/
protected function showLogFragment( $user, $output ) {
$output->addHTML( Xml::element( 'h2', null, LogPage::logName( 'rights' ) . "\n" ) );
*/
protected function showLogFragment( $user, $output ) {
$output->addHTML( Xml::element( 'h2', null, LogPage::logName( 'rights' ) . "\n" ) );