* (bug 8621) Log revisions marked as patrolled
authorRob Church <robchurch@users.mediawiki.org>
Tue, 16 Jan 2007 17:05:30 +0000 (17:05 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Tue, 16 Jan 2007 17:05:30 +0000 (17:05 +0000)
* Uses normal logging framework, but
** doesn't duplicate the log in recentchanges ;)
** uses a cleaner method to override LogPage::actionText() and do all the formatting
* Introduces PatrolLog::record()

RELEASE-NOTES
includes/Article.php
includes/AutoLoader.php
includes/DefaultSettings.php
includes/LogPage.php
includes/PatrolLog.php [new file with mode: 0644]
languages/messages/MessagesEn.php

index b25915e..5b64df5 100644 (file)
@@ -78,7 +78,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Suppress PHP warning about set_time_limit in installer when safe mode is on
 * (bug 3000) Fall back to SCRIPT_NAME plus QUERY_STRING when REQUEST_URI is
   not available, as on IIS with PHP-CGI
-
+* (bug 8621) Log revisions marked as patrolled
 
 == Languages updated ==
 
index bee90bf..8357c26 100644 (file)
@@ -1348,6 +1348,7 @@ class Article {
                                                # Mark as patrolled if the user can do so
                                                if( $wgUser->isAllowed( 'autopatrol' ) ) {
                                                        RecentChange::markPatrolled( $rcid );
+                                                       PatrolLog::record( $rcid, true );
                                                }
                                        }
                                        $wgUser->incEditCount();
@@ -1409,6 +1410,7 @@ class Article {
                                # Mark as patrolled if the user can
                                if( $wgUser->isAllowed( 'autopatrol' ) ) {
                                        RecentChange::markPatrolled( $rcid );
+                                       PatrolLog::record( $rcid, true );
                                }
                        }
                        $wgUser->incEditCount();
@@ -1514,6 +1516,7 @@ class Article {
                
                # Mark the edit as patrolled
                RecentChange::markPatrolled( $rcid );
+               PatrolLog::record( $rcid );
                wfRunHooks( 'MarkPatrolledComplete', array( &$rcid, &$wgUser, false ) );
                
                # Inform the user
index 36d2b61..0b1c82b 100644 (file)
@@ -240,6 +240,7 @@ function __autoload($className) {
                'UserloginTemplate' => 'includes/templates/Userlogin.php',
                'Language' => 'languages/Language.php',
                'PasswordResetForm' => 'includes/SpecialResetpass.php',
+               'PatrolLog' => 'includes/PatrolLog.php',
 
                // API classes
                'ApiBase' => 'includes/api/ApiBase.php',
index e3a38b4..55b0b33 100644 (file)
@@ -2004,7 +2004,9 @@ $wgLogTypes = array( '',
        'delete',
        'upload',
        'move',
-       'import' );
+       'import',
+       'patrol',
+);
 
 /**
  * Lists the message key string for each log type. The localized messages
@@ -2020,7 +2022,9 @@ $wgLogNames = array(
        'delete'  => 'dellogpage',
        'upload'  => 'uploadlogpage',
        'move'    => 'movelogpage',
-       'import'  => 'importlogpage' );
+       'import'  => 'importlogpage',
+       'patrol'  => 'patrol-log-page',
+);
 
 /**
  * Lists the message key string for descriptive text to be shown at the
@@ -2036,7 +2040,9 @@ $wgLogHeaders = array(
        'delete'  => 'dellogpagetext',
        'upload'  => 'uploadlogpagetext',
        'move'    => 'movelogpagetext',
-       'import'  => 'importlogpagetext', );
+       'import'  => 'importlogpagetext',
+       'patrol'  => 'patrol-log-header',
+);
 
 /**
  * Lists the message key string for formatting individual events of each
@@ -2058,7 +2064,8 @@ $wgLogActions = array(
        'move/move'         => '1movedto2',
        'move/move_redir'   => '1movedto2_redir',
        'import/upload'     => 'import-logentry-upload',
-       'import/interwiki'  => 'import-logentry-interwiki' );
+       'import/interwiki'  => 'import-logentry-interwiki',
+);
 
 /**
  * Experimental preview feature to fetch rendered text
index a0b45e7..ad0e535 100644 (file)
@@ -134,6 +134,10 @@ class LogPage {
                global $wgLang, $wgContLang, $wgLogActions;
 
                $key = "$type/$action";
+               
+               if( $key == 'patrol/patrol' )
+                       return PatrolLog::makeActionText( $title, $params, $skin );
+               
                if( isset( $wgLogActions[$key] ) ) {
                        if( is_null( $title ) ) {
                                $rv=wfMsg( $wgLogActions[$key] );
diff --git a/includes/PatrolLog.php b/includes/PatrolLog.php
new file mode 100644 (file)
index 0000000..e4f80ac
--- /dev/null
@@ -0,0 +1,84 @@
+<?php
+
+/**
+ * Class containing static functions for working with
+ * logs of patrol events
+ *
+ * @package MediaWiki
+ * @author Rob Church <robchur@gmail.com>
+ */
+class PatrolLog {
+
+       /**
+        * Record a log event for a change being patrolled
+        *
+        * @param mixed $change Change identifier or RecentChange object
+        * @param bool $auto Was this patrol event automatic?
+        */
+       public static function record( $change, $auto = false ) {
+               if( !( is_object( $change ) && $change instanceof RecentChange ) ) {
+                       $change = RecentChange::newFromId( $change );
+                       if( !is_object( $change ) )
+                               return false;
+               }
+               $title = Title::makeTitleSafe( $change->getAttribute( 'rc_namespace' ),
+                                       $change->getAttribute( 'rc_title' ) );
+               if( is_object( $title ) ) {
+                       $params = self::buildParams( $change, $auto );
+                       $log = new LogPage( 'patrol', false ); # False suppresses RC entries
+                       $log->addEntry( 'patrol', $title, '', $params );
+                       return true;
+               } else {
+                       return false;
+               }
+       }
+       
+       /**
+        * Generate the log action text corresponding to a patrol log item
+        *
+        * @param Title $title Title of the page that was patrolled
+        * @param array $params Log parameters (from logging.log_params)
+        * @param Skin $skin Skin to use for building links, etc.
+        * @return string
+        */
+       public static function makeActionText( $title, $params, $skin ) {
+               # This is a bit of a hack, but...if $skin is not a Skin, then *do nothing*
+               # -- this is fine, because the action text we would be queried for under
+               # these conditions would have gone into recentchanges, which we aren't
+               # supposed to be updating
+               if( is_object( $skin ) ) {
+                       list( $cur, $prev, $auto ) = $params;
+                       # Standard link to the page in question
+                       $link = $skin->makeLinkObj( $title );
+                       # Generate a diff link
+                       $bits[] = 'oldid=' . urlencode( $cur );
+                       $bits[] = 'diff=prev';
+                       $bits = implode( '&', $bits );
+                       $diff = $skin->makeLinkObj( $title, htmlspecialchars( wfMsg( 'patrol-log-diff', $cur ) ), $bits );
+                       # Indicate whether or not the patrolling was automatic
+                       $auto = $auto ? wfMsgHtml( 'patrol-log-auto' ) : '';
+                       # Put it all together
+                       return wfMsgHtml( 'patrol-log-line', $diff, $link, $auto );
+               } else {
+                       return '';
+               }
+       }
+       
+       /**
+        * Prepare log parameters for a patrolled change
+        *
+        * @param RecentChange $change RecentChange to represent
+        * @param bool $auto Whether the patrol event was automatic
+        * @return array
+        */
+       private static function buildParams( $change, $auto ) {
+               return array(
+                       $change->getAttribute( 'rc_this_oldid' ),
+                       $change->getAttribute( 'rc_last_oldid' ),
+                       (int)$auto
+               );
+       }
+
+}
+
+?>
\ No newline at end of file
index df9012f..3aed86e 100644 (file)
@@ -2236,6 +2236,13 @@ All transwiki import actions are logged at the [[Special:Log/import|import log]]
 'markedaspatrollederrortext' => "You need to specify a revision to mark as patrolled.",
 'markedaspatrollederror-noautopatrol' => 'You are not allowed to mark your own changes as patrolled.',
 
+# Patrol log
+'patrol-log-page' => 'Patrol log',
+'patrol-log-header' => '',
+'patrol-log-line' => 'marked $1 of $2 patrolled $3',
+'patrol-log-auto' => '(automatic)',
+'patrol-log-diff' => 'r$1',
+
 # image deletion
 'deletedrevision' => 'Deleted old revision $1.',