From a19c0eb2a3cbaba28dc0a668c73ec0162d00516e Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Thu, 17 Jun 2010 07:39:31 +0000 Subject: [PATCH] * (bug 24009) Include implicit groups in action=query&list=users&usprop=groups Add some whitespace, fix some braces in ApiQueryUsers Add a few braces to SpecialUserrights.php, change or to || and and to && --- RELEASE-NOTES | 1 + includes/api/ApiQueryUsers.php | 19 +++++++++++++++++-- includes/specials/SpecialUserrights.php | 12 +++++++----- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index b91295580c..7dfa7594a5 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -222,6 +222,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN thumbnailing larger than original image * (bug 23835) Need "thumbmime" result in "imageinfo" query * (bug 23851) Repair diff for file redirect pages +* (bug 24009) Include implicit groups in action=query&list=users&usprop=groups === Languages updated in 1.17 === diff --git a/includes/api/ApiQueryUsers.php b/includes/api/ApiQueryUsers.php index 947838e605..12e5391e0e 100644 --- a/includes/api/ApiQueryUsers.php +++ b/includes/api/ApiQueryUsers.php @@ -130,20 +130,25 @@ if ( !defined( 'MEDIAWIKI' ) ) { $user = User::newFromRow( $r ); $name = $user->getName(); $data[$name]['name'] = $name; + if ( isset( $this->prop['editcount'] ) ) { $data[$name]['editcount'] = intval( $user->getEditCount() ); } + if ( isset( $this->prop['registration'] ) ) { $data[$name]['registration'] = wfTimestampOrNull( TS_ISO_8601, $user->getRegistration() ); } + if ( isset( $this->prop['groups'] ) && !is_null( $r->ug_group ) ) { // This row contains only one group, others will be added from other rows $data[$name]['groups'][] = $r->ug_group; } + if ( isset( $this->prop['blockinfo'] ) && !is_null( $r->blocker_name ) ) { $data[$name]['blockedby'] = $r->blocker_name; $data[$name]['blockreason'] = $r->ipb_reason; } + if ( isset( $this->prop['emailable'] ) && $user->canReceiveEmail() ) { $data[$name]['emailable'] = ''; } @@ -175,10 +180,13 @@ if ( !defined( 'MEDIAWIKI' ) ) { $data[$u] = array( 'name' => $u ); $urPage = new UserrightsPage; $iwUser = $urPage->fetchUser( $u ); + if ( $iwUser instanceof UserRightsProxy ) { $data[$u]['interwiki'] = ''; + if ( !is_null( $params['token'] ) ) { $tokenFunctions = $this->getTokenFunctions(); + foreach ( $params['token'] as $t ) { $val = call_user_func( $tokenFunctions[$t], $iwUser ); if ( $val === false ) { @@ -192,8 +200,15 @@ if ( !defined( 'MEDIAWIKI' ) ) { $data[$u]['missing'] = ''; } } else { - if ( isset( $this->prop['groups'] ) && isset( $data[$u]['groups'] ) ) - { + if ( isset( $this->prop['groups'] ) && isset( $data[$u]['groups'] ) ) { + $autolist = array(); + $autolist[] = "*"; + foreach( Autopromote::getAutopromoteGroups( User::newFromName( $u ) ) as $group ) { + $autolist[] = $group; + } + + $data[$u]['groups'] = array_merge( $autolist, $data[$u]['groups'] ); + $this->getResult()->setIndexedTagName( $data[$u]['groups'], 'g' ); } } diff --git a/includes/specials/SpecialUserrights.php b/includes/specials/SpecialUserrights.php index 052f9a3245..e92283076e 100644 --- a/includes/specials/SpecialUserrights.php +++ b/includes/specials/SpecialUserrights.php @@ -32,10 +32,10 @@ class UserrightsPage extends SpecialPage { public function userCanChangeRights( $user, $checkIfSelf = true ) { $available = $this->changeableGroups(); return !empty( $available['add'] ) - or !empty( $available['remove'] ) - or ( ( $this->isself || !$checkIfSelf ) and + || !empty( $available['remove'] ) + || ( ( $this->isself || !$checkIfSelf ) && ( !empty( $available['add-self'] ) - or !empty( $available['remove-self'] ) ) ); + || !empty( $available['remove-self'] ) ) ); } /** @@ -77,8 +77,9 @@ class UserrightsPage extends SpecialPage { $this->mTarget = $wgUser->getName(); } - if ( User::getCanonicalName( $this->mTarget ) == $wgUser->getName() ) + if ( User::getCanonicalName( $this->mTarget ) == $wgUser->getName() ) { $this->isself = true; + } if( !$this->userCanChangeRights( $wgUser, true ) ) { // fixme... there may be intermediate groups we can mention. @@ -99,8 +100,9 @@ class UserrightsPage extends SpecialPage { $this->setHeaders(); // show the general form - if ( count( $available['add'] ) || count( $available['remove'] ) ) + if ( count( $available['add'] ) || count( $available['remove'] ) ) { $this->switchForm(); + } if( $wgRequest->wasPosted() ) { // save settings -- 2.20.1