r27204 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r27203‎ | r27204 | r27205 >
Date:15:47, 5 November 2007
Author:vasilievvv
Status:old
Tags:
Comment:
* (bug 1401) Allow hiding logged-in users, bots and patrolled pages on Special:Newpages
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/SpecialNewpages.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialNewpages.php
@@ -14,13 +14,15 @@
1515 var $username;
1616 var $hideliu;
1717 var $hidepatrolled;
 18+ var $hidebots;
1819 var $defaults;
1920
20 - function NewPagesPage( $namespace, $username, $hideliu, $hidepatrolled, $defaults) {
 21+ function NewPagesPage( $namespace, $username, $hideliu, $hidepatrolled, $hidebots, $defaults) {
2122 $this->namespace = $namespace;
2223 $this->username = $username;
2324 $this->hideliu = $hideliu;
2425 $this->hidepatrolled = $hidepatrolled;
 26+ $this->hidebots = $hidebots;
2527 $this->defaults = $defaults;
2628 }
2729
@@ -37,17 +39,18 @@
3840 global $wgGroupPermissions;
3941 $where = '';
4042 if ($this->hidepatrolled)
41 - $where = ' AND rc_patrolled = 0';
 43+ $where .= ' AND rc_patrolled = 0';
 44+ if ($this->hidebots)
 45+ $where .= ' AND rc_bot = 0';
4246 if ($wgGroupPermissions['*']['createpage'] == true && $this->hideliu) {
43 - return $where . ' AND rc_user = 0';
 47+ $where .= ' AND rc_user = 0';
4448 } else {
4549 $title = Title::makeTitleSafe( NS_USER, $this->username );
4650 if( $title ) {
47 - return $where . ' AND rc_user_text = ' . $dbo->addQuotes( $title->getText() );
48 - } else {
49 - return $where;
 51+ $where .= ' AND rc_user_text = ' . $dbo->addQuotes( $title->getText() );
5052 }
5153 }
 54+ return $where;
5255 }
5356
5457 private function makeNamespaceWhere() {
@@ -171,12 +174,15 @@
172175 htmlspecialchars( $showhide[1-$this->hideliu] ), wfArrayToCGI( array( 'hideliu' => 1-$this->hideliu ), $nondefaults ) );
173176 $patrLink = $wgUser->getSkin()->makeKnownLink( $wgContLang->specialPage( 'Newpages' ),
174177 htmlspecialchars( $showhide[1-$this->hidepatrolled] ), wfArrayToCGI( array( 'hidepatrolled' => 1-$this->hidepatrolled ), $nondefaults ) );
 178+ $botsLink = $wgUser->getSkin()->makeKnownLink( $wgContLang->specialPage( 'Newpages' ),
 179+ htmlspecialchars( $showhide[1-$this->hidebots] ), wfArrayToCGI( array( 'hidebots' => 1-$this->hidebots ), $nondefaults ) );
175180 $links = array();
176181 if( $wgGroupPermissions['*']['createpage'] == true )
177182 $links[] = wfMsgHtml( 'rcshowhideliu', $liuLink );
178 - if( $wgUseNPPatrol )
179 - $links[] = wfMsgHtml( 'rcshowhidepatr', $patrLink );
180 - $hl = implode( ' | ', $links );
 183+ if( $wgUseNPPatrol )
 184+ $links[] = wfMsgHtml( 'rcshowhidepatr', $patrLink );
 185+ $links[] = wfMsgHtml( 'rcshowhidebots', $botsLink );
 186+ $hl = implode( ' | ', $links );
181187
182188 $form = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) .
183189 Xml::hidden( 'title', $self->getPrefixedDBkey() ) .
@@ -230,16 +236,17 @@
231237 list( $limit, $offset ) = wfCheckLimits();
232238
233239 $defaults = array(
234 - /* bool */ 'hideliu' => false,
235 - /* bool */ 'hidepatrolled' => false,
236 - /* text */ 'namespace' => NS_MAIN,
237 - /* text */ 'username' => '',
238 - /* int */ 'offset' => $offset,
239 - /* int */ 'limit' => $limit,
240 - );
241 -
242 - extract($defaults);
 240+ /* bool */ 'hideliu' => false,
 241+ /* bool */ 'hidepatrolled' => false,
 242+ /* bool */ 'hidebots' => false,
 243+ /* text */ 'namespace' => NS_MAIN,
 244+ /* text */ 'username' => '',
 245+ /* int */ 'offset' => $offset,
 246+ /* int */ 'limit' => $limit,
 247+);
243248
 249+ extract($defaults);
 250+
244251 if ( $par ) {
245252 $bits = preg_split( '/\s*,\s*/', trim( $par ) );
246253 foreach ( $bits as $bit ) {
@@ -249,6 +256,8 @@
250257 $hideliu = true;
251258 if ( 'hidepatrolled' == $bit )
252259 $hidepatrolled = true;
 260+ if ( 'hidebots' == $bit )
 261+ $hidebots = true;
253262 if ( is_numeric( $bit ) )
254263 $limit = $bit;
255264
@@ -273,13 +282,14 @@
274283 $hideliu = $hliu;
275284 if( $hpatrolled = $wgRequest->getBool( 'hidepatrolled' ) )
276285 $hidepatrolled = $hpatrolled;
277 -
 286+ if( $hbots = $wgRequest->getBool( 'hidebots' ) )
 287+ $hidebots = $hbots;
278288 }
279289
280290 if ( ! isset( $shownavigation ) )
281291 $shownavigation = ! $specialPage->including();
282292
283 - $npp = new NewPagesPage( $namespace, $username, $hideliu, $hidepatrolled, $defaults );
 293+ $npp = new NewPagesPage( $namespace, $username, $hideliu, $hidepatrolled, $hidebots, $defaults );
284294
285295 if ( ! $npp->doFeed( $wgRequest->getVal( 'feed' ), $limit ) )
286296 $npp->doQuery( $offset, $limit, $shownavigation );
Index: trunk/phase3/RELEASE-NOTES
@@ -44,11 +44,11 @@
4545 * Removed "Clear" link in watchlist editor tools, as people were afraid to
4646 click it. Existing clear links will fall back to the raw editor, which is
4747 very easy to clear your watchlist with.
48 -* Allow hiding new pages by logged-in users on Special:Newpages
4948 * (bug 1405) Add wgUseNPPatrol option to control patroling for new articles
5049 on Special:Newpages
5150 * LogLine hook added to allow formatting custom entries in Special:Log.
5251 * Support for Iranian calendar
 52+* (bug 1401) Allow hiding logged-in users, bots and patrolled pages on Special:Newpages
5353
5454 === Bug fixes in 1.12 ===
5555

Status & tagging log