From 94215f3416a0e3787d0518ff93ea20d576d6de74 Mon Sep 17 00:00:00 2001 From: Rob Church Date: Sat, 18 Mar 2006 22:47:40 +0000 Subject: [PATCH] (bug 4729) Add user preference that marks a user's edits as patrolled if user is able to --- RELEASE-NOTES | 2 +- includes/Article.php | 14 ++++++++++++-- includes/RecentChange.php | 7 +++---- includes/SpecialPreferences.php | 4 +++- languages/Language.php | 1 + languages/Messages.php | 1 + 6 files changed, 21 insertions(+), 8 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index e282a778d9..f151e54a71 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -705,7 +705,7 @@ fully support the editing toolbar, but was found to be too confusing. results that don't code back to their original values. * (bug 4611) Add user preference (default on) to add new pages to creators's watchlist * (bug 5286) Fix regression in display of missing/bad revision IDs - +* (bug 4729) Add user preference that marks a user's edits as patrolled if user is able to === Caveats === diff --git a/includes/Article.php b/includes/Article.php index cdfe6434d3..2d00bf1c38 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -1215,8 +1215,12 @@ class Article { Article::onArticleCreate( $this->mTitle ); if(!$suppressRC) { require_once( 'RecentChange.php' ); - RecentChange::notifyNew( $now, $this->mTitle, $isminor, $wgUser, $summary, 'default', + $rcid = RecentChange::notifyNew( $now, $this->mTitle, $isminor, $wgUser, $summary, 'default', '', strlen( $text ), $revisionId ); + # Mark as patrolled if the user can and has the option set + if( $wgUser->isAllowed( 'patrol' ) && $wgUser->getOption( 'autopatrol' ) ) { + RecentChange::markPatrolled( $rcid ); + } } if ($watchthis) { @@ -1424,9 +1428,15 @@ class Article { # Update recentchanges and purge cache and whatnot require_once( 'RecentChange.php' ); $bot = (int)($wgUser->isBot() || $forceBot); - RecentChange::notifyEdit( $now, $this->mTitle, $isminor, $wgUser, $summary, + $rcid = RecentChange::notifyEdit( $now, $this->mTitle, $isminor, $wgUser, $summary, $lastRevision, $this->getTimestamp(), $bot, '', $oldsize, $newsize, $revisionId ); + + # Mark as patrolled if the user can do so and has it set in their options + if( $wgUser->isAllowed( 'patrol' ) && $wgUser->getOption( 'autopatrol' ) ) { + RecentChange::markPatrolled( $rcid ); + } + $dbw->commit(); // Update caches outside the main transaction diff --git a/includes/RecentChange.php b/includes/RecentChange.php index 1a244587bf..06f9ce0f5b 100644 --- a/includes/RecentChange.php +++ b/includes/RecentChange.php @@ -116,10 +116,8 @@ class RecentChange # Insert new row $dbw->insert( 'recentchanges', $this->mAttribs, $fname ); - if ( $wgUseRCPatrol ) { - # Retrieve the id assigned by the db, but only if we'll use it later - $this->mAttribs['rc_id'] = $dbw->insertId(); - } + # Set the ID + $this->mAttribs['rc_id'] = $dbw->insertId(); # Update old rows, if necessary if ( $this->mAttribs['rc_type'] == RC_EDIT ) { @@ -242,6 +240,7 @@ class RecentChange 'newSize' => $newSize, ); $rc->save(); + return( $rc->mAttribs['rc_id'] ); } # Makes an entry in the database corresponding to page creation diff --git a/includes/SpecialPreferences.php b/includes/SpecialPreferences.php index fa7f9da0df..7af9b26fa6 100644 --- a/includes/SpecialPreferences.php +++ b/includes/SpecialPreferences.php @@ -817,9 +817,11 @@ class PreferencesForm { 'minordefault', 'externaleditor', 'externaldiff', - $wgLivePreview ? 'uselivepreview' : false, ) + $wgLivePreview ? 'uselivepreview' : false, + $wgUser->isAllowed( 'patrol' ) ? 'autopatrol' : false, ) ) . '' ); + $this->mUsedToggles['autopatrol'] = true; # Don't show this up for users who can't; the handler below is dumb and doesn't know it $wgOut->addHTML( '
' . htmlspecialchars(wfMsg('prefs-rc')) . '' . '