From: Rob Church Date: Tue, 16 Jan 2007 17:05:30 +0000 (+0000) Subject: * (bug 8621) Log revisions marked as patrolled X-Git-Tag: 1.31.0-rc.0~54364 X-Git-Url: http://git.cyclocoop.org/data/%24self?a=commitdiff_plain;h=c16298f2d2573677e70c81615901a8760b585261;p=lhc%2Fweb%2Fwiklou.git * (bug 8621) Log revisions marked as patrolled * 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() --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index b25915ec93..5b64df528a 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 == diff --git a/includes/Article.php b/includes/Article.php index bee90bf8ca..8357c26712 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -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 diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index 36d2b61245..0b1c82bf72 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -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', diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index e3a38b4b11..55b0b339a8 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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 diff --git a/includes/LogPage.php b/includes/LogPage.php index a0b45e7cd0..ad0e535a57 100644 --- a/includes/LogPage.php +++ b/includes/LogPage.php @@ -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 index 0000000000..e4f80ac86e --- /dev/null +++ b/includes/PatrolLog.php @@ -0,0 +1,84 @@ + + */ +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 diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index df9012fc27..3aed86e1d4 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -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.',