From d2013c99aa2622d9f1202069e77ff1155ee4ad64 Mon Sep 17 00:00:00 2001 From: Greg Maxwell Date: Thu, 1 Nov 2007 16:18:17 +0000 Subject: [PATCH] Switch Special:Newpages "Hide logged-in users" to use a link rather than a checkbox (per Brion), add a "Hide patrolled" link if NPPatrol is enabled, enable patrolled highlighting for all users, autopatrol new pages by autopatrol able users if NPPatrol is enabled. --- includes/Article.php | 2 +- includes/SpecialNewpages.php | 49 ++++++++++++++++++++++++------------ 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index cf9072cf33..4041e16ca4 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -1450,7 +1450,7 @@ class Article { $rcid = RecentChange::notifyNew( $now, $this->mTitle, $isminor, $wgUser, $summary, $bot, '', strlen( $text ), $revisionId ); # Mark as patrolled if the user can - if( $GLOBALS['wgUseRCPatrol'] && $wgUser->isAllowed( 'autopatrol' ) ) { + if( ($GLOBALS['wgUseRCPatrol'] || $GLOBALS['wgUseNPPatrol']) && $wgUser->isAllowed( 'autopatrol' ) ) { RecentChange::markPatrolled( $rcid ); PatrolLog::record( $rcid, true ); } diff --git a/includes/SpecialNewpages.php b/includes/SpecialNewpages.php index 6595852a66..eb9cb4d5e7 100644 --- a/includes/SpecialNewpages.php +++ b/includes/SpecialNewpages.php @@ -13,11 +13,13 @@ class NewPagesPage extends QueryPage { var $namespace; var $username = ''; var $hideliu; + var $hidepatrolled; - function NewPagesPage( $namespace = NS_MAIN, $username = '', $hideliu= false ) { + function NewPagesPage( $namespace = NS_MAIN, $username = '', $hideliu = false, $hidepatrolled = false ) { $this->namespace = $namespace; $this->username = $username; $this->hideliu = $hideliu; + $this->hidepatrolled = $hidepatrolled; } function getName() { @@ -31,14 +33,17 @@ class NewPagesPage extends QueryPage { function makeUserWhere( &$dbo ) { global $wgGroupPermissions; + $where = ''; + if ($this->hidepatrolled) + $where = ' AND rc_patrolled = 0'; if ($wgGroupPermissions['*']['createpage'] == true && $this->hideliu) { - return ' AND rc_user = 0'; + return $where . ' AND rc_user = 0'; } else { $title = Title::makeTitleSafe( NS_USER, $this->username ); if( $title ) { - return ' AND rc_user_text = ' . $dbo->addQuotes( $title->getText() ); + return $where . ' AND rc_user_text = ' . $dbo->addQuotes( $title->getText() ); } else { - return ''; + return $where; } } } @@ -51,7 +56,7 @@ class NewPagesPage extends QueryPage { function getSQL() { global $wgUser, $wgUseNPPatrol; - $usepatrol = ( $wgUseNPPatrol && $wgUser->isAllowed( 'patrol' ) ) ? 1 : 0; + $usepatrol = ( $wgUseNPPatrol ) ? 1 : 0; $dbr = wfGetDB( DB_SLAVE ); list( $recentchanges, $page ) = $dbr->tableNamesN( 'recentchanges', 'page' ); @@ -145,9 +150,23 @@ class NewPagesPage extends QueryPage { * @return string */ function getPageHeader() { - global $wgScript, $wgContLang, $wgGroupPermissions; + global $wgScript, $wgContLang, $wgGroupPermissions, $wgUser, $wgUseNPPatrol; $align = $wgContLang->isRTL() ? 'left' : 'right'; $self = SpecialPage::getTitleFor( $this->getName() ); + + // show/hide links + $showhide = array( wfMsg( 'show' ), wfMsg( 'hide' )); + $liuLink = $wgUser->getSkin()->makeKnownLink( $wgContLang->specialPage( 'Newpages' ), + 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 ) ); + $links = array(); + if( $wgGroupPermissions['*']['createpage'] == true ) + $links[] = wfMsgHtml( 'rcshowhideliu', $liuLink ); + if( $wgUseNPPatrol ) + $links[] = wfMsgHtml( 'rcshowhidepatr', $patrLink ); + $hl = implode( ' | ', $links ); + $form = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) . Xml::hidden( 'title', $self->getPrefixedDBkey() ) . Xml::openElement( 'table' ) . @@ -166,14 +185,7 @@ class NewPagesPage extends QueryPage { " . Xml::input( 'username', 30, $this->username, array( 'id' => 'mw-np-username' ) ) . " - "; - if ($wgGroupPermissions['*']['createpage'] == true) { - $form = $form . " - " . Xml::checkLabel( wfMsgHtml( 'rcshowhideliu', wfMsg( 'hide' ) ), - 'hideliu', 'hideliu', $this->hideliu, array( 'id' => 'mw-np-hideliu' ) ) . " - "; - } - $form = $form . " + " . $hl . " " . Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . @@ -192,7 +204,7 @@ class NewPagesPage extends QueryPage { * @return array */ function linkParameters() { - return( array( 'namespace' => $this->namespace, 'username' => $this->username, 'hideliu' => $this->hideliu ) ); + return( array( 'namespace' => $this->namespace, 'username' => $this->username, 'hideliu' => $this->hideliu, 'hidepatrolled' => $this->hidepatrolled ) ); } } @@ -207,6 +219,7 @@ function wfSpecialNewpages($par, $specialPage) { $namespace = NS_MAIN; $username = ''; $hideliu = false; + $hidepatrolled = false; if ( $par ) { $bits = preg_split( '/\s*,\s*/', trim( $par ) ); @@ -215,6 +228,8 @@ function wfSpecialNewpages($par, $specialPage) { $shownavigation = true; if ( 'hideliu' == $bit ) $hideliu = true; + if ( 'hidepatrolled' == $bit ) + $hidepatrolled = true; if ( is_numeric( $bit ) ) $limit = $bit; @@ -237,13 +252,15 @@ function wfSpecialNewpages($par, $specialPage) { $username = $un; if( $hliu = $wgRequest->getBool( 'hideliu' ) ) $hideliu = $hliu; + if( $hpatrolled = $wgRequest->getBool( 'hidepatrolled' ) ) + $hidepatrolled = $hpatrolled; } if ( ! isset( $shownavigation ) ) $shownavigation = ! $specialPage->including(); - $npp = new NewPagesPage( $namespace, $username, $hideliu ); + $npp = new NewPagesPage( $namespace, $username, $hideliu, $hidepatrolled ); if ( ! $npp->doFeed( $wgRequest->getVal( 'feed' ), $limit ) ) $npp->doQuery( $offset, $limit, $shownavigation ); -- 2.20.1