From: Reedy Date: Thu, 10 May 2012 18:47:42 +0000 (+0000) Subject: Merge "(bug 19195) Make user IDs more readily available with the API" X-Git-Tag: 1.31.0-rc.0~23654 X-Git-Url: https://git.heureux-cyclage.org/?a=commitdiff_plain;h=c87a63935a2595f6c24f0a3af94cd29d2b82f80a;hp=f8aaeb1360cc72ccf2e53091bf723f59532bc9d7;p=lhc%2Fweb%2Fwiklou.git Merge "(bug 19195) Make user IDs more readily available with the API" --- diff --git a/includes/api/ApiBlock.php b/includes/api/ApiBlock.php index c566a5cbaf..9a2f25565c 100644 --- a/includes/api/ApiBlock.php +++ b/includes/api/ApiBlock.php @@ -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']; diff --git a/includes/api/ApiQueryAllUsers.php b/includes/api/ApiQueryAllUsers.php index e96676ea4b..01cb15af69 100644 --- a/includes/api/ApiQueryAllUsers.php +++ b/includes/api/ApiQueryAllUsers.php @@ -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; } diff --git a/includes/api/ApiQueryBase.php b/includes/api/ApiQueryBase.php index a63374847f..92fabddd00 100644 --- a/includes/api/ApiQueryBase.php +++ b/includes/api/ApiQueryBase.php @@ -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 diff --git a/includes/api/ApiQueryUserInfo.php b/includes/api/ApiQueryUserInfo.php index cbb35aeb2a..e3bc775a79 100644 --- a/includes/api/ApiQueryUserInfo.php +++ b/includes/api/ApiQueryUserInfo.php @@ -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(); } } diff --git a/includes/api/ApiQueryUsers.php b/includes/api/ApiQueryUsers.php index 38244fff6a..a07ee7f890 100644 --- a/includes/api/ApiQueryUsers.php +++ b/includes/api/ApiQueryUsers.php @@ -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; } diff --git a/includes/api/ApiUnblock.php b/includes/api/ApiUnblock.php index 32e0d88e82..49353b61f6 100644 --- a/includes/api/ApiUnblock.php +++ b/includes/api/ApiUnblock.php @@ -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 ); } diff --git a/includes/api/ApiUserrights.php b/includes/api/ApiUserrights.php index 191dd3ec1e..399bc54329 100644 --- a/includes/api/ApiUserrights.php +++ b/includes/api/ApiUserrights.php @@ -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'],