r41776 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41775‎ | r41776 | r41777 >
Date:20:17, 6 October 2008
Author:aaron
Status:old (Comments)
Tags:
Comment:
(bug 4391) Blocklist filters
Modified paths:
  • /trunk/phase3/includes/specials/SpecialIpblocklist.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialIpblocklist.php
@@ -71,9 +71,13 @@
7272 var $ip, $reason, $id;
7373
7474 function IPUnblockForm( $ip, $id, $reason ) {
 75+ global $wgRequest;
7576 $this->ip = strtr( $ip, '_', ' ' );
7677 $this->id = $id;
7778 $this->reason = $reason;
 79+ $this->hideuserblocks = $wgRequest->getBool( 'hideuserblocks' );
 80+ $this->hidetempblocks = $wgRequest->getBool( 'hidetempblocks' );
 81+ $this->hideaddressblocks = $wgRequest->getBool( 'hideaddressblocks' );
7882 }
7983
8084 /**
@@ -257,11 +261,22 @@
258262 $conds['ipb_auto'] = 0;
259263 }
260264 }
 265+ // Apply filters
 266+ if( $this->hideuserblocks ) {
 267+ $conds['ipb_user'] = 0;
 268+ }
 269+ if( $this->hidetempblocks ) {
 270+ $conds['ipb_expiry'] = 'infinity';
 271+ }
 272+ if( $this->hideaddressblocks ) {
 273+ $conds[] = "ipb_range_end > ipb_range_start";
 274+ }
261275
262276 $pager = new IPBlocklistPager( $this, $conds );
263277 if ( $pager->getNumRows() ) {
264278 $wgOut->addHTML(
265279 $this->searchForm() .
 280+ $this->showhideLinks() .
266281 $pager->getNavigationBar() .
267282 Xml::tags( 'ul', null, $pager->getBody() ) .
268283 $pager->getNavigationBar()
@@ -287,6 +302,49 @@
288303 Xml::closeElement( 'fieldset' )
289304 );
290305 }
 306+
 307+ function showhideLinks() {
 308+ $showhide = array( wfMsg( 'show' ), wfMsg( 'hide' ) );
 309+ $nondefaults = array();
 310+ if( $this->hideuserblocks ) {
 311+ $nondefaults['hideuserblocks'] = $this->hideuserblocks;
 312+ }
 313+ if( $this->hidetempblocks ) {
 314+ $nondefaults['hidetempblocks'] = $this->hidetempblocks;
 315+ }
 316+ if( $this->hideaddressblocks ) {
 317+ $nondefaults['hideaddressblocks'] = $this->hideaddressblocks;
 318+ }
 319+ $ubLink = $this->makeOptionsLink( $showhide[1-$this->hideuserblocks],
 320+ array( 'hideuserblocks' => 1-$this->hideuserblocks ), $nondefaults);
 321+ $tbLink = $this->makeOptionsLink( $showhide[1-$this->hidetempblocks],
 322+ array( 'hidetempblocks' => 1-$this->hidetempblocks ), $nondefaults);
 323+ $sipbLink = $this->makeOptionsLink( $showhide[1-$this->hideaddressblocks],
 324+ array( 'hideaddressblocks' => 1-$this->hideaddressblocks ), $nondefaults);
 325+
 326+ $links = array();
 327+ $links[] = wfMsgHtml( 'ipblocklist-sh-userblocks', $ubLink );
 328+ $links[] = wfMsgHtml( 'ipblocklist-sh-tempblocks', $tbLink );
 329+ $links[] = wfMsgHtml( 'ipblocklist-sh-addressblocks', $sipbLink );
 330+
 331+ $hl = '(' . implode( ' | ', $links ) . ')<hr/>';
 332+ return $hl;
 333+ }
 334+
 335+ /**
 336+ * Makes change an option link which carries all the other options
 337+ * @param $title see Title
 338+ * @param $override
 339+ * @param $options
 340+ */
 341+ function makeOptionsLink( $title, $override, $options, $active = false ) {
 342+ global $wgUser;
 343+ $sk = $wgUser->getSkin();
 344+ $params = wfArrayMerge( $options, $override );
 345+ $ipblocklist = SpecialPage::getTitleFor( 'IPBlockList' );
 346+ return $sk->link( $ipblocklist, htmlspecialchars( $title ),
 347+ ( $active ? array( 'style'=>'font-weight: bold;' ) : array() ), $params, array( 'known' ) );
 348+ }
291349
292350 /**
293351 * Callback function to output a block
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -2562,6 +2562,9 @@
25632563 'ipblocklist' => 'Blocked IP addresses and usernames',
25642564 'ipblocklist-legend' => 'Find a blocked user',
25652565 'ipblocklist-username' => 'Username or IP address:',
 2566+'ipblocklist-sh-userblocks' => '$1 account blocks',
 2567+'ipblocklist-sh-tempblocks' => '$1 temporary blocks',
 2568+'ipblocklist-sh-addressblocks' => '$1 single IP blocks',
25662569 'ipblocklist-summary' => '', # do not translate or duplicate this message to other languages
25672570 'ipblocklist-submit' => 'Search',
25682571 'blocklistline' => '$1, $2 blocked $3 ($4)',

Comments

#Comment by Brion VIBBER (talk | contribs)   00:13, 7 October 2008

Tweaks in r41784

Status & tagging log