private function isClosureRequested()
 {
     global $wgEnableCloseMyAccountExt;
     if (!empty($wgEnableCloseMyAccountExt)) {
         $closeAccountHelper = new CloseMyAccountHelper();
         return $closeAccountHelper->isScheduledForClosure($this->mUser) && !$closeAccountHelper->isClosed($this->mUser);
     }
     return false;
 }
 public function testIsClosed()
 {
     $userMock = $this->getMock('User', ['getGlobalFlag']);
     $userMock->expects($this->exactly(2))->method('getGlobalFlag')->with($this->equalTo('disabled'))->will($this->onConsecutiveCalls(1, 0));
     $closeAccountHelper = new CloseMyAccountHelper();
     $resultOne = $closeAccountHelper->isClosed($userMock);
     $this->assertTrue($resultOne);
     $resultTwo = $closeAccountHelper->isClosed($userMock);
     $this->assertFalse($resultTwo);
 }
 /**
  * Entry point for requesting that an account is reactivated
  *
  * This is the form users will be taken to after successfully attempting
  * to login to an account that has requested closure.
  *
  * @responseParam boolean showForm - Whether or not to show the request form
  * @responseParam string error - Whether or not an error occurred
  * @responseParam string introText - The introductory text that explains the
  *                                   reactivation process
  * @responseParam string submitButton - The HTML for the submit button
  * @return void
  */
 public function reactivateRequest()
 {
     wfProfileIn(__METHOD__);
     $this->response->setTemplateEngine(WikiaResponse::TEMPLATE_ENGINE_MUSTACHE);
     $userId = $this->request->getSessionData('closeAccountSessionId');
     $this->showForm = false;
     // Paranoia, if they got here, this shouldn't happen
     if ($userId === null) {
         $this->error = $this->msg('closemyaccount-reactivate-error-id')->escaped();
         wfProfileOut(__METHOD__);
         return;
     } elseif ($this->getUser()->isLoggedIn()) {
         $this->error = $this->msg('closemyaccount-reactivate-error-logged-in')->escaped();
         wfProfileOut(__METHOD__);
         return;
     }
     $helper = new CloseMyAccountHelper();
     $userObj = User::newFromId($userId);
     if ($helper->isClosed($userObj)) {
         $this->error = $this->msg('closemyaccount-reactivate-error-disabled')->parse();
         wfProfileOut(__METHOD__);
         return;
     }
     // Paranoia, shouldn't happen, but just in case...
     if (!$helper->isScheduledForClosure($userObj)) {
         $this->error = $this->msg('closemyaccount-reactivate-error-not-scheduled')->escaped();
         wfProfileOut(__METHOD__);
         return;
     }
     if (!$userObj->isEmailConfirmed()) {
         $this->error = $this->msg('closemyaccount-reactivate-error-email')->parse();
         wfProfileOut(__METHOD__);
         return;
     }
     $this->getOutput()->setPageTitle($this->msg('closemyaccount-reactivate-page-title')->plain());
     if ($this->request->wasPosted()) {
         $result = $helper->requestReactivation($userObj, $this->app);
         if ($result) {
             $this->introText = $this->msg('closemyaccount-reactivate-requested')->parseAsBlock();
         } else {
             $this->error = $this->msg('closemyaccount-reactivate-error-failed')->parse();
         }
     } else {
         $this->showForm = true;
         // Show how many days they have before their account is permanently closed
         $daysUntilClosure = $helper->getDaysUntilClosure($userObj);
         $this->introText = $this->msg('closemyaccount-reactivate-intro', $this->getLanguage()->formatNum($daysUntilClosure), $userObj->getName())->parseAsBlock();
         $buttonParams = ['type' => 'button', 'vars' => ['type' => 'submit', 'classes' => ['wikia-button', 'big', 'closemyaccount'], 'value' => $this->msg('closemyaccount-reactivate-button-text')->text(), 'data' => []]];
         $this->submitButton = \Wikia\UI\Factory::getInstance()->init('button')->render($buttonParams);
     }
     wfProfileOut(__METHOD__);
 }