/** * Main special page entry point * * Handles requesting account closure. * * @requestParam string token - User's edit token * @responseParam string showForm - Whether or not to show the request form * @responseParam string introText - The introductory text that explains the * CloseMyAccount process * @responseParam string warning - Text of any warnings to show to the user * @responseParam string currentUserMessage - Text to confirm the current user * details * @responseParam string confirmationText - Text for the confirmation text box * @responseParam string submitButton - The HTML for the submit button * @return void */ public function index() { wfProfileIn(__METHOD__); $user = $this->getUser(); $this->specialPage->setHeaders(); if ($this->getPar() === 'reactivate') { $this->forward('CloseMyAccountSpecial', 'reactivate'); wfProfileOut(__METHOD__); return; } if (!$user->isLoggedIn()) { wfProfileOut(__METHOD__); $this->displayRestrictionError(); return; } $this->response->setTemplateEngine(WikiaResponse::TEMPLATE_ENGINE_MUSTACHE); $helper = new CloseMyAccountHelper(); $this->response->addModuleStyles('ext.closeMyAccount'); $waitPeriod = $this->getLanguage()->formatNum(CloseMyAccountHelper::CLOSE_MY_ACCOUNT_WAIT_PERIOD); $this->editToken = $user->getEditToken(); $this->showForm = true; if ($this->request->wasPosted() && $user->matchEditToken($this->getVal('token'))) { $scheduleCloseAccount = $helper->scheduleCloseAccount($user); $this->showForm = false; if ($scheduleCloseAccount) { $user->logout(); $this->introText = $this->msg('closemyaccount-scheduled', $this->getLanguage()->formatNum(CloseMyAccountHelper::CLOSE_MY_ACCOUNT_WAIT_PERIOD))->parseAsBlock(); } else { $this->introText = ''; $this->warning = $this->msg('closemyaccount-scheduled-failed')->parse(); } } else { $this->introText = $this->msg('closemyaccount-intro-text', $waitPeriod, $user->getName())->parseAsBlock(); $this->currentUserMessage = $this->msg('closemyaccount-logged-in-as', $user->getName())->parseAsBlock(); if (!$user->isEmailConfirmed()) { $this->warning = $this->msg('closemyaccount-unconfirmed-email')->parse(); } else { $this->currentUserMessage .= $this->msg('closemyaccount-current-email', $user->getEmail(), $user->getName())->parseAsBlock(); } $this->confirmationText = $this->msg('closemyaccount-confirm', $user->getName())->parse(); $buttonParams = ['type' => 'button', 'vars' => ['type' => 'submit', 'classes' => ['wikia-button', 'big', 'closemyaccount'], 'value' => $this->msg('closemyaccount-button-text')->text(), 'data' => []]]; $this->submitButton = \Wikia\UI\Factory::getInstance()->init('button')->render($buttonParams); } wfProfileOut(__METHOD__); }