X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialBlockList.php;h=638535940da8c6a18538c8b52871257b45c89045;hb=70e2881cec98b89edc5afebfae55650782937e67;hp=186e5ad7417d034fb9ccc152850947ada1816cdd;hpb=b0494b29097eaff97073f01e3427f2629eedadc1;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialBlockList.php b/includes/specials/SpecialBlockList.php index 186e5ad741..638535940d 100644 --- a/includes/specials/SpecialBlockList.php +++ b/includes/specials/SpecialBlockList.php @@ -21,6 +21,8 @@ * @ingroup SpecialPage */ +use MediaWiki\Block\DatabaseBlock; + /** * A special page that lists existing blocks * @@ -31,18 +33,19 @@ class SpecialBlockList extends SpecialPage { protected $options; + protected $blockType; + function __construct() { parent::__construct( 'BlockList' ); } /** - * Main execution point - * - * @param string $par Title fragment + * @param string|null $par Title fragment */ public function execute( $par ) { $this->setHeaders(); $this->outputHeader(); + $this->addHelpLink( 'Help:Blocking_users' ); $out = $this->getOutput(); $out->setPageTitle( $this->msg( 'ipblocklist' ) ); $out->addModuleStyles( [ 'mediawiki.special' ] ); @@ -52,6 +55,7 @@ class SpecialBlockList extends SpecialPage { $this->target = trim( $request->getVal( 'wpTarget', $par ) ); $this->options = $request->getArray( 'wpOptions', [] ); + $this->blockType = $request->getVal( 'blockType' ); $action = $request->getText( 'action' ); @@ -78,21 +82,41 @@ class SpecialBlockList extends SpecialPage { 'Options' => [ 'type' => 'multiselect', 'options-messages' => [ - 'blocklist-userblocks' => 'userblocks', 'blocklist-tempblocks' => 'tempblocks', + 'blocklist-indefblocks' => 'indefblocks', + 'blocklist-userblocks' => 'userblocks', 'blocklist-addressblocks' => 'addressblocks', 'blocklist-rangeblocks' => 'rangeblocks', ], 'flatlist' => true, ], - 'Limit' => [ - 'type' => 'limitselect', - 'label-message' => 'table_pager_limit_label', - 'options' => $pager->getLimitSelectList(), - 'name' => 'limit', - 'default' => $pager->getLimit(), - ], ]; + + if ( $this->getConfig()->get( 'EnablePartialBlocks' ) ) { + $fields['BlockType'] = [ + 'type' => 'select', + 'label-message' => 'blocklist-type', + 'options' => [ + $this->msg( 'blocklist-type-opt-all' )->escaped() => '', + $this->msg( 'blocklist-type-opt-sitewide' )->escaped() => 'sitewide', + $this->msg( 'blocklist-type-opt-partial' )->escaped() => 'partial', + ], + 'name' => 'blockType', + 'cssclass' => 'mw-field-block-type', + ]; + } + + $fields['Limit'] = [ + 'type' => 'limitselect', + 'label-message' => 'table_pager_limit_label', + 'options' => $pager->getLimitSelectList(), + 'name' => 'limit', + 'default' => $pager->getLimit(), + 'cssclass' => $this->getConfig()->get( 'EnablePartialBlocks' ) ? + 'mw-field-limit mw-has-field-block-type' : + 'mw-field-limit', + ]; + $context = new DerivativeContext( $this->getContext() ); $context->setTitle( $this->getPageTitle() ); // Remove subpage $form = HTMLForm::factory( 'ooui', $fields, $context ); @@ -113,34 +137,35 @@ class SpecialBlockList extends SpecialPage { */ protected function getBlockListPager() { $conds = []; + $db = $this->getDB(); # Is the user allowed to see hidden blocks? if ( !$this->getUser()->isAllowed( 'hideuser' ) ) { $conds['ipb_deleted'] = 0; } if ( $this->target !== '' ) { - list( $target, $type ) = Block::parseTarget( $this->target ); + list( $target, $type ) = DatabaseBlock::parseTarget( $this->target ); switch ( $type ) { - case Block::TYPE_ID: - case Block::TYPE_AUTO: + case DatabaseBlock::TYPE_ID: + case DatabaseBlock::TYPE_AUTO: $conds['ipb_id'] = $target; break; - case Block::TYPE_IP: - case Block::TYPE_RANGE: + case DatabaseBlock::TYPE_IP: + case DatabaseBlock::TYPE_RANGE: list( $start, $end ) = IP::parseRange( $target ); - $conds[] = wfGetDB( DB_REPLICA )->makeList( + $conds[] = $db->makeList( [ 'ipb_address' => $target, - Block::getRangeCond( $start, $end ) + DatabaseBlock::getRangeCond( $start, $end ) ], LIST_OR ); $conds['ipb_auto'] = 0; break; - case Block::TYPE_USER: + case DatabaseBlock::TYPE_USER: $conds['ipb_address'] = $target->getName(); $conds['ipb_auto'] = 0; break; @@ -151,9 +176,6 @@ class SpecialBlockList extends SpecialPage { if ( in_array( 'userblocks', $this->options ) ) { $conds['ipb_user'] = 0; } - if ( in_array( 'tempblocks', $this->options ) ) { - $conds['ipb_expiry'] = 'infinity'; - } if ( in_array( 'addressblocks', $this->options ) ) { $conds[] = "ipb_user != 0 OR ipb_range_end > ipb_range_start"; } @@ -161,6 +183,23 @@ class SpecialBlockList extends SpecialPage { $conds[] = "ipb_range_end = ipb_range_start"; } + $hideTemp = in_array( 'tempblocks', $this->options ); + $hideIndef = in_array( 'indefblocks', $this->options ); + if ( $hideTemp && $hideIndef ) { + // If both types are hidden, ensure query doesn't produce any results + $conds[] = '1=0'; + } elseif ( $hideTemp ) { + $conds['ipb_expiry'] = $db->getInfinity(); + } elseif ( $hideIndef ) { + $conds[] = "ipb_expiry != " . $db->addQuotes( $db->getInfinity() ); + } + + if ( $this->blockType === 'sitewide' ) { + $conds['ipb_sitewide'] = 1; + } elseif ( $this->blockType === 'partial' ) { + $conds['ipb_sitewide'] = 0; + } + return new BlockListPager( $this, $conds ); } @@ -214,4 +253,13 @@ class SpecialBlockList extends SpecialPage { protected function getGroupName() { return 'users'; } + + /** + * Return a IDatabase object for reading + * + * @return IDatabase + */ + protected function getDB() { + return wfGetDB( DB_REPLICA ); + } }