(bug 4391) Blocklist filters
authorAaron Schulz <aaron@users.mediawiki.org>
Mon, 6 Oct 2008 20:17:35 +0000 (20:17 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Mon, 6 Oct 2008 20:17:35 +0000 (20:17 +0000)
includes/specials/SpecialIpblocklist.php
languages/messages/MessagesEn.php

index 5a7ce26..fb12b9c 100644 (file)
@@ -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 ) . ')<hr/>';
+               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
index 9ae83a2..c2c8baf 100644 (file)
@@ -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)',