r68156 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68155‎ | r68156 | r68157 >
Date:07:39, 17 June 2010
Author:reedy
Status:ok (Comments)
Tags:
Comment:
* (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 &&
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryUsers.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUserrights.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryUsers.php
@@ -130,20 +130,25 @@
131131 $user = User::newFromRow( $r );
132132 $name = $user->getName();
133133 $data[$name]['name'] = $name;
 134+
134135 if ( isset( $this->prop['editcount'] ) ) {
135136 $data[$name]['editcount'] = intval( $user->getEditCount() );
136137 }
 138+
137139 if ( isset( $this->prop['registration'] ) ) {
138140 $data[$name]['registration'] = wfTimestampOrNull( TS_ISO_8601, $user->getRegistration() );
139141 }
 142+
140143 if ( isset( $this->prop['groups'] ) && !is_null( $r->ug_group ) ) {
141144 // This row contains only one group, others will be added from other rows
142145 $data[$name]['groups'][] = $r->ug_group;
143146 }
 147+
144148 if ( isset( $this->prop['blockinfo'] ) && !is_null( $r->blocker_name ) ) {
145149 $data[$name]['blockedby'] = $r->blocker_name;
146150 $data[$name]['blockreason'] = $r->ipb_reason;
147151 }
 152+
148153 if ( isset( $this->prop['emailable'] ) && $user->canReceiveEmail() ) {
149154 $data[$name]['emailable'] = '';
150155 }
@@ -175,10 +180,13 @@
176181 $data[$u] = array( 'name' => $u );
177182 $urPage = new UserrightsPage;
178183 $iwUser = $urPage->fetchUser( $u );
 184+
179185 if ( $iwUser instanceof UserRightsProxy ) {
180186 $data[$u]['interwiki'] = '';
 187+
181188 if ( !is_null( $params['token'] ) ) {
182189 $tokenFunctions = $this->getTokenFunctions();
 190+
183191 foreach ( $params['token'] as $t ) {
184192 $val = call_user_func( $tokenFunctions[$t], $iwUser );
185193 if ( $val === false ) {
@@ -192,8 +200,15 @@
193201 $data[$u]['missing'] = '';
194202 }
195203 } else {
196 - if ( isset( $this->prop['groups'] ) && isset( $data[$u]['groups'] ) )
197 - {
 204+ if ( isset( $this->prop['groups'] ) && isset( $data[$u]['groups'] ) ) {
 205+ $autolist = array();
 206+ $autolist[] = "*";
 207+ foreach( Autopromote::getAutopromoteGroups( User::newFromName( $u ) ) as $group ) {
 208+ $autolist[] = $group;
 209+ }
 210+
 211+ $data[$u]['groups'] = array_merge( $autolist, $data[$u]['groups'] );
 212+
198213 $this->getResult()->setIndexedTagName( $data[$u]['groups'], 'g' );
199214 }
200215 }
Index: trunk/phase3/includes/specials/SpecialUserrights.php
@@ -32,10 +32,10 @@
3333 public function userCanChangeRights( $user, $checkIfSelf = true ) {
3434 $available = $this->changeableGroups();
3535 return !empty( $available['add'] )
36 - or !empty( $available['remove'] )
37 - or ( ( $this->isself || !$checkIfSelf ) and
 36+ || !empty( $available['remove'] )
 37+ || ( ( $this->isself || !$checkIfSelf ) &&
3838 ( !empty( $available['add-self'] )
39 - or !empty( $available['remove-self'] ) ) );
 39+ || !empty( $available['remove-self'] ) ) );
4040 }
4141
4242 /**
@@ -77,8 +77,9 @@
7878 $this->mTarget = $wgUser->getName();
7979 }
8080
81 - if ( User::getCanonicalName( $this->mTarget ) == $wgUser->getName() )
 81+ if ( User::getCanonicalName( $this->mTarget ) == $wgUser->getName() ) {
8282 $this->isself = true;
 83+ }
8384
8485 if( !$this->userCanChangeRights( $wgUser, true ) ) {
8586 // fixme... there may be intermediate groups we can mention.
@@ -99,8 +100,9 @@
100101 $this->setHeaders();
101102
102103 // show the general form
103 - if ( count( $available['add'] ) || count( $available['remove'] ) )
 104+ if ( count( $available['add'] ) || count( $available['remove'] ) ) {
104105 $this->switchForm();
 106+ }
105107
106108 if( $wgRequest->wasPosted() ) {
107109 // save settings
Index: trunk/phase3/RELEASE-NOTES
@@ -222,6 +222,7 @@
223223 thumbnailing larger than original image
224224 * (bug 23835) Need "thumbmime" result in "imageinfo" query
225225 * (bug 23851) Repair diff for file redirect pages
 226+* (bug 24009) Include implicit groups in action=query&list=users&usprop=groups
226227
227228 === Languages updated in 1.17 ===
228229

Follow-up revisions

RevisionCommit summaryAuthorDate
r68157Minor followup to r68156, add "user" as implicit group...reedy08:00, 17 June 2010

Comments

#Comment by Aaron Schulz (talk | contribs)   21:15, 17 June 2010

I assume the getAutopromoteGroups() overhead works out to be tiny here, right? Is this on Special:ListUsers too?

Status & tagging log