X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQueryBlocks.php;h=8b8bd0110fb54a102e72871de518779239f40547;hb=23e5cdb5034dca5bbdfc2ac9c111c5fac20ff579;hp=229e3d1187cba2c0bf388cd9366f8782ff1c5e85;hpb=3c18e32e58d53ab38d1dd52d00f248ddef435ebd;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQueryBlocks.php b/includes/api/ApiQueryBlocks.php index 229e3d1187..8b8bd0110f 100644 --- a/includes/api/ApiQueryBlocks.php +++ b/includes/api/ApiQueryBlocks.php @@ -57,16 +57,16 @@ class ApiQueryBlocks extends ApiQueryBase { $result = $this->getResult(); $this->addTables( 'ipblocks' ); - $this->addFields( array( 'ipb_auto', 'ipb_id', 'ipb_timestamp' ) ); + $this->addFields( [ 'ipb_auto', 'ipb_id', 'ipb_timestamp' ] ); - $this->addFieldsIf( array( 'ipb_address', 'ipb_user' ), $fld_user || $fld_userid ); + $this->addFieldsIf( [ 'ipb_address', 'ipb_user' ], $fld_user || $fld_userid ); $this->addFieldsIf( 'ipb_by_text', $fld_by ); $this->addFieldsIf( 'ipb_by', $fld_byid ); $this->addFieldsIf( 'ipb_expiry', $fld_expiry ); $this->addFieldsIf( 'ipb_reason', $fld_reason ); - $this->addFieldsIf( array( 'ipb_range_start', 'ipb_range_end' ), $fld_range ); - $this->addFieldsIf( array( 'ipb_anon_only', 'ipb_create_account', 'ipb_enable_autoblock', - 'ipb_block_email', 'ipb_deleted', 'ipb_allow_usertalk' ), + $this->addFieldsIf( [ 'ipb_range_start', 'ipb_range_end' ], $fld_range ); + $this->addFieldsIf( [ 'ipb_anon_only', 'ipb_create_account', 'ipb_enable_autoblock', + 'ipb_block_email', 'ipb_deleted', 'ipb_allow_usertalk' ], $fld_flags ); $this->addOption( 'LIMIT', $params['limit'] + 1 ); @@ -96,7 +96,7 @@ class ApiQueryBlocks extends ApiQueryBase { $this->addWhereFld( 'ipb_id', $params['ids'] ); } if ( isset( $params['users'] ) ) { - $usernames = array(); + $usernames = []; foreach ( (array)$params['users'] as $u ) { $usernames[] = $this->prepareUsername( $u ); } @@ -137,12 +137,12 @@ class ApiQueryBlocks extends ApiQueryBase { $lower = $db->addQuotes( $lower ); $upper = $db->addQuotes( $upper ); - $this->addWhere( array( + $this->addWhere( [ 'ipb_range_start' . $db->buildLike( $prefix, $db->anyString() ), 'ipb_range_start <= ' . $lower, 'ipb_range_end >= ' . $upper, 'ipb_auto' => 0 - ) ); + ] ); } if ( !is_null( $params['show'] ) ) { @@ -187,9 +187,9 @@ class ApiQueryBlocks extends ApiQueryBase { $this->setContinueEnumParameter( 'continue', "$row->ipb_timestamp|$row->ipb_id" ); break; } - $block = array( + $block = [ ApiResult::META_TYPE => 'assoc', - ); + ]; if ( $fld_id ) { $block['id'] = (int)$row->ipb_id; } @@ -228,13 +228,13 @@ class ApiQueryBlocks extends ApiQueryBase { $block['hidden'] = (bool)$row->ipb_deleted; $block['allowusertalk'] = (bool)$row->ipb_allow_usertalk; } - $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $block ); + $fit = $result->addValue( [ 'query', $this->getModuleName() ], null, $block ); if ( !$fit ) { $this->setContinueEnumParameter( 'continue', "$row->ipb_timestamp|$row->ipb_id" ); break; } } - $result->addIndexedTagName( array( 'query', $this->getModuleName() ), 'block' ); + $result->addIndexedTagName( [ 'query', $this->getModuleName() ], 'block' ); } protected function prepareUsername( $user ) { @@ -253,46 +253,46 @@ class ApiQueryBlocks extends ApiQueryBase { public function getAllowedParams() { $blockCIDRLimit = $this->getConfig()->get( 'BlockCIDRLimit' ); - return array( - 'start' => array( + return [ + 'start' => [ ApiBase::PARAM_TYPE => 'timestamp' - ), - 'end' => array( + ], + 'end' => [ ApiBase::PARAM_TYPE => 'timestamp', - ), - 'dir' => array( - ApiBase::PARAM_TYPE => array( + ], + 'dir' => [ + ApiBase::PARAM_TYPE => [ 'newer', 'older' - ), + ], ApiBase::PARAM_DFLT => 'older', ApiBase::PARAM_HELP_MSG => 'api-help-param-direction', - ), - 'ids' => array( + ], + 'ids' => [ ApiBase::PARAM_TYPE => 'integer', ApiBase::PARAM_ISMULTI => true - ), - 'users' => array( + ], + 'users' => [ ApiBase::PARAM_TYPE => 'user', ApiBase::PARAM_ISMULTI => true - ), - 'ip' => array( - ApiBase::PARAM_HELP_MSG => array( + ], + 'ip' => [ + ApiBase::PARAM_HELP_MSG => [ 'apihelp-query+blocks-param-ip', $blockCIDRLimit['IPv4'], $blockCIDRLimit['IPv6'], - ), - ), - 'limit' => array( + ], + ], + 'limit' => [ ApiBase::PARAM_DFLT => 10, ApiBase::PARAM_TYPE => 'limit', ApiBase::PARAM_MIN => 1, ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1, ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2 - ), - 'prop' => array( + ], + 'prop' => [ ApiBase::PARAM_DFLT => 'id|user|by|timestamp|expiry|reason|flags', - ApiBase::PARAM_TYPE => array( + ApiBase::PARAM_TYPE => [ 'id', 'user', 'userid', @@ -303,12 +303,12 @@ class ApiQueryBlocks extends ApiQueryBase { 'reason', 'range', 'flags' - ), + ], ApiBase::PARAM_ISMULTI => true, - ApiBase::PARAM_HELP_MSG_PER_VALUE => array(), - ), - 'show' => array( - ApiBase::PARAM_TYPE => array( + ApiBase::PARAM_HELP_MSG_PER_VALUE => [], + ], + 'show' => [ + ApiBase::PARAM_TYPE => [ 'account', '!account', 'temp', @@ -317,22 +317,22 @@ class ApiQueryBlocks extends ApiQueryBase { '!ip', 'range', '!range', - ), + ], ApiBase::PARAM_ISMULTI => true - ), - 'continue' => array( + ], + 'continue' => [ ApiBase::PARAM_HELP_MSG => 'api-help-param-continue', - ), - ); + ], + ]; } protected function getExamplesMessages() { - return array( + return [ 'action=query&list=blocks' => 'apihelp-query+blocks-example-simple', 'action=query&list=blocks&bkusers=Alice|Bob' => 'apihelp-query+blocks-example-users', - ); + ]; } public function getHelpUrls() {