Resolve bug 1405 (http://bugzilla.wikimedia.org/show_bug.cgi?id=1405). New option...
authorGreg Maxwell <gmaxwell@users.mediawiki.org>
Mon, 29 Oct 2007 20:38:58 +0000 (20:38 +0000)
committerGreg Maxwell <gmaxwell@users.mediawiki.org>
Mon, 29 Oct 2007 20:38:58 +0000 (20:38 +0000)
includes/Article.php
includes/DefaultSettings.php
includes/SpecialNewpages.php
languages/messages/MessagesEn.php

index c0484e7..1533ae9 100644 (file)
@@ -622,7 +622,7 @@ class Article {
        */
        function view() {
                global $wgUser, $wgOut, $wgRequest, $wgContLang;
-               global $wgEnableParserCache, $wgStylePath, $wgUseRCPatrol, $wgParser;
+               global $wgEnableParserCache, $wgStylePath, $wgParser;
                global $wgUseTrackbacks, $wgNamespaceRobotPolicies, $wgArticleRobotPolicies;
                $sk = $wgUser->getSkin();
 
@@ -868,7 +868,7 @@ class Article {
 
                # If we have been passed an &rcid= parameter, we want to give the user a
                # chance to mark this new article as patrolled.
-               if ( $wgUseRCPatrol && !is_null( $rcid ) && $rcid != 0 && $wgUser->isAllowed( 'patrol' ) ) {
+               if (!is_null( $rcid ) && $rcid != 0 && $wgUser->isAllowed( 'patrol' ) ) {
                        $wgOut->addHTML(
                                "<div class='patrollink'>" .
                                        wfMsgHtml( 'markaspatrolledlink',
@@ -1508,14 +1508,34 @@ class Article {
        }
 
        /**
-        * Mark this particular edit as patrolled
+        * Mark this particular edit/page as patrolled
         */
        function markpatrolled() {
-               global $wgOut, $wgRequest, $wgUseRCPatrol, $wgUser;
+               global $wgOut, $wgRequest, $wgUseRCPatrol, $wgUseNPPatrol, $wgUser;
                $wgOut->setRobotPolicy( 'noindex,nofollow' );
 
-               # Check RC patrol config. option
-               if( !$wgUseRCPatrol ) {
+               # Check patrol config options
+
+               if ( !($wgUseNPPatrol || $wgUseRCPatrol)) {
+                       $wgOut->errorPage( 'rcpatroldisabled', 'rcpatroldisabledtext' );
+                       return;         
+               }
+
+               # If we haven't been given an rc_id value, we can't do anything
+               $rcid = (int) $wgRequest->getVal('rcid');
+               $rc = $rcid ? RecentChange::newFromId($rcid) : null;
+               if ( is_null ( $rc ) )
+               {
+                       $wgOut->errorPage( 'markedaspatrollederror', 'markedaspatrollederrortext' );
+                       return;
+               }
+
+               if ( $rc->mAttribs['rc_type'] == RC_NEW && !$wgUseNPPatrol ) {
+                       $wgOut->errorpage( 'nppatroldisabled', 'nppatroldisabledtext' );
+                       return;
+               }
+               
+               if ( !$wgUseRCPatrol && $rc->mAttribs['rc_type'] != RC_NEW) {
                        $wgOut->errorPage( 'rcpatroldisabled', 'rcpatroldisabledtext' );
                        return;
                }
@@ -1529,19 +1549,15 @@ class Article {
                        return;
                }
 
-               # If we haven't been given an rc_id value, we can't do anything
-               $rcid = $wgRequest->getVal( 'rcid' );
-               if( !$rcid ) {
-                       $wgOut->errorPage( 'markedaspatrollederror', 'markedaspatrollederrortext' );
-                       return;
-               }
-
                # Handle the 'MarkPatrolled' hook
                if( !wfRunHooks( 'MarkPatrolled', array( $rcid, &$wgUser, false ) ) ) {
                        return;
                }
 
-               $return = SpecialPage::getTitleFor( 'Recentchanges' );
+               #It would be nice to see where the user had actually come from, but for now just guess
+               $returnto = $rc->mAttribs['rc_type'] == RC_NEW ? 'Newpages' : 'Recentchanges';
+               $return = Title::makeTitle( NS_SPECIAL, $returnto );
+
                # If it's left up to us, check that the user is allowed to patrol this edit
                # If the user has the "autopatrol" right, then we'll assume there are no
                # other conditions stopping them doing so
index 7bb13de..7339faf 100644 (file)
@@ -2019,6 +2019,9 @@ $wgExternalDiffEngine = false;
 /** Use RC Patrolling to check for vandalism */
 $wgUseRCPatrol = true;
 
+/** Use new page patrolling to check new pages on special:Newpages */
+$wgUseNPPatrol = true;
+
 /** Set maximum number of results to return in syndication feeds (RSS, Atom) for
  * eg Recentchanges, Newpages. */
 $wgFeedLimit = 50;
index ab92715..6595852 100644 (file)
@@ -50,8 +50,8 @@ class NewPagesPage extends QueryPage {
        }
 
        function getSQL() {
-               global $wgUser, $wgUseRCPatrol;
-               $usepatrol = ( $wgUseRCPatrol && $wgUser->isAllowed( 'patrol' ) ) ? 1 : 0;
+               global $wgUser, $wgUseNPPatrol;
+               $usepatrol = ( $wgUseNPPatrol && $wgUser->isAllowed( 'patrol' ) ) ? 1 : 0;
                $dbr = wfGetDB( DB_SLAVE );
                list( $recentchanges, $page ) = $dbr->tableNamesN( 'recentchanges', 'page' );
 
@@ -123,8 +123,8 @@ class NewPagesPage extends QueryPage {
         * @return bool
         */
        function patrollable( $result ) {
-               global $wgUser, $wgUseRCPatrol;
-               return $wgUseRCPatrol && $wgUser->isAllowed( 'patrol' ) && !$result->patrolled;
+               global $wgUser, $wgUseNPPatrol;
+               return $wgUseNPPatrol && $wgUser->isAllowed( 'patrol' ) && !$result->patrolled;
        }
 
        function feedItemDesc( $row ) {
index 1de89a3..3396c11 100644 (file)
@@ -2435,6 +2435,8 @@ All transwiki import actions are logged at the [[Special:Log/import|import log]]
 'markedaspatrollederror'              => 'Cannot mark as patrolled',
 'markedaspatrollederrortext'          => 'You need to specify a revision to mark as patrolled.',
 'markedaspatrollederror-noautopatrol' => 'You are not allowed to mark your own changes as patrolled.',
+'nppatroldisabled'                    => 'New Pages Patrol disabled',
+'nppatroldisabledtext'                => 'The New Pages Patrol feature is currently disabled.',
 
 # Patrol log
 'patrol-log-page'   => 'Patrol log',