* (bug 27616) Add userid of blocked user and blocker to list=blocks
authorSam Reed <reedy@users.mediawiki.org>
Mon, 21 Feb 2011 19:48:15 +0000 (19:48 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Mon, 21 Feb 2011 19:48:15 +0000 (19:48 +0000)
Also tweak comment about "blocking admin". Non admins can block if they have the right... Sooo,  "user" is more appropriate

RELEASE-NOTES
includes/api/ApiQueryBlocks.php

index 81147ad..3ef39c0 100644 (file)
@@ -178,6 +178,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   prop=info&inprop=displaytitle
 * (bug 27554) Update api information text to reflect change in bug 26125
 * (bug 27611) list=blocks: Use ipb_by_text instead of join with user table
+* (bug 27616) Add userid of blocked user and blocker to list=blocks
 
 === Languages updated in 1.18 ===
 
index 80940d5..477d979 100644 (file)
@@ -36,7 +36,10 @@ if ( !defined( 'MEDIAWIKI' ) ) {
  */
 class ApiQueryBlocks extends ApiQueryBase {
 
-       var $users;
+       /**
+        * @var Array
+        */
+       protected $usernames;
 
        public function __construct( $query, $moduleName ) {
                parent::__construct( $query, $moduleName, 'bk' );
@@ -53,7 +56,9 @@ class ApiQueryBlocks extends ApiQueryBase {
                $prop = array_flip( $params['prop'] );
                $fld_id = isset( $prop['id'] );
                $fld_user = isset( $prop['user'] );
+               $fld_userid = isset( $prop['userid'] );
                $fld_by = isset( $prop['by'] );
+               $fld_byid = isset( $prop['byid'] );
                $fld_timestamp = isset( $prop['timestamp'] );
                $fld_expiry = isset( $prop['expiry'] );
                $fld_reason = isset( $prop['reason'] );
@@ -68,12 +73,15 @@ class ApiQueryBlocks extends ApiQueryBase {
                if ( $fld_id ) {
                        $this->addFields( 'ipb_id' );
                }
-               if ( $fld_user ) {
+               if ( $fld_user || $fld_userid ) {
                        $this->addFields( array( 'ipb_address', 'ipb_user' ) );
                }
                if ( $fld_by ) {
                        $this->addFields( 'ipb_by_text' );
                }
+               if ( $fld_byid ) {
+                       $this->addFields( 'ipb_by' );
+               }
                if ( $fld_timestamp ) {
                        $this->addFields( 'ipb_timestamp' );
                }
@@ -149,9 +157,15 @@ class ApiQueryBlocks extends ApiQueryBase {
                        if ( $fld_user && !$row->ipb_auto ) {
                                $block['user'] = $row->ipb_address;
                        }
+                       if ( $fld_userid && !$row->ipb_auto ) {
+                               $block['userid'] = $row->ipb_user;
+                       }
                        if ( $fld_by ) {
                                $block['by'] = $row->ipb_by_text;
                        }
+                       if ( $fld_byid ) {
+                               $block['byid'] = $row->ipb_by;
+                       }
                        if ( $fld_timestamp ) {
                                $block['timestamp'] = wfTimestamp( TS_ISO_8601, $row->ipb_timestamp );
                        }
@@ -246,7 +260,9 @@ class ApiQueryBlocks extends ApiQueryBase {
                                ApiBase::PARAM_TYPE => array(
                                        'id',
                                        'user',
+                                       'userid',
                                        'by',
+                                       'byid',
                                        'timestamp',
                                        'expiry',
                                        'reason',
@@ -272,7 +288,9 @@ class ApiQueryBlocks extends ApiQueryBase {
                                'Which properties to get',
                                ' id         - Adds the ID of the block',
                                ' user       - Adds the username of the blocked user',
-                               ' by         - Adds the username of the blocking admin',
+                               ' userid     - Adds the user ID of the blocked user',
+                               ' by         - Adds the username of the blocking user',
+                               ' byid       - Adds the user ID of the blocking user',
                                ' timestamp  - Adds the timestamp of when the block was given',
                                ' expiry     - Adds the timestamp of when the block expires',
                                ' reason     - Adds the reason given for the block',