/**
  * Redirect users out to review the changes to the stable version.
  * Only for people who can review and for pages that have a stable version.
  */
 public function injectPostEditURLParams(&$sectionAnchor, &$extraQuery)
 {
     $reqUser = $this->getUser();
     $this->load();
     $this->article->loadPageData('fromdbmaster');
     # Get the stable version from the master
     $frev = $this->article->getStableRev();
     if (!$frev || !$this->article->revsArePending()) {
         return true;
         // only for pages with pending edits
     }
     $params = array();
     // If the edit was not autoreviewed, and the user can actually make a
     // new stable version, then go to the diff...
     if ($frev->userCanSetFlags($reqUser)) {
         $params += array('oldid' => $frev->getRevId(), 'diff' => 'cur', 'shownotice' => 1);
         $params += FlaggedRevs::diffOnlyCGI();
         // ...otherwise, go to the draft revision after completing an edit.
         // This allows for users to immediately see their changes.
     } else {
         $params += array('stable' => 0);
         // Show a notice at the top of the page for non-reviewers...
         if (!$reqUser->isAllowed('review') && $this->article->isStableShownByDefault()) {
             $params += array('shownotice' => 1);
             if ($sectionAnchor) {
                 // Pass a section parameter in the URL as needed to add a link to
                 // the "your changes are pending" box on the top of the page...
                 $section = str_replace(array(':', '.'), array('%3A', '%'), substr($sectionAnchor, 1));
                 $params += array('fromsection' => $section);
                 $sectionAnchor = '';
                 // go to the top of the page to see notice
             }
         }
     }
     if ($extraQuery !== '') {
         $extraQuery .= '&';
     }
     $extraQuery .= wfArrayToCGI($params);
     // note: EditPage will add initial "&"
     return true;
 }
 public function formatRow($row)
 {
     $css = $quality = $underReview = '';
     $title = Title::newFromRow($row);
     $stxt = ChangesList::showCharacterDifference($row->rev_len, $row->page_len);
     # Page links...
     $link = Linker::link($title);
     $hist = Linker::linkKnown($title, wfMsgHtml('hist'), array(), 'action=history');
     $review = Linker::linkKnown($title, wfMsg('pendingchanges-diff'), array(), array('diff' => 'cur', 'oldid' => $row->stable) + FlaggedRevs::diffOnlyCGI());
     # Show quality level if there are several
     if (FlaggedRevs::qualityVersions()) {
         $quality = $row->quality ? wfMsgHtml('revreview-lev-quality') : wfMsgHtml('revreview-lev-basic');
         $quality = " <b>[{$quality}]</b>";
     }
     # Is anybody watching?
     if (!$this->including() && $this->getUser()->isAllowed('unreviewedpages')) {
         $uw = FRUserActivity::numUsersWatchingPage($title);
         $watching = $uw ? wfMsgExt('pendingchanges-watched', 'parsemag', $this->getLang()->formatNum($uw)) : wfMsgHtml('pendingchanges-unwatched');
         $watching = " {$watching}";
     } else {
         $uw = -1;
         $watching = '';
         // leave out data
     }
     # Get how long the first unreviewed edit has been waiting...
     if ($row->pending_since) {
         $firstPendingTime = wfTimestamp(TS_UNIX, $row->pending_since);
         $hours = ($this->currentUnixTS - $firstPendingTime) / 3600;
         // After three days, just use days
         if ($hours > 3 * 24) {
             $days = round($hours / 24, 0);
             $age = wfMsgExt('pendingchanges-days', 'parsemag', $this->getLang()->formatNum($days));
             // If one or more hours, use hours
         } elseif ($hours >= 1) {
             $hours = round($hours, 0);
             $age = wfMsgExt('pendingchanges-hours', 'parsemag', $this->getLang()->formatNum($hours));
         } else {
             $age = wfMsg('pendingchanges-recent');
             // hot off the press :)
         }
         // Oh-noes!
         $css = self::getLineClass($hours, $uw);
         $css = $css ? " class='{$css}'" : "";
     } else {
         $age = "";
         // wtf?
     }
     # Show if a user is looking at this page
     list($u, $ts) = FRUserActivity::getUserReviewingDiff($row->stable, $row->page_latest);
     if ($u !== null) {
         $underReview = ' <span class="fr-under-review">' . wfMsgHtml('pendingchanges-viewing') . '</span>';
     }
     return "<li{$css}>{$link} ({$hist}) {$stxt} ({$review}) <i>{$age}</i>" . "{$quality}{$watching}{$underReview}</li>";
 }
 /**
  * Create revision, diff, and history links for log line entry
  */
 public static function reviewLogLinks($action, $title, $params)
 {
     global $wgLang;
     $links = '';
     # Show link to page with oldid=x as well as the diff to the former stable rev.
     # Param format is <rev id, last stable id, rev timestamp>.
     if (isset($params[0])) {
         $revId = (int) $params[0];
         // the revision reviewed
         $oldStable = isset($params[1]) ? (int) $params[1] : 0;
         # Show diff to changes since the prior stable version
         if ($oldStable && $revId > $oldStable) {
             $msg = FlaggedRevsLog::isReviewDeapproval($action) ? 'review-logentry-diff2' : 'review-logentry-diff';
             // reviewed
             $links .= '(';
             $links .= Linker::linkKnown($title, wfMessage($msg)->escaped(), array(), array('oldid' => $oldStable, 'diff' => $revId));
             $links .= ')';
         }
         # Show a diff link to this revision
         $ts = empty($params[2]) ? Revision::getTimestampFromId($title, $revId) : $params[2];
         $time = $wgLang->timeanddate($ts, true);
         $links .= ' (';
         $links .= Linker::linkKnown($title, wfMessage('review-logentry-id', $revId, $time)->escaped(), array(), array('oldid' => $revId, 'diff' => 'prev') + FlaggedRevs::diffOnlyCGI());
         $links .= ')';
     }
     return $links;
 }
 public static function addToChangeListLine(&$list, &$articlelink, &$s, RecentChange &$rc)
 {
     global $wgUser;
     $title = $rc->getTitle();
     // convenience
     if (!FlaggedRevs::inReviewNamespace($title) || empty($rc->mAttribs['rc_this_oldid']) || !array_key_exists('fp_stable', $rc->mAttribs)) {
         return true;
         // confirm that page is in reviewable namespace
     }
     $rlink = $css = '';
     // page is not reviewed
     if ($rc->mAttribs['fp_stable'] == null) {
         // Is this a config were pages start off reviewable?
         // Hide notice from non-reviewers due to vandalism concerns (bug 24002).
         if (!FlaggedRevs::useOnlyIfProtected() && $wgUser->isAllowed('review')) {
             $rlink = wfMsgHtml('revreview-unreviewedpage');
             $css = 'flaggedrevs-unreviewed';
         }
         // page is reviewed and has pending edits (use timestamps; bug 15515)
     } elseif (isset($rc->mAttribs['fp_pending_since']) && $rc->mAttribs['rc_timestamp'] >= $rc->mAttribs['fp_pending_since']) {
         $rlink = $list->skin->link($title, wfMsgHtml('revreview-reviewlink'), array('title' => wfMsg('revreview-reviewlink-title')), array('oldid' => $rc->mAttribs['fp_stable'], 'diff' => 'cur') + FlaggedRevs::diffOnlyCGI());
         $css = 'flaggedrevs-pending';
     }
     if ($rlink != '') {
         $articlelink .= " <span class=\"mw-fr-reviewlink {$css}\">[{$rlink}]</span>";
     }
     return true;
 }