summaryrefslogtreecommitdiff
path: root/includes/specials/SpecialUserrights.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2014-12-27 15:41:37 +0100
committerPierre Schmitz <pierre@archlinux.de>2014-12-31 11:43:28 +0100
commitc1f9b1f7b1b77776192048005dcc66dcf3df2bfb (patch)
tree2b38796e738dd74cb42ecd9bfd151803108386bc /includes/specials/SpecialUserrights.php
parentb88ab0086858470dd1f644e64cb4e4f62bb2be9b (diff)
Update to MediaWiki 1.24.1
Diffstat (limited to 'includes/specials/SpecialUserrights.php')
-rw-r--r--includes/specials/SpecialUserrights.php165
1 files changed, 115 insertions, 50 deletions
diff --git a/includes/specials/SpecialUserrights.php b/includes/specials/SpecialUserrights.php
index 4501736f..cefdad07 100644
--- a/includes/specials/SpecialUserrights.php
+++ b/includes/specials/SpecialUserrights.php
@@ -55,6 +55,7 @@ class UserrightsPage extends SpecialPage {
if ( $user->getId() == 0 ) {
return false;
}
+
return !empty( $available['add'] )
|| !empty( $available['remove'] )
|| ( ( $this->isself || !$checkIfSelf ) &&
@@ -66,7 +67,7 @@ class UserrightsPage extends SpecialPage {
* Manage forms to be shown according to posted data.
* Depending on the submit button used, call a form or a save function.
*
- * @param $par Mixed: string if any subpage provided, else null
+ * @param string|null $par String if any subpage provided, else null
* @throws UserBlockedError|PermissionsError
*/
public function execute( $par ) {
@@ -118,6 +119,7 @@ class UserrightsPage extends SpecialPage {
$out = $this->getOutput();
$out->wrapWikiMsg( "<div class=\"successbox\">\n$1\n</div>", 'userrights-removed-self' );
$out->returnToMain();
+
return;
}
@@ -148,12 +150,18 @@ class UserrightsPage extends SpecialPage {
$status = $this->fetchUser( $this->mTarget );
if ( !$status->isOK() ) {
$this->getOutput()->addWikiText( $status->getWikiText() );
+
return;
}
$targetUser = $status->value;
+ if ( $targetUser instanceof User ) { // UserRightsProxy doesn't have this method (bug 61252)
+ $targetUser->clearInstanceCache(); // bug 38989
+ }
- if ( $request->getVal( 'conflictcheck-originalgroups' ) !== implode( ',', $targetUser->getGroups() ) ) {
+ if ( $request->getVal( 'conflictcheck-originalgroups' )
+ !== implode( ',', $targetUser->getGroups() )
+ ) {
$out->addWikiMsg( 'userrights-conflict' );
} else {
$this->saveUserGroups(
@@ -163,6 +171,7 @@ class UserrightsPage extends SpecialPage {
);
$out->redirect( $this->getSuccessURL() );
+
return;
}
}
@@ -174,15 +183,15 @@ class UserrightsPage extends SpecialPage {
}
function getSuccessURL() {
- return $this->getTitle( $this->mTarget )->getFullURL( array( 'success' => 1 ) );
+ return $this->getPageTitle( $this->mTarget )->getFullURL( array( 'success' => 1 ) );
}
/**
* Save user groups changes in the database.
* Data comes from the editUserGroupsForm() form function
*
- * @param string $username username to apply changes to.
- * @param string $reason reason for group change
+ * @param string $username Username to apply changes to.
+ * @param string $reason Reason for group change
* @param User|UserRightsProxy $user Target user object.
* @return null
*/
@@ -209,11 +218,11 @@ class UserrightsPage extends SpecialPage {
/**
* Save user groups changes in the database.
*
- * @param $user User object
- * @param array $add of groups to add
- * @param array $remove of groups to remove
- * @param string $reason reason for group change
- * @return Array: Tuple of added, then removed groups
+ * @param User $user
+ * @param array $add Array of groups to add
+ * @param array $remove Array of groups to remove
+ * @param string $reason Reason for group change
+ * @return array Tuple of added, then removed groups
*/
function doSaveUserGroups( $user, $add, $remove, $reason = '' ) {
global $wgAuth;
@@ -256,18 +265,23 @@ class UserrightsPage extends SpecialPage {
// update groups in external authentication database
$wgAuth->updateExternalDBGroups( $user, $add, $remove );
- wfDebug( 'oldGroups: ' . print_r( $oldGroups, true ) );
- wfDebug( 'newGroups: ' . print_r( $newGroups, true ) );
+ wfDebug( 'oldGroups: ' . print_r( $oldGroups, true ) . "\n" );
+ wfDebug( 'newGroups: ' . print_r( $newGroups, true ) . "\n" );
wfRunHooks( 'UserRights', array( &$user, $add, $remove ) );
if ( $newGroups != $oldGroups ) {
$this->addLogEntry( $user, $oldGroups, $newGroups, $reason );
}
+
return array( $add, $remove );
}
/**
* Add a rights log entry for an action.
+ * @param User $user
+ * @param array $oldGroups
+ * @param array $newGroups
+ * @param array $reason
*/
function addLogEntry( $user, $oldGroups, $newGroups, $reason ) {
$logEntry = new ManualLogEntry( 'rights', 'rights' );
@@ -284,12 +298,13 @@ class UserrightsPage extends SpecialPage {
/**
* Edit user groups membership
- * @param string $username name of the user.
+ * @param string $username Name of the user.
*/
function editUserGroupsForm( $username ) {
$status = $this->fetchUser( $username );
if ( !$status->isOK() ) {
$this->getOutput()->addWikiText( $status->getWikiText() );
+
return;
} else {
$user = $status->value;
@@ -310,12 +325,10 @@ class UserrightsPage extends SpecialPage {
*
* Side effects: error output for invalid access
* @param string $username
- * @return Status object
+ * @return Status
*/
public function fetchUser( $username ) {
- global $wgUserrightsInterwikiDelimiter;
-
- $parts = explode( $wgUserrightsInterwikiDelimiter, $username );
+ $parts = explode( $this->getConfig()->get( 'UserrightsInterwikiDelimiter' ), $username );
if ( count( $parts ) < 2 ) {
$name = trim( $username );
$database = '';
@@ -384,8 +397,8 @@ class UserrightsPage extends SpecialPage {
/**
* Make a list of group names to be stored as parameter for log entries
*
- * @deprecated in 1.21; use LogFormatter instead.
- * @param $ids array
+ * @deprecated since 1.21; use LogFormatter instead.
+ * @param array $ids
* @return string
*/
function makeGroupNameListForLog( $ids ) {
@@ -402,12 +415,26 @@ class UserrightsPage extends SpecialPage {
* Output a form to allow searching for a user
*/
function switchForm() {
- global $wgScript;
$this->getOutput()->addHTML(
- Html::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'name' => 'uluser', 'id' => 'mw-userrights-form1' ) ) .
- Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
+ 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() ) .
- Xml::inputLabel( $this->msg( 'userrights-user-editname' )->text(), 'user', 'username', 30, str_replace( '_', ' ', $this->mTarget ), array( 'autofocus' => true ) ) . ' ' .
+ Xml::inputLabel(
+ $this->msg( 'userrights-user-editname' )->text(),
+ 'user',
+ 'username',
+ 30,
+ str_replace( '_', ' ', $this->mTarget ),
+ array( 'autofocus' => true )
+ ) . ' ' .
Xml::submitButton( $this->msg( 'editusergroup' )->text() ) .
Html::closeElement( 'fieldset' ) .
Html::closeElement( 'form' ) . "\n"
@@ -419,8 +446,8 @@ class UserrightsPage extends SpecialPage {
* form will be able to manipulate based on the current user's system
* permissions.
*
- * @param array $groups list of groups the given user is in
- * @return Array: Tuple of addable, then removable groups
+ * @param array $groups List of groups the given user is in
+ * @return array Tuple of addable, then removable groups
*/
protected function splitGroups( $groups ) {
list( $addable, $removable, $addself, $removeself ) = array_values( $this->changeableGroups() );
@@ -440,8 +467,8 @@ class UserrightsPage extends SpecialPage {
/**
* Show the form to edit group memberships.
*
- * @param $user User or UserRightsProxy you're editing
- * @param $groups Array: Array of groups the user is in
+ * @param User|UserRightsProxy $user User or UserRightsProxy you're editing
+ * @param array $groups Array of groups the user is in
*/
protected function showEditUserGroupsForm( $user, $groups ) {
$list = array();
@@ -476,30 +503,48 @@ class UserrightsPage extends SpecialPage {
$grouplist = $this->msg( 'userrights-groupsmember', $count, $user->getName() )->parse();
$grouplist = '<p>' . $grouplist . ' ' . $displayedList . "</p>\n";
}
+
$count = count( $autoList );
if ( $count > 0 ) {
- $autogrouplistintro = $this->msg( 'userrights-groupsmember-auto', $count, $user->getName() )->parse();
+ $autogrouplistintro = $this->msg( 'userrights-groupsmember-auto', $count, $user->getName() )
+ ->parse();
$grouplist .= '<p>' . $autogrouplistintro . ' ' . $displayedAutolist . "</p>\n";
}
$userToolLinks = Linker::userToolLinks(
- $user->getId(),
- $user->getName(),
- false, /* default for redContribsWhenNoEdits */
- Linker::TOOL_LINKS_EMAIL /* Add "send e-mail" link */
+ $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' ) ) .
+ 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 ) ) .
- Html::hidden( 'conflictcheck-originalgroups', implode( ',', $user->getGroups() ) ) . // Conflict detection
+ Html::hidden(
+ 'conflictcheck-originalgroups',
+ implode( ',', $user->getGroups() )
+ ) . // Conflict detection
Xml::openElement( 'fieldset' ) .
- Xml::element( 'legend', array(), $this->msg( 'userrights-editusergroup', $user->getName() )->text() ) .
- $this->msg( 'editinguser' )->params( wfEscapeWikiText( $user->getName() ) )->rawParams( $userToolLinks )->parse() .
+ Xml::element(
+ 'legend',
+ array(),
+ $this->msg( 'userrights-editusergroup', $user->getName() )->text()
+ ) .
+ $this->msg( 'editinguser' )->params( wfEscapeWikiText( $user->getName() ) )
+ ->rawParams( $userToolLinks )->parse() .
$this->msg( 'userrights-groups-help', $user->getName() )->parse() .
$grouplist .
- Xml::tags( 'p', null, $this->groupCheckboxes( $groups, $user ) ) .
+ $this->groupCheckboxes( $groups, $user ) .
Xml::openElement( 'table', array( 'id' => 'mw-userrights-table-outer' ) ) .
"<tr>
<td class='mw-label'>" .
@@ -514,7 +559,9 @@ class UserrightsPage extends SpecialPage {
<td></td>
<td class='mw-submit'>" .
Xml::submitButton( $this->msg( 'saveusergroups' )->text(),
- array( 'name' => 'saveusergroups' ) + Linker::tooltipAndAccesskeyAttribs( 'userrights-set' ) ) .
+ array( 'name' => 'saveusergroups' ) +
+ Linker::tooltipAndAccesskeyAttribs( 'userrights-set' )
+ ) .
"</td>
</tr>" .
Xml::closeElement( 'table' ) . "\n" .
@@ -526,7 +573,7 @@ class UserrightsPage extends SpecialPage {
/**
* Format a link to a group description page
*
- * @param $group string
+ * @param string $group
* @return string
*/
private static function buildGroupLink( $group ) {
@@ -536,7 +583,7 @@ class UserrightsPage extends SpecialPage {
/**
* Format a link to a group member description page
*
- * @param $group string
+ * @param string $group
* @return string
*/
private static function buildGroupMemberLink( $group ) {
@@ -555,8 +602,8 @@ class UserrightsPage extends SpecialPage {
* Adds a table with checkboxes where you can select what groups to add/remove
*
* @todo Just pass the username string?
- * @param array $usergroups groups the user belongs to
- * @param $user User a user object
+ * @param array $usergroups Groups the user belongs to
+ * @param User $user
* @return string XHTML table element with checkboxes
*/
private function groupCheckboxes( $usergroups, $user ) {
@@ -599,8 +646,13 @@ class UserrightsPage extends SpecialPage {
continue;
}
// Messages: userrights-changeable-col, userrights-unchangeable-col
- $ret .= Xml::element( 'th', null, $this->msg( 'userrights-' . $name . '-col', count( $column ) )->text() );
+ $ret .= Xml::element(
+ 'th',
+ null,
+ $this->msg( 'userrights-' . $name . '-col', count( $column ) )->text()
+ );
}
+
$ret .= "</tr>\n<tr>\n";
foreach ( $columns as $column ) {
if ( $column === array() ) {
@@ -631,28 +683,41 @@ class UserrightsPage extends SpecialPage {
}
/**
- * @param $group String: the name of the group to check
+ * @param string $group The name of the group to check
* @return bool Can we remove the group?
*/
private function canRemove( $group ) {
// $this->changeableGroups()['remove'] doesn't work, of course. Thanks, PHP.
$groups = $this->changeableGroups();
- return in_array( $group, $groups['remove'] ) || ( $this->isself && in_array( $group, $groups['remove-self'] ) );
+
+ return in_array(
+ $group,
+ $groups['remove'] ) || ( $this->isself && in_array( $group, $groups['remove-self'] )
+ );
}
/**
- * @param string $group the name of the group to check
+ * @param string $group The name of the group to check
* @return bool Can we add the group?
*/
private function canAdd( $group ) {
$groups = $this->changeableGroups();
- return in_array( $group, $groups['add'] ) || ( $this->isself && in_array( $group, $groups['add-self'] ) );
+
+ return in_array(
+ $group,
+ $groups['add'] ) || ( $this->isself && in_array( $group, $groups['add-self'] )
+ );
}
/**
* Returns $this->getUser()->changeableGroups()
*
- * @return Array array( 'add' => array( addablegroups ), 'remove' => array( removablegroups ), 'add-self' => array( addablegroups to self ), 'remove-self' => array( removable groups from self ) )
+ * @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 $this->getUser()->changeableGroups();
@@ -661,8 +726,8 @@ class UserrightsPage extends SpecialPage {
/**
* Show a rights log fragment for the specified user
*
- * @param $user User to show log for
- * @param $output OutputPage to use
+ * @param User $user User to show log for
+ * @param OutputPage $output OutputPage to use
*/
protected function showLogFragment( $user, $output ) {
$rightsLogPage = new LogPage( 'rights' );