From 7e73e00d1f5df59cd9b1ee7070d5441c4e6db6dd Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Mon, 6 Oct 2008 20:17:35 +0000 Subject: [PATCH] (bug 4391) Blocklist filters --- includes/specials/SpecialIpblocklist.php | 58 ++++++++++++++++++++++++ languages/messages/MessagesEn.php | 3 ++ 2 files changed, 61 insertions(+) diff --git a/includes/specials/SpecialIpblocklist.php b/includes/specials/SpecialIpblocklist.php index 5a7ce26287..fb12b9c3ce 100644 --- a/includes/specials/SpecialIpblocklist.php +++ b/includes/specials/SpecialIpblocklist.php @@ -71,9 +71,13 @@ class IPUnblockForm { var $ip, $reason, $id; function IPUnblockForm( $ip, $id, $reason ) { + global $wgRequest; $this->ip = strtr( $ip, '_', ' ' ); $this->id = $id; $this->reason = $reason; + $this->hideuserblocks = $wgRequest->getBool( 'hideuserblocks' ); + $this->hidetempblocks = $wgRequest->getBool( 'hidetempblocks' ); + $this->hideaddressblocks = $wgRequest->getBool( 'hideaddressblocks' ); } /** @@ -257,11 +261,22 @@ class IPUnblockForm { $conds['ipb_auto'] = 0; } } + // Apply filters + if( $this->hideuserblocks ) { + $conds['ipb_user'] = 0; + } + if( $this->hidetempblocks ) { + $conds['ipb_expiry'] = 'infinity'; + } + if( $this->hideaddressblocks ) { + $conds[] = "ipb_range_end > ipb_range_start"; + } $pager = new IPBlocklistPager( $this, $conds ); if ( $pager->getNumRows() ) { $wgOut->addHTML( $this->searchForm() . + $this->showhideLinks() . $pager->getNavigationBar() . Xml::tags( 'ul', null, $pager->getBody() ) . $pager->getNavigationBar() @@ -287,6 +302,49 @@ class IPUnblockForm { Xml::closeElement( 'fieldset' ) ); } + + function showhideLinks() { + $showhide = array( wfMsg( 'show' ), wfMsg( 'hide' ) ); + $nondefaults = array(); + if( $this->hideuserblocks ) { + $nondefaults['hideuserblocks'] = $this->hideuserblocks; + } + if( $this->hidetempblocks ) { + $nondefaults['hidetempblocks'] = $this->hidetempblocks; + } + if( $this->hideaddressblocks ) { + $nondefaults['hideaddressblocks'] = $this->hideaddressblocks; + } + $ubLink = $this->makeOptionsLink( $showhide[1-$this->hideuserblocks], + array( 'hideuserblocks' => 1-$this->hideuserblocks ), $nondefaults); + $tbLink = $this->makeOptionsLink( $showhide[1-$this->hidetempblocks], + array( 'hidetempblocks' => 1-$this->hidetempblocks ), $nondefaults); + $sipbLink = $this->makeOptionsLink( $showhide[1-$this->hideaddressblocks], + array( 'hideaddressblocks' => 1-$this->hideaddressblocks ), $nondefaults); + + $links = array(); + $links[] = wfMsgHtml( 'ipblocklist-sh-userblocks', $ubLink ); + $links[] = wfMsgHtml( 'ipblocklist-sh-tempblocks', $tbLink ); + $links[] = wfMsgHtml( 'ipblocklist-sh-addressblocks', $sipbLink ); + + $hl = '(' . implode( ' | ', $links ) . ')
'; + return $hl; + } + + /** + * Makes change an option link which carries all the other options + * @param $title see Title + * @param $override + * @param $options + */ + function makeOptionsLink( $title, $override, $options, $active = false ) { + global $wgUser; + $sk = $wgUser->getSkin(); + $params = wfArrayMerge( $options, $override ); + $ipblocklist = SpecialPage::getTitleFor( 'IPBlockList' ); + return $sk->link( $ipblocklist, htmlspecialchars( $title ), + ( $active ? array( 'style'=>'font-weight: bold;' ) : array() ), $params, array( 'known' ) ); + } /** * Callback function to output a block diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 9ae83a2aba..c2c8baf6bd 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -2562,6 +2562,9 @@ See [[Special:IPBlockList|IP block list]] to review blocks.', 'ipblocklist' => 'Blocked IP addresses and usernames', 'ipblocklist-legend' => 'Find a blocked user', 'ipblocklist-username' => 'Username or IP address:', +'ipblocklist-sh-userblocks' => '$1 account blocks', +'ipblocklist-sh-tempblocks' => '$1 temporary blocks', +'ipblocklist-sh-addressblocks' => '$1 single IP blocks', 'ipblocklist-summary' => '', # do not translate or duplicate this message to other languages 'ipblocklist-submit' => 'Search', 'blocklistline' => '$1, $2 blocked $3 ($4)', -- 2.20.1