r77275 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77274‎ | r77275 | r77276 >
Date:09:50, 25 November 2010
Author:aaron
Status:ok
Tags:
Comment:
(bug 25204) Notice about pending changes on watchlist should not be in sitenotice area
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -408,12 +408,10 @@
409409 $wgHooks['GetPreferences'][] = 'FlaggedRevsHooks::onGetPreferences';
410410 # Show unreviewed pages links
411411 $wgHooks['CategoryPageView'][] = 'FlaggedRevsHooks::onCategoryPageView';
412 -# Backlog notice
413 -$wgHooks['SiteNoticeAfter'][] = 'FlaggedRevsHooks::addBacklogNotice';
414412 # Review/stability log links
415413 $wgHooks['LogLine'][] = 'FlaggedRevsHooks::logLineLinks';
416414
417 -# Add CSS/JS and review notice
 415+# Add review notice, backlog notices and CSS/JS and set robots
418416 $wgHooks['BeforePageDisplay'][] = 'FlaggedRevsHooks::onBeforePageDisplay';
419417 # Add global JS vars
420418 $wgHooks['MakeGlobalVariablesScript'][] = 'FlaggedRevsHooks::injectGlobalJSVars';
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -166,6 +166,7 @@
167167 $view->setRobotPolicy(); // set indexing policy
168168 self::injectStyleAndJS(); // full CSS/JS
169169 } else {
 170+ self::maybeAddBacklogNotice( $out ); // RC/Watchlist notice
170171 self::injectStyleForSpecial( $out ); // try special page CSS
171172 }
172173 return true;
@@ -1835,36 +1836,36 @@
18361837 return true;
18371838 }
18381839
1839 - public static function addBacklogNotice( &$notice ) {
1840 - global $wgUser, $wgTitle;
1841 - $namespaces = FlaggedRevs::getReviewNamespaces();
1842 - if ( !count( $namespaces ) ) {
1843 - return true; // nothing to have a backlog on
1844 - } elseif ( empty( $wgTitle ) || $wgTitle->getNamespace() !== NS_SPECIAL ) {
1845 - return true; // nothing to do here
1846 - } elseif ( !$wgUser->isAllowed( 'review' ) ) {
 1840+ protected static function maybeAddBacklogNotice( OutputPage &$out ) {
 1841+ global $wgUser;
 1842+ if ( !$wgUser->isAllowed( 'review' ) ) {
18471843 return true; // not relevant to user
18481844 }
1849 - $watchlist = SpecialPage::getTitleFor( 'Watchlist' );
1850 - $recentchanges = SpecialPage::getTitleFor( 'Recentchanges' );
1851 - if ( $wgTitle->equals( $watchlist ) || $wgTitle->equals( $recentchanges ) ) {
1852 - $dbr = wfGetDB( DB_SLAVE, 'watchlist' );
1853 - $watchedOutdated = $dbr->selectField(
1854 - array( 'watchlist', 'page', 'flaggedpages' ),
1855 - '1', // existence
1856 - array( 'wl_user' => $wgUser->getId(), // this user
1857 - 'wl_namespace' => $namespaces, // reviewable
1858 - 'wl_namespace = page_namespace',
1859 - 'wl_title = page_title',
1860 - 'fp_page_id = page_id',
1861 - 'fp_reviewed' => 0, // edits pending
1862 - ), __METHOD__
1863 - );
1864 - # Give a notice if pages on the wachlist are outdated
1865 - if ( $watchedOutdated ) {
1866 - $css = 'plainlinks fr-watchlist-pending-notice';
1867 - $notice .= "<div id='mw-fr-watchlist-pending-notice' class='$css'>" .
1868 - wfMsgExt( 'flaggedrevs-watched-pending', 'parseinline' ) . "</div>";
 1845+ $title = $out->getTitle();
 1846+ $namespaces = FlaggedRevs::getReviewNamespaces();
 1847+ if ( $title->getNamespace() == NS_SPECIAL && $namespaces ) {
 1848+ $watchlist = SpecialPage::getTitleFor( 'Watchlist' );
 1849+ $recentchanges = SpecialPage::getTitleFor( 'Recentchanges' );
 1850+ # Notice applies only to RC/watchlists
 1851+ if ( $title->equals( $watchlist ) || $title->equals( $recentchanges ) ) {
 1852+ $dbr = wfGetDB( DB_SLAVE, 'watchlist' ); // consistency with watchlist
 1853+ $watchedOutdated = $dbr->selectField(
 1854+ array( 'watchlist', 'page', 'flaggedpages' ),
 1855+ '1', // existence
 1856+ array( 'wl_user' => $wgUser->getId(), // this user
 1857+ 'wl_namespace' => $namespaces, // reviewable
 1858+ 'wl_namespace = page_namespace',
 1859+ 'wl_title = page_title',
 1860+ 'fp_page_id = page_id',
 1861+ 'fp_reviewed' => 0, // edits pending
 1862+ ), __METHOD__
 1863+ );
 1864+ # Give a notice if pages on the users's wachlist have pending edits
 1865+ if ( $watchedOutdated ) {
 1866+ $css = 'plainlinks fr-watchlist-pending-notice';
 1867+ $out->prependHTML( "<div id='mw-fr-watchlist-pending-notice' class='$css'>" .
 1868+ wfMsgExt( 'flaggedrevs-watched-pending', 'parseinline' ) . "</div>" );
 1869+ }
18691870 }
18701871 }
18711872 return true;

Follow-up revisions

RevisionCommit summaryAuthorDate
r77740MFT r77275,r77738aaron19:51, 4 December 2010

Status & tagging log