From: umherirrender Date: Sun, 22 Apr 2012 12:20:46 +0000 (+0200) Subject: (bug 19195) Make user IDs more readily available with the API X-Git-Tag: 1.31.0-rc.0~23654^2 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=426ccbf42e65b244f7af24f86d394114f40601d8;p=lhc%2Fweb%2Fwiklou.git (bug 19195) Make user IDs more readily available with the API Add some block ids and user ids to the result of some modules Change-Id: If50604b888a54827eddde76574e779db6c7263ec --- diff --git a/includes/api/ApiBlock.php b/includes/api/ApiBlock.php index 7d3a40bb5f..a5615c5aba 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 ac112ef982..0f2db10129 100644 --- a/includes/api/ApiQueryAllUsers.php +++ b/includes/api/ApiQueryAllUsers.php @@ -209,7 +209,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 a0ee227fc7..87edca0d0c 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 31624bdf04..22575956d1 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 e599e3286e..44e174783a 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'],