From f2c323e431fb34513fce877939925e1f25e77f9e Mon Sep 17 00:00:00 2001 From: Victor Vasiliev Date: Mon, 5 Nov 2007 15:47:10 +0000 Subject: [PATCH] * (bug 1401) Allow hiding logged-in users, bots and patrolled pages on Special:Newpages --- RELEASE-NOTES | 2 +- includes/SpecialNewpages.php | 50 +++++++++++++++++++++--------------- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index a4617e231a..572652d68b 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -44,11 +44,11 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Removed "Clear" link in watchlist editor tools, as people were afraid to click it. Existing clear links will fall back to the raw editor, which is very easy to clear your watchlist with. -* Allow hiding new pages by logged-in users on Special:Newpages * (bug 1405) Add wgUseNPPatrol option to control patroling for new articles on Special:Newpages * LogLine hook added to allow formatting custom entries in Special:Log. * Support for Iranian calendar +* (bug 1401) Allow hiding logged-in users, bots and patrolled pages on Special:Newpages === Bug fixes in 1.12 === diff --git a/includes/SpecialNewpages.php b/includes/SpecialNewpages.php index 17f3974da8..6824b1c2bf 100644 --- a/includes/SpecialNewpages.php +++ b/includes/SpecialNewpages.php @@ -14,13 +14,15 @@ class NewPagesPage extends QueryPage { var $username; var $hideliu; var $hidepatrolled; + var $hidebots; var $defaults; - function NewPagesPage( $namespace, $username, $hideliu, $hidepatrolled, $defaults) { + function NewPagesPage( $namespace, $username, $hideliu, $hidepatrolled, $hidebots, $defaults) { $this->namespace = $namespace; $this->username = $username; $this->hideliu = $hideliu; $this->hidepatrolled = $hidepatrolled; + $this->hidebots = $hidebots; $this->defaults = $defaults; } @@ -37,17 +39,18 @@ class NewPagesPage extends QueryPage { global $wgGroupPermissions; $where = ''; if ($this->hidepatrolled) - $where = ' AND rc_patrolled = 0'; + $where .= ' AND rc_patrolled = 0'; + if ($this->hidebots) + $where .= ' AND rc_bot = 0'; if ($wgGroupPermissions['*']['createpage'] == true && $this->hideliu) { - return $where . ' AND rc_user = 0'; + $where .= ' AND rc_user = 0'; } else { $title = Title::makeTitleSafe( NS_USER, $this->username ); if( $title ) { - return $where . ' AND rc_user_text = ' . $dbo->addQuotes( $title->getText() ); - } else { - return $where; + $where .= ' AND rc_user_text = ' . $dbo->addQuotes( $title->getText() ); } } + return $where; } private function makeNamespaceWhere() { @@ -171,12 +174,15 @@ class NewPagesPage extends QueryPage { htmlspecialchars( $showhide[1-$this->hideliu] ), wfArrayToCGI( array( 'hideliu' => 1-$this->hideliu ), $nondefaults ) ); $patrLink = $wgUser->getSkin()->makeKnownLink( $wgContLang->specialPage( 'Newpages' ), htmlspecialchars( $showhide[1-$this->hidepatrolled] ), wfArrayToCGI( array( 'hidepatrolled' => 1-$this->hidepatrolled ), $nondefaults ) ); + $botsLink = $wgUser->getSkin()->makeKnownLink( $wgContLang->specialPage( 'Newpages' ), + htmlspecialchars( $showhide[1-$this->hidebots] ), wfArrayToCGI( array( 'hidebots' => 1-$this->hidebots ), $nondefaults ) ); $links = array(); if( $wgGroupPermissions['*']['createpage'] == true ) $links[] = wfMsgHtml( 'rcshowhideliu', $liuLink ); - if( $wgUseNPPatrol ) - $links[] = wfMsgHtml( 'rcshowhidepatr', $patrLink ); - $hl = implode( ' | ', $links ); + if( $wgUseNPPatrol ) + $links[] = wfMsgHtml( 'rcshowhidepatr', $patrLink ); + $links[] = wfMsgHtml( 'rcshowhidebots', $botsLink ); + $hl = implode( ' | ', $links ); $form = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) . Xml::hidden( 'title', $self->getPrefixedDBkey() ) . @@ -230,15 +236,16 @@ function wfSpecialNewpages($par, $specialPage) { list( $limit, $offset ) = wfCheckLimits(); $defaults = array( - /* bool */ 'hideliu' => false, - /* bool */ 'hidepatrolled' => false, - /* text */ 'namespace' => NS_MAIN, - /* text */ 'username' => '', - /* int */ 'offset' => $offset, - /* int */ 'limit' => $limit, - ); - - extract($defaults); + /* bool */ 'hideliu' => false, + /* bool */ 'hidepatrolled' => false, + /* bool */ 'hidebots' => false, + /* text */ 'namespace' => NS_MAIN, + /* text */ 'username' => '', + /* int */ 'offset' => $offset, + /* int */ 'limit' => $limit, +); + + extract($defaults); if ( $par ) { $bits = preg_split( '/\s*,\s*/', trim( $par ) ); @@ -249,6 +256,8 @@ function wfSpecialNewpages($par, $specialPage) { $hideliu = true; if ( 'hidepatrolled' == $bit ) $hidepatrolled = true; + if ( 'hidebots' == $bit ) + $hidebots = true; if ( is_numeric( $bit ) ) $limit = $bit; @@ -273,13 +282,14 @@ function wfSpecialNewpages($par, $specialPage) { $hideliu = $hliu; if( $hpatrolled = $wgRequest->getBool( 'hidepatrolled' ) ) $hidepatrolled = $hpatrolled; - + if( $hbots = $wgRequest->getBool( 'hidebots' ) ) + $hidebots = $hbots; } if ( ! isset( $shownavigation ) ) $shownavigation = ! $specialPage->including(); - $npp = new NewPagesPage( $namespace, $username, $hideliu, $hidepatrolled, $defaults ); + $npp = new NewPagesPage( $namespace, $username, $hideliu, $hidepatrolled, $hidebots, $defaults ); if ( ! $npp->doFeed( $wgRequest->getVal( 'feed' ), $limit ) ) $npp->doQuery( $offset, $limit, $shownavigation ); -- 2.20.1