Index: trunk/phase3/includes/PageHistory.php |
— | — | @@ -44,6 +44,10 @@ |
45 | 45 | function getArticle() { |
46 | 46 | return $this->mArticle; |
47 | 47 | } |
| 48 | + |
| 49 | + function getTitle() { |
| 50 | + return $this->mTitle; |
| 51 | + } |
48 | 52 | |
49 | 53 | /** |
50 | 54 | * As we use the same small set of messages in various methods and that |
— | — | @@ -595,12 +599,14 @@ |
596 | 600 | } |
597 | 601 | |
598 | 602 | function getQueryInfo() { |
599 | | - return array( |
600 | | - 'tables' => 'revision', |
| 603 | + $queryInfo = array( |
| 604 | + 'tables' => array('revision'), |
601 | 605 | 'fields' => Revision::selectFields(), |
602 | 606 | 'conds' => array('rev_page' => $this->mPageHistory->mTitle->getArticleID() ), |
603 | | - 'options' => array( 'USE INDEX' => 'page_timestamp' ) |
| 607 | + 'options' => array( 'USE INDEX' => array('revision','page_timestamp') ) |
604 | 608 | ); |
| 609 | + wfRunHooks( 'PageHistoryPager::getQueryInfo', array( &$this, &$queryInfo ) ); |
| 610 | + return $queryInfo; |
605 | 611 | } |
606 | 612 | |
607 | 613 | function getIndexField() { |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | $wgExtensionCredits['specialpage'][] = array( |
21 | 21 | 'name' => 'Flagged Revisions', |
22 | 22 | 'author' => array( 'Aaron Schulz', 'Joerg Baach' ), |
23 | | - 'version' => '1.061', |
| 23 | + 'version' => '1.07', |
24 | 24 | 'url' => 'http://www.mediawiki.org/wiki/Extension:FlaggedRevs', |
25 | 25 | 'descriptionmsg' => 'flaggedrevs-desc', |
26 | 26 | ); |
— | — | @@ -195,6 +195,11 @@ |
196 | 196 | # How many hours pending review is considering long? |
197 | 197 | $wgFlaggedRevsLongPending = 3; |
198 | 198 | |
| 199 | +# Flagged revisions are always visible to users with rights below. |
| 200 | +# Use '*' for non-user accounts. |
| 201 | +$wgFlaggedRevsVisible = array(); |
| 202 | +$wgFlaggedRevsTalkVisible = true; |
| 203 | + |
199 | 204 | # End of configuration variables. |
200 | 205 | ######### |
201 | 206 | |
— | — | @@ -289,6 +294,9 @@ |
290 | 295 | # Image version display |
291 | 296 | $wgHooks['ImagePageFindFile'][] = 'FlaggedRevs::imagePageFindFile'; |
292 | 297 | |
| 298 | +# Visibility - experimental |
| 299 | +$wgHooks['userCan'][] = 'FlaggedRevs::userCanView'; |
| 300 | + |
293 | 301 | # Main hooks, overrides pages content, adds tags, sets tabs and permalink |
294 | 302 | $wgHooks['SkinTemplateTabs'][] = 'FlaggedRevs::setActionTabs'; |
295 | 303 | # Change last-modified footer |
— | — | @@ -303,6 +311,7 @@ |
304 | 312 | $wgHooks['BeforePageDisplay'][] = 'FlaggedRevs::addReviewForm'; |
305 | 313 | $wgHooks['BeforePageDisplay'][] = 'FlaggedRevs::addVisibilityLink'; |
306 | 314 | # Mark of items in page history |
| 315 | +$wgHooks['PageHistoryPager::getQueryInfo'][] = 'FlaggedRevs::addToHistQuery'; |
307 | 316 | $wgHooks['PageHistoryLineEnding'][] = 'FlaggedRevs::addToHistLine'; |
308 | 317 | $wgHooks['ImagePageFileHistoryLine'][] = 'FlaggedRevs::addToFileHistLine'; |
309 | 318 | # Page review on edit |
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php |
— | — | @@ -725,8 +725,7 @@ |
726 | 726 | if( !$this->isReviewable() || !$this->getStableRev() ) |
727 | 727 | return true; |
728 | 728 | $skin = $wgUser->getSkin(); |
729 | | - list($link,$class) = FlaggedRevs::makeStableVersionLink( |
730 | | - $this->parent->getTitle(), $row->rev_id, $skin, wfGetDB( DB_SLAVE ) ); |
| 729 | + list($link,$class) = FlaggedRevs::markHistoryRow( $this->parent->getTitle(), $row, $skin ); |
731 | 730 | if( $link ) { |
732 | 731 | $s = "<span class='$class'>$s</span> <small><strong>[$link]</strong></small>"; |
733 | 732 | } |
— | — | @@ -736,7 +735,7 @@ |
737 | 736 | /** |
738 | 737 | * Add link to stable version of reviewed revisions |
739 | 738 | */ |
740 | | - public function addToFileHistLine( $historyList, $file, &$row, &$class ) { |
| 739 | + public function addToFileHistLine( $historyList, $file, &$s, &$class ) { |
741 | 740 | global $wgUser; |
742 | 741 | # Non-content pages cannot be validated. Stable version must exist. |
743 | 742 | if( !$this->isReviewable() || !$this->getStableRev() ) |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php |
— | — | @@ -764,25 +764,16 @@ |
765 | 765 | /** |
766 | 766 | * Make stable version link and return the css |
767 | 767 | * @param Title $title |
768 | | - * @param int $rev_id |
769 | | - * @param Database $db, optional |
| 768 | + * @param Row $row, from history page |
770 | 769 | * @returns array (string,string) |
771 | 770 | */ |
772 | | - public static function makeStableVersionLink( $title, $rev_id, $skin, $db = NULL ) { |
773 | | - $db = $db ? $db : wfGetDB( DB_SLAVE ); |
774 | | - $row = $db->selectRow( 'flaggedrevs', |
775 | | - array( 'fr_quality', 'fr_user' ), |
776 | | - array( 'fr_page_id' => $title->getArticleID(), |
777 | | - 'fr_rev_id' => $rev_id ), |
778 | | - __METHOD__, |
779 | | - array( 'FORCE INDEX' => 'PRIMARY' ) |
780 | | - ); |
781 | | - if( $row ) { |
| 771 | + public static function markHistoryRow( $title, $row, $skin ) { |
| 772 | + if( isset($row->fr_quality) ) { |
782 | 773 | $css = FlaggedRevsXML::getQualityColor( $row->fr_quality ); |
783 | 774 | $user = User::whois( $row->fr_user ); |
784 | 775 | $msg = ($row->fr_quality >= 1) ? 'hist-quality-user' : 'hist-stable-user'; |
785 | 776 | $st = $title->getPrefixedDBkey(); |
786 | | - $link = "<span class='plainlinks'>".wfMsgExt($msg,array('parseinline'),$st,$rev_id,$user)."</span>"; |
| 777 | + $link = "<span class='plainlinks'>".wfMsgExt($msg,array('parseinline'),$st,$row->rev_id,$user)."</span>"; |
787 | 778 | } else { |
788 | 779 | return array("",""); |
789 | 780 | } |
— | — | @@ -1509,6 +1500,40 @@ |
1510 | 1501 | return true; |
1511 | 1502 | } |
1512 | 1503 | |
| 1504 | + /** |
| 1505 | + * Allow users to view reviewed pages. |
| 1506 | + */ |
| 1507 | + public static function userCanView( $title, $user, $action, $result ) { |
| 1508 | + global $wgFlaggedRevsVisible, $wgFlaggedRevsTalkVisible, $wgTitle; |
| 1509 | + # Assume $action may still not be set, in which case, treat it as 'view'... |
| 1510 | + if( !$wgFlaggedRevsVisible || $action != 'read' ) |
| 1511 | + return true; |
| 1512 | + # Admin may set this to false, rather than array()... |
| 1513 | + $groups = $user->getGroups(); |
| 1514 | + $groups[] = '*'; |
| 1515 | + if( empty($wgFlaggedRevsVisible) || !array_intersect($groups,$wgFlaggedRevsVisible) ) |
| 1516 | + return true; |
| 1517 | + # Is this a talk page? |
| 1518 | + if( $wgFlaggedRevsTalkVisible && $title->isTalkPage() ) { |
| 1519 | + $result = true; |
| 1520 | + return true; |
| 1521 | + } |
| 1522 | + # See if there is a stable version. Also, see if, given the page |
| 1523 | + # config and URL params, the page can be overriden. |
| 1524 | + $flaggedArticle = FlaggedArticle::getInstance( $title ); |
| 1525 | + if( $wgTitle && $wgTitle->equals( $title ) && $flaggedArticle->getStableRev( true ) ) { |
| 1526 | + // Cache stable version while we are at it. |
| 1527 | + if( $flaggedArticle->pageOverride() ) { |
| 1528 | + $result = true; |
| 1529 | + } |
| 1530 | + } else { |
| 1531 | + if( self::getStablePageRev( $title ) ) { |
| 1532 | + $result = true; |
| 1533 | + } |
| 1534 | + } |
| 1535 | + return true; |
| 1536 | + } |
| 1537 | + |
1513 | 1538 | /** |
1514 | 1539 | * When an edit is made by a reviewer, if the current revision is the stable |
1515 | 1540 | * version, try to automatically review it. |
— | — | @@ -1939,16 +1964,16 @@ |
1940 | 1965 | |
1941 | 1966 | static function onArticleViewHeader( $article, &$outputDone, &$pcache ) { |
1942 | 1967 | $flaggedArticle = FlaggedArticle::getInstance( $article ); |
1943 | | - $flaggedArticle->maybeUpdateMainCache( &$outputDone, &$pcache ); |
1944 | | - $flaggedArticle->setPageContent( &$outputDone, &$pcache ); |
1945 | | - $flaggedArticle->addPatrolLink( &$outputDone, &$pcache ); |
| 1968 | + $flaggedArticle->maybeUpdateMainCache( $outputDone, $pcache ); |
| 1969 | + $flaggedArticle->setPageContent( $outputDone, $pcache ); |
| 1970 | + $flaggedArticle->addPatrolLink( $outputDone, $pcache ); |
1946 | 1971 | return true; |
1947 | 1972 | } |
1948 | 1973 | |
1949 | 1974 | static function setPermaLink( $skin, &$navUrls, &$revId, &$id ) { |
1950 | 1975 | global $wgArticle; |
1951 | 1976 | if ( $wgArticle ) { |
1952 | | - FlaggedArticle::getInstance( $wgArticle )->setPermaLink( $skin, &$navUrls, &$revId, &$id ); |
| 1977 | + FlaggedArticle::getInstance( $wgArticle )->setPermaLink( $skin, $navUrls, $revId, $id ); |
1953 | 1978 | } |
1954 | 1979 | return true; |
1955 | 1980 | } |
— | — | @@ -1959,7 +1984,7 @@ |
1960 | 1985 | |
1961 | 1986 | static function addReviewForm( $out ) { |
1962 | 1987 | global $wgArticle; |
1963 | | - if ( $out->isArticleRelated() ) { |
| 1988 | + if ( $wgArticle && $out->isArticleRelated() ) { |
1964 | 1989 | FlaggedArticle::getInstance( $wgArticle )->addReviewForm( $out ); |
1965 | 1990 | } |
1966 | 1991 | return true; |
— | — | @@ -1967,23 +1992,34 @@ |
1968 | 1993 | |
1969 | 1994 | static function addVisibilityLink( $out ) { |
1970 | 1995 | global $wgArticle; |
1971 | | - if ( $out->isArticleRelated() ) { |
| 1996 | + if ( $wgArticle && $out->isArticleRelated() ) { |
1972 | 1997 | FlaggedArticle::getInstance( $wgArticle )->addVisibilityLink( $out ); |
1973 | 1998 | } |
1974 | 1999 | return true; |
1975 | 2000 | } |
1976 | 2001 | |
| 2002 | + static function addToHistQuery( $pager, &$queryInfo ) { |
| 2003 | + $flaggedArticle = FlaggedArticle::getInstance( $pager->mPageHistory->getTitle() ); |
| 2004 | + $pageID = $pager->mPageHistory->getTitle()->getArticleId(); |
| 2005 | + if( $flaggedArticle->isReviewable() ) { |
| 2006 | + $queryInfo['tables'][] = 'flaggedrevs'; |
| 2007 | + $queryInfo['fields'][] = 'fr_quality'; |
| 2008 | + $queryInfo['fields'][] = 'fr_user'; |
| 2009 | + $queryInfo['join_conds']['flaggedrevs'] = array( 'LEFT JOIN', "fr_page_id = {$pageID} AND fr_rev_id = rev_id" ); |
| 2010 | + } |
| 2011 | + return true; |
| 2012 | + } |
| 2013 | + |
1977 | 2014 | static function addToHistLine( $history, $row, &$s ) { |
1978 | | - return FlaggedArticle::getInstance( $history->getArticle() )->addToHistLine( $history, $row, &$s ); |
| 2015 | + return FlaggedArticle::getInstance( $history->getArticle() )->addToHistLine( $history, $row, $s ); |
1979 | 2016 | } |
1980 | 2017 | |
1981 | | - static function addToFileHistLine( $historyList, $file, &$row, &$rowClass ) { |
1982 | | - return FlaggedArticle::getInstance( $historyList->getImagePage() ) |
1983 | | - -> addToFileHistLine( $historyList, $file, &$row, &$rowClass ); |
| 2018 | + static function addToFileHistLine( $hist, $file, &$s, &$rowClass ) { |
| 2019 | + return FlaggedArticle::getInstance( $hist->getImagePage() )->addToFileHistLine( $hist, $file, $s, $rowClass ); |
1984 | 2020 | } |
1985 | 2021 | |
1986 | 2022 | static function injectReviewDiffURLParams( $article, &$sectionAnchor, &$extraQuery ) { |
1987 | | - return FlaggedArticle::getInstance( $article )->injectReviewDiffURLParams( &$sectionAnchor, &$extraQuery ); |
| 2023 | + return FlaggedArticle::getInstance( $article )->injectReviewDiffURLParams( $sectionAnchor, $extraQuery ); |
1988 | 2024 | } |
1989 | 2025 | |
1990 | 2026 | static function onDiffViewHeader( $diff, $oldRev, $newRev ) { |