From 0adea58af3177e9e62a3e586064113a8e80410f0 Mon Sep 17 00:00:00 2001 From: krisfield Date: Wed, 20 Feb 2019 16:37:02 -0600 Subject: [PATCH] Fix viewing other user reviews (#99) --- i18n/en.json | 3 ++- specials/SpecialPendingReviews.php | 26 ++++++++++++++++---------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/i18n/en.json b/i18n/en.json index 2a0d49b..15aeceb 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -89,7 +89,8 @@ "pendingreviews-timediff-just-now": "Changed just now", "pendingreviews-no-revisions": "No page content changes", "pendingreviews-num-reviews": "You have $1 pending {{PLURAL:$1|review|reviews}}", - "pendingreviews-num-reviews-complete": "Congrats! You completed your reviews." , + "pendingreviews-num-reviews-complete": "Congrats! You completed your reviews.", + "pendingreviews-num-other-user-reviews": "$1 has $2 pending {{PLURAL:$2|review|reviews}}", "pendingreviews-num-approvals": "/$1 pending {{PLURAL:$1|approval|approvals}}.", "pendingreviews-reviewer-criticality-danger": "Pages reviewed by 0 - {{PLURAL:$1|1 person|$1 people}}", "pendingreviews-reviewer-criticality-danger-zero": "Pages reviewed by 0 people", diff --git a/specials/SpecialPendingReviews.php b/specials/SpecialPendingReviews.php index 5c0219c..9dd0aed 100644 --- a/specials/SpecialPendingReviews.php +++ b/specials/SpecialPendingReviews.php @@ -91,7 +91,7 @@ public function __construct() { * @return bool */ public function execute( $parser = null ) { - global $wgOut, $wgUser; + global $wgOut; $this->setHeaders(); @@ -128,7 +128,7 @@ public function execute( $parser = null ) { // Check that Approved Revs is installed $useApprovedRevs = class_exists( 'ApprovedRevs' ); - $html = $this->getPageHeader( $wgUser, $useApprovedRevs ); + $html = $this->getPageHeader( $this->mUser, $useApprovedRevs ); $html .= ''; $rowCount = 0; @@ -660,10 +660,7 @@ public function getPageHeader( User $user, $useApprovedRevs ) { $prevReviewSet = max( [ 0, $this->reviewOffset - $this->reviewLimit ] ); $currentURL = $this->getPageTitle()->getLocalUrl(); - $viewingUser = ''; - // if ( $this->mUser ) { - // $viewingUser = '&user='.$this->mUser; - // } + $viewingUser = '&user=' . $this->mUser; $linkClass = "pendingreviews-nav-link"; if ( $this->reviewOffset == 0 ) { @@ -695,13 +692,22 @@ public function getPageHeader( User $user, $useApprovedRevs ) { wfMessage( 'watchanalytics-pendingreviews-next-revisions' )->text() ); - if ( $numPendingReviews != 0 ) { - // message like "You have X pending reviews" - $html .= '

' . wfMessage( 'pendingreviews-num-reviews', $numPendingReviews, $this->reviewLimit )->text() . '

'; + $html .= '

'; + + if ( !( $this->getRequest()->getVal( 'user' ) ) ) { + if ( $numPendingReviews != 0 ) { + // message like "You have X pending reviews" + $html .= wfMessage( 'pendingreviews-num-reviews', $numPendingReviews )->text(); + } else { + // message like "Congrats you finished your reviews!" + $html .= wfMessage( 'pendingreviews-num-reviews-complete' )->text(); + } } else { - $html .= '
' . wfMessage( 'pendingreviews-num-reviews-complete' )->text() . ''; + $html .= wfMessage( 'pendingreviews-num-other-user-reviews', $user, $numPendingReviews )->text(); } + $html .= '

'; + return $html; }