/**
  * This function does essentially the same as RevisionReview::AjaxReview,
  * except that it generates the template and image parameters itself.
  */
 public function execute()
 {
     global $wgUser;
     $params = $this->extractRequestParams();
     // Check basic permissions
     if (!$wgUser->isAllowed('review')) {
         $this->dieUsage("You don't have the right to review revisions.", 'permissiondenied');
     } elseif ($wgUser->isBlocked(false)) {
         $this->dieUsageMsg(array('blockedtext'));
     }
     $newRev = Revision::newFromId($params['oldid']);
     if (!$newRev || !$newRev->getTitle()) {
         $this->dieUsage("Cannot find a revision with the specified ID.", 'notarget');
     }
     $title = $newRev->getTitle();
     $fa = FlaggableWikiPage::getTitleInstance($title);
     if (!$fa->isReviewable()) {
         $this->dieUsage("Provided page is not reviewable.", 'notreviewable');
     }
     $status = false;
     if ($params['previd']) {
         // changes
         $oldRev = Revision::newFromId($params['previd']);
         if (!$oldRev || $oldRev->getPage() != $newRev->getPage()) {
             $this->dieUsage("Revisions do not belong to the same page.", 'notarget');
         }
         // Mark as reviewing...
         if ($params['reviewing']) {
             $status = FRUserActivity::setUserReviewingDiff($wgUser, $params['previd'], $params['oldid']);
             // Unmark as reviewing...
         } else {
             $status = FRUserActivity::clearUserReviewingDiff($wgUser, $params['previd'], $params['oldid']);
         }
     } else {
         // Mark as reviewing...
         if ($params['reviewing']) {
             $status = FRUserActivity::setUserReviewingPage($wgUser, $newRev->getPage());
             // Unmark as reviewing...
         } else {
             $status = FRUserActivity::clearUserReviewingPage($wgUser, $newRev->getPage());
         }
     }
     # Success in setting flag...
     if ($status === true) {
         $this->getResult()->addValue(null, $this->getModuleName(), array('result' => 'Success'));
         # Failure...
     } else {
         $this->getResult()->addValue(null, $this->getModuleName(), array('result' => 'Failure'));
     }
 }
 public function testUserReviewingPage()
 {
     $page = 910;
     FRUserActivity::clearAllReviewingPage($page);
     // clear
     $this->assertEquals(true, FRUserActivity::setUserReviewingPage($this->user, $page), "Set reviewing page succeeds");
     $this->assertEquals(true, FRUserActivity::clearUserReviewingPage($this->user, $page), "Unset reviewing page");
     $this->assertEquals(false, FRUserActivity::clearUserReviewingPage($this->user, $page), "Extra unset reviewing page");
     // set two instances...
     $this->assertEquals(true, FRUserActivity::setUserReviewingPage($this->user, $page), "Set reviewing page (1)");
     $this->assertEquals(true, FRUserActivity::setUserReviewingPage($this->user, $page), "Set reviewing page (2)");
     // clear both...
     $this->assertEquals(true, FRUserActivity::clearUserReviewingPage($this->user, $page), "Unset reviewing page (1)");
     $this->assertEquals(true, FRUserActivity::clearUserReviewingPage($this->user, $page), "Unset reviewing page (2)");
     // extra clears...
     $this->assertEquals(false, FRUserActivity::clearUserReviewingPage($this->user, $page), "Extra unset reviewing page");
 }