Merge "(bug 19195) Make user IDs more readily available with the API"
authorReedy <reedy@wikimedia.org>
Thu, 10 May 2012 18:47:42 +0000 (18:47 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 10 May 2012 18:47:42 +0000 (18:47 +0000)
includes/api/ApiBlock.php
includes/api/ApiQueryAllUsers.php
includes/api/ApiQueryBase.php
includes/api/ApiQueryUserInfo.php
includes/api/ApiQueryUsers.php
includes/api/ApiUnblock.php
includes/api/ApiUserrights.php

index c566a5c..9a2f255 100644 (file)
@@ -103,9 +103,11 @@ class ApiBlock extends ApiBase {
                        $res['expiry'] = $block->mExpiry == wfGetDB( DB_SLAVE )->getInfinity()
                                ? 'infinite'
                                : wfTimestamp( TS_ISO_8601, $block->mExpiry );
+                       $res['id'] = $block->getId();
                } else {
                        # should be unreachable
                        $res['expiry'] = '';
+                       $res['id'] = '';
                }
 
                $res['reason'] = $params['reason'];
index e96676e..01cb15a 100644 (file)
@@ -218,7 +218,9 @@ class ApiQueryAllUsers extends ApiQueryBase {
                                        'name' => $lastUser,
                                );
                                if ( $fld_blockinfo && !is_null( $row->ipb_by_text ) ) {
+                                       $lastUserData['blockid'] = $row->ipb_id;
                                        $lastUserData['blockedby'] = $row->ipb_by_text;
+                                       $lastUserData['blockedbyid'] = $row->ipb_by;
                                        $lastUserData['blockreason'] = $row->ipb_reason;
                                        $lastUserData['blockexpiry'] = $row->ipb_expiry;
                                }
index a633748..92fabdd 100644 (file)
@@ -519,7 +519,7 @@ abstract class ApiQueryBase extends ApiBase {
                        $this->addFields( 'ipb_deleted' );
 
                        if ( $showBlockInfo ) {
-                               $this->addFields( array( 'ipb_reason', 'ipb_by_text', 'ipb_expiry' ) );
+                               $this->addFields( array( 'ipb_id', 'ipb_by', 'ipb_by_text', 'ipb_reason', 'ipb_expiry' ) );
                        }
 
                        // Don't show hidden names
index cbb35ae..e3bc775 100644 (file)
@@ -63,7 +63,10 @@ class ApiQueryUserInfo extends ApiQueryBase {
 
                if ( isset( $this->prop['blockinfo'] ) ) {
                        if ( $user->isBlocked() ) {
-                               $vals['blockedby'] = User::whoIs( $user->blockedBy() );
+                               $block = $user->getBlock();
+                               $vals['blockid'] = $block->getId();
+                               $vals['blockedby'] = $block->getByName();
+                               $vals['blockedbyid'] = $block->getBy();
                                $vals['blockreason'] = $user->blockedFor();
                        }
                }
index 38244ff..a07ee7f 100644 (file)
@@ -165,7 +165,9 @@ class ApiQueryUsers extends ApiQueryBase {
                                        $data[$name]['hidden'] = '';
                                }
                                if ( isset( $this->prop['blockinfo'] ) && !is_null( $row->ipb_by_text ) ) {
+                                       $data[$name]['blockid'] = $row->ipb_id;
                                        $data[$name]['blockedby'] = $row->ipb_by_text;
+                                       $data[$name]['blockedbyid'] = $row->ipb_by;
                                        $data[$name]['blockreason'] = $row->ipb_reason;
                                        $data[$name]['blockexpiry'] = $row->ipb_expiry;
                                }
index 32e0d88..49353b6 100644 (file)
@@ -78,7 +78,9 @@ class ApiUnblock extends ApiBase {
                }
 
                $res['id'] = $block->getId();
-               $res['user'] = $block->getType() == Block::TYPE_AUTO ? '' : $block->getTarget();
+               $target = $block->getType() == Block::TYPE_AUTO ? '' : $block->getTarget();
+               $res['user'] = $target;
+               $res['userid'] = $target instanceof User ? $target->getId() : 0;
                $res['reason'] = $params['reason'];
                $this->getResult()->addValue( null, $this->getModuleName(), $res );
        }
index 191dd3e..399bc54 100644 (file)
@@ -43,6 +43,7 @@ class ApiUserrights extends ApiBase {
 
                $form = new UserrightsPage;
                $r['user'] = $user->getName();
+               $r['userid'] = $user->getId();
                list( $r['added'], $r['removed'] ) =
                        $form->doSaveUserGroups(
                                $user, (array)$params['add'],