Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php |
— | — | @@ -147,13 +147,29 @@ |
148 | 148 | */ |
149 | 149 | public function isReviewable( $titleOnly = false ) { |
150 | 150 | global $wgFlaggedRevsReviewForDefault; |
151 | | - if( !FlaggedRevs::isPageReviewable( $this->parent->getTitle() ) ) |
| 151 | + if( !FlaggedRevs::isPageReviewable( $this->parent->getTitle() ) ) { |
152 | 152 | return false; |
153 | | - if( !$titleOnly && $wgFlaggedRevsReviewForDefault && !$this->showStableByDefault() ) |
| 153 | + } else if( !$titleOnly && $wgFlaggedRevsReviewForDefault && !$this->showStableByDefault() ) { |
154 | 154 | return false; |
| 155 | + } |
155 | 156 | return true; |
156 | 157 | } |
157 | 158 | |
| 159 | + /** |
| 160 | + * Is this page in patrolable? |
| 161 | + * @param bool $titleOnly, only check if title is in reviewable namespace |
| 162 | + * @return bool |
| 163 | + */ |
| 164 | + public function isPatrollable( $titleOnly = false ) { |
| 165 | + global $wgFlaggedRevsReviewForDefault; |
| 166 | + if( FlaggedRevs::isPagePatrollable( $this->parent->getTitle() ) ) { |
| 167 | + return true; |
| 168 | + } else if( !$titleOnly && $wgFlaggedRevsReviewForDefault && !$this->showStableByDefault() ) { |
| 169 | + return true; |
| 170 | + } |
| 171 | + return false; |
| 172 | + } |
| 173 | + |
158 | 174 | /** |
159 | 175 | * Is this article rateable? |
160 | 176 | */ |
— | — | @@ -209,7 +225,7 @@ |
210 | 226 | public function setPageContent( &$outputDone, &$pcache ) { |
211 | 227 | global $wgRequest, $wgOut, $wgUser, $wgLang; |
212 | 228 | # Only trigger for reviewable pages |
213 | | - if( !$this->isReviewable(true) ) { |
| 229 | + if( !$this->isReviewable() ) { |
214 | 230 | return true; |
215 | 231 | } |
216 | 232 | # Only trigger on article view for content pages, not for protect/delete/hist... |
— | — | @@ -728,13 +744,13 @@ |
729 | 745 | public function addPatrolLink( &$outputDone, &$pcache ) { |
730 | 746 | global $wgRequest, $wgOut, $wgUser; |
731 | 747 | # For unreviewable pages, allow for basic patrolling |
732 | | - if( !FlaggedRevs::isPagePatrollable( $this->parent->getTitle() ) ) { |
| 748 | + if( !$this->isPatrollable() ) { |
733 | 749 | return true; |
734 | 750 | } |
735 | 751 | # If we have been passed an &rcid= parameter, we want to give the user a |
736 | 752 | # chance to mark this new article as patrolled. |
737 | 753 | $rcid = $wgRequest->getIntOrNull( 'rcid' ); |
738 | | - if( !is_null( $rcid ) && $rcid != 0 && $wgUser->isAllowed( 'review' ) ) { |
| 754 | + if( !empty($rcid) && $wgUser->isAllowed( 'review' ) ) { |
739 | 755 | wfLoadExtensionMessages( 'FlaggedRevs' ); |
740 | 756 | $reviewTitle = SpecialPage::getTitleFor( 'RevisionReview' ); |
741 | 757 | $token = $wgUser->editToken( $this->parent->getTitle()->getPrefixedText(), $rcid ); |
— | — | @@ -753,7 +769,7 @@ |
754 | 770 | public function addVisibilityLink( &$data ) { |
755 | 771 | global $wgUser, $wgRequest, $wgOut; |
756 | 772 | # Check only if the title is reviewable |
757 | | - if( !$this->isReviewable(true) ) { |
| 773 | + if( !$this->isReviewable() ) { |
758 | 774 | return true; |
759 | 775 | } |
760 | 776 | $action = $wgRequest->getVal( 'action', 'view' ); |
— | — | @@ -784,8 +800,25 @@ |
785 | 801 | global $wgRequest, $wgUser, $wgFlaggedRevTabs; |
786 | 802 | $title = $this->parent->getTitle()->getSubjectPage(); |
787 | 803 | # Non-content pages cannot be validated |
788 | | - if( !FlaggedRevs::isPageReviewable( $title ) || !$title->exists() ) |
| 804 | + if( !$this->isReviewable(true) || !$title->exists() ) |
789 | 805 | return true; |
| 806 | + # We can change the behavoir of stable version for this page to be different |
| 807 | + # than the site default. |
| 808 | + if( !$skin->mTitle->isTalkPage() && $wgUser->isAllowed('stablesettings') ) { |
| 809 | + wfLoadExtensionMessages( 'Stabilization' ); |
| 810 | + $stableTitle = SpecialPage::getTitleFor( 'Stabilization' ); |
| 811 | + if( !isset($contentActions['protect']) && !isset($contentActions['unprotect']) ) { |
| 812 | + wfLoadExtensionMessages( 'Stabilization' ); |
| 813 | + $contentActions['default'] = array( |
| 814 | + 'class' => false, |
| 815 | + 'text' => wfMsg('stabilization-tab'), |
| 816 | + 'href' => $stableTitle->getLocalUrl('page='.$title->getPrefixedUrl()) |
| 817 | + ); |
| 818 | + } |
| 819 | + } |
| 820 | + # Check config |
| 821 | + if( !$this->isReviewable() ) |
| 822 | + return true; |
790 | 823 | # If we are viewing a page normally, and it was overridden, |
791 | 824 | # change the edit tab to a "current revision" tab |
792 | 825 | $srev = $this->getStableRev(); |
— | — | @@ -813,20 +846,6 @@ |
814 | 847 | $contentActions['viewsource']['href'] = $title->getLocalUrl( 'action=edit' ); |
815 | 848 | } |
816 | 849 | } |
817 | | - # We can change the behavoir of stable version for this page to be different |
818 | | - # than the site default. |
819 | | - if( !$skin->mTitle->isTalkPage() && $wgUser->isAllowed('stablesettings') ) { |
820 | | - wfLoadExtensionMessages( 'Stabilization' ); |
821 | | - $stableTitle = SpecialPage::getTitleFor( 'Stabilization' ); |
822 | | - if( !isset($contentActions['protect']) && !isset($contentActions['unprotect']) ) { |
823 | | - wfLoadExtensionMessages( 'Stabilization' ); |
824 | | - $contentActions['default'] = array( |
825 | | - 'class' => false, |
826 | | - 'text' => wfMsg('stabilization-tab'), |
827 | | - 'href' => $stableTitle->getLocalUrl('page='.$title->getPrefixedUrl()) |
828 | | - ); |
829 | | - } |
830 | | - } |
831 | 850 | // Add auxillary tabs... |
832 | 851 | if( !$wgFlaggedRevTabs || $synced ) |
833 | 852 | return true; |
— | — | @@ -937,8 +956,7 @@ |
938 | 957 | */ |
939 | 958 | public function addDiffNoticeAndIncludes( $diff, $oldRev, $newRev ) { |
940 | 959 | global $wgRequest, $wgUser, $wgOut, $wgMemc; |
941 | | - |
942 | | - if( $wgOut->isPrintable() || !FlaggedRevs::isPageReviewable( $newRev->getTitle() ) ) |
| 960 | + if( $wgOut->isPrintable() || !$this->isReviewable() ) |
943 | 961 | return true; |
944 | 962 | # Load required messages |
945 | 963 | wfLoadExtensionMessages( 'FlaggedRevs' ); |
— | — | @@ -1125,10 +1143,7 @@ |
1126 | 1144 | public function addPatrolAndDiffLink( $diff, $oldRev, $newRev ) { |
1127 | 1145 | global $wgUser, $wgOut; |
1128 | 1146 | // Is there a stable version? |
1129 | | - if( FlaggedRevs::isPageReviewable( $newRev->getTitle() ) ) { |
1130 | | - if( !$oldRev ) { |
1131 | | - return true; |
1132 | | - } |
| 1147 | + if( $oldRev && $this->isReviewable() ) { |
1133 | 1148 | wfLoadExtensionMessages( 'FlaggedRevs' ); |
1134 | 1149 | $frev = $this->getStableRev(); |
1135 | 1150 | if( $frev && $frev->getRevId() == $oldRev->getID() && $newRev->isCurrent() ) { |
— | — | @@ -1145,19 +1160,18 @@ |
1146 | 1161 | } |
1147 | 1162 | } |
1148 | 1163 | // Prepare a change patrol link, if applicable |
1149 | | - } else if( FlaggedRevs::isPagePatrollable( $newRev->getTitle() ) && $wgUser->isAllowed( 'review' ) ) { |
| 1164 | + } else if( $this->isPatrollable() && $wgUser->isAllowed( 'review' ) ) { |
1150 | 1165 | wfLoadExtensionMessages( 'FlaggedRevs' ); |
1151 | 1166 | // If we've been given an explicit change identifier, use it; saves time |
1152 | 1167 | if( $diff->mRcidMarkPatrolled ) { |
1153 | 1168 | $rcid = $diff->mRcidMarkPatrolled; |
1154 | 1169 | } else { |
1155 | 1170 | # Look for an unpatrolled change corresponding to this diff |
1156 | | - $dbr = wfGetDB( DB_SLAVE ); |
1157 | 1171 | $change = RecentChange::newFromConds( |
1158 | 1172 | array( |
1159 | 1173 | # Add redundant user,timestamp condition so we can use the existing index |
1160 | 1174 | 'rc_user_text' => $diff->mNewRev->getRawUserText(), |
1161 | | - 'rc_timestamp' => $dbr->timestamp( $diff->mNewRev->getTimestamp() ), |
| 1175 | + 'rc_timestamp' => wfGetDB( DB_SLAVE )->timestamp( $diff->mNewRev->getTimestamp() ), |
1162 | 1176 | 'rc_this_oldid' => $diff->mNewid, |
1163 | 1177 | 'rc_last_oldid' => $diff->mOldid, |
1164 | 1178 | 'rc_patrolled' => 0 |