/**
  * @brief serves standalone signup page on GET.  if POSTed, parameters will be required.
  * @details
  *   on GET, template will render
  *   on POST,
  *     if signup is successful, it will redirect to returnto, or mainpage of wiki
  *     if signup is not successful, the template will render error messages, highlighting the errors
  * @requestParam string username - on POST
  * @requestParam string email - on POST
  * @requestParam string password - on POST
  * @requestParam string birthmonth - on POST
  * @requestParam string birthday - on POST
  * @requestParam string birthyear - on POST
  * @requestParam string captcha - on POST
  * @requestParam string returnto - url to return to upon successful login
  * @requestParam string signupToken
  * @requestParam string uselang
  * @responseParam string result [ok/error]
  * @responseParam string msg - result message
  * @responseParam string errParam - error param
  */
 public function index()
 {
     $this->wg->Out->setPageTitle($this->wf->Msg('usersignup-page-title'));
     $this->response->addAsset('extensions/wikia/UserLogin/css/UserSignup.scss');
     if (F::app()->checkSkin('oasis')) {
         $this->response->addAsset('extensions/wikia/UserLogin/js/UserSignup.js');
     }
     if (!empty($this->wg->EnableFacebookConnectExt)) {
         $this->response->addAsset('extensions/wikia/UserLogin/js/UserLoginFacebookPageInit.js');
     }
     // hide things in the skin
     $this->wg->SuppressWikiHeader = true;
     $this->wg->SuppressPageHeader = true;
     $this->wg->SuppressFooter = true;
     $this->wg->SuppressAds = true;
     $this->wg->SuppressToolbar = true;
     // form params
     $this->username = $this->request->getVal('username', '');
     $this->email = $this->request->getVal('email', '');
     $this->password = $this->request->getVal('password', '');
     $this->birthmonth = $this->request->getVal('birthmonth', '');
     $this->birthday = $this->request->getVal('birthday', '');
     $this->birthyear = $this->request->getVal('birthyear', '');
     $this->returnto = $this->request->getVal('returnto', '');
     $this->byemail = $this->request->getBool('byemail', false);
     $this->signupToken = UserLoginHelper::getSignupToken();
     $this->uselang = $this->request->getVal('uselang', 'en');
     //fb#38260 -- removed uselang
     $this->avatars = $this->userLoginHelper->getRandomAvatars();
     $this->popularWikis = $this->userLoginHelper->getRandomWikis();
     // template params
     $this->pageHeading = wfMsg('usersignup-heading');
     $this->createAccountButtonLabel = wfMsg('createaccount');
     if ($this->byemail) {
         $this->pageHeading = wfMsg('usersignup-heading-byemail');
         $this->createAccountButtonLabel = wfMsg('usersignup-createaccount-byemail');
     }
     // process signup
     $redirected = $this->request->getVal('redirected', '');
     if ($this->wg->Request->wasPosted() && empty($redirected)) {
         $response = $this->app->sendRequest('UserSignupSpecial', 'signup');
         $this->result = $response->getVal('result', '');
         $this->msg = $response->getVal('msg', '');
         $this->errParam = $response->getVal('errParam', '');
         if ($this->result == 'ok') {
             $params = array('method' => 'sendConfirmationEmail', 'username' => $this->username, 'byemail' => intval($this->byemail));
             $redirectUrl = $this->wg->title->getFullUrl($params);
             $this->wg->out->redirect($redirectUrl);
         }
     }
 }
 /**
  * Displays Facebook sign up modal (called by index method)
  */
 public function modal()
 {
     // get an email from Facebook API
     $resp = $this->sendRequest('FacebookSignup', 'getFacebookData', array('fbUserId' => $this->getFacebookUserId()));
     // BugId:24400
     $data = $resp->getData();
     if (empty($data)) {
         $this->skipRendering();
         return false;
     }
     $this->fbEmail = $resp->getVal('contact_email', false);
     $email = $resp->getVal('email', false);
     // check for proxy email
     if ($this->fbEmail != $email) {
         $this->fbEmail = $this->wf->Msg('usersignup-facebook-proxy-email');
     }
     $this->loginToken = UserLoginHelper::getSignupToken();
     $this->specialUserLoginUrl = F::build('SpecialPage', array('UserLogin'), 'getTitleFor')->getLocalUrl();
     // FB feed option checkboxes
     $this->fbFeedOptions = F::build('FBConnectPushEvent', array(), 'getPreferencesToggles');
 }
 /**
  * Displays Facebook sign up modal (called by index method)
  */
 public function modal()
 {
     $fbUserId = $this->getFacebookUserId();
     if (empty($fbUserId)) {
         $this->skipRendering();
         return;
     }
     // get an email from Facebook API
     $userInfo = \FacebookClient::getInstance()->getUserInfo($fbUserId);
     // BugId:24400
     if (!$userInfo) {
         $this->skipRendering();
         return;
     }
     $returnToUrl = $this->userLoginHelper->getRedirectUrl('fbconnected=1');
     $returnTo = $this->wg->request->getVal('returnto');
     $returnToQuery = $this->wg->request->getVal('returntoquery');
     $returnToParams = 'returnto=' . $returnTo;
     if ($returnToQuery) {
         $returnToParams .= '&returntoquery=' . htmlspecialchars($returnToQuery);
     }
     $this->response->setData(['fbEmail' => $userInfo->getProperty('email'), 'returnToUrl' => $returnToUrl, 'queryString' => $returnToParams, 'loginToken' => UserLoginHelper::getSignupToken()]);
 }
 /**
  * @brief serves standalone signup page on GET.  if POSTed, parameters will be required.
  * @details
  *   on GET, template will render
  *   on POST,
  *     if signup is successful, it will redirect to returnto, or mainpage of wiki
  *     if signup is not successful, the template will render error messages, highlighting the errors
  * @requestParam string userloginext01 - on POST
  * @requestParam string email - on POST
  * @requestParam string password - on POST
  * @requestParam string birthmonth - on POST
  * @requestParam string birthday - on POST
  * @requestParam string birthyear - on POST
  * @requestParam string captcha - on POST
  * @requestParam string returnto - url to return to upon successful login
  * @requestParam string signupToken
  * @requestParam string uselang
  * @responseParam string result [ok/error]
  * @responseParam string msg - result message
  * @responseParam string errParam - error param
  */
 public function signupForm()
 {
     $this->wg->Out->setPageTitle(wfMessage('usersignup-page-title')->plain());
     $this->response->addAsset('extensions/wikia/UserLogin/css/UserSignup.scss');
     if ($this->app->checkSkin('oasis')) {
         $this->response->addAsset('user_signup_js');
     }
     // We're not supporting connecting with facebook from this page while logged in
     if (!empty($this->wg->EnableFacebookClientExt) && !$this->wg->User->isLoggedIn() && !$this->isMonobookOrUncyclo) {
         $this->response->addAsset('extensions/wikia/UserLogin/js/UserLoginFacebookPageInit.js');
     }
     // hide things in the skin
     $this->wg->SuppressWikiHeader = true;
     $this->wg->SuppressPageHeader = true;
     $this->wg->SuppressFooter = true;
     $this->wg->SuppressAds = true;
     $this->wg->SuppressToolbar = true;
     $this->getOutput()->disallowUserJs();
     // just in case...
     // form params
     $this->username = $this->request->getVal('userloginext01', '');
     $this->email = $this->request->getVal('email', '');
     $this->password = $this->request->getVal('userloginext02', '');
     $this->birthmonth = $this->request->getVal('birthmonth', '');
     $this->birthday = $this->request->getVal('birthday', '');
     $this->birthyear = $this->request->getVal('birthyear', '');
     $this->returnto = $this->request->getVal('returnto', '');
     $this->byemail = $this->request->getBool('byemail', false);
     $this->signupToken = UserLoginHelper::getSignupToken();
     $this->uselang = $this->request->getVal('uselang', 'en');
     // fb#38260 -- removed uselang
     $this->avatars = $this->userLoginHelper->getRandomAvatars();
     // template params
     $this->pageHeading = wfMessage('usersignup-heading')->escaped();
     $this->createAccountButtonLabel = wfMessage('createaccount')->escaped();
     if ($this->byemail) {
         $this->pageHeading = wfMessage('usersignup-heading-byemail')->escaped();
         $this->createAccountButtonLabel = wfMessage('usersignup-createaccount-byemail')->escaped();
     }
     if ($this->app->checkSkin('wikiamobile')) {
         $this->wg->Out->setPageTitle(wfMessage('usersignup-page-title-wikiamobile')->escaped());
         $this->overrideTemplate('WikiaMobileIndex');
     }
     // process signup
     $redirected = $this->request->getVal('redirected', '');
     if ($this->wg->Request->wasPosted() && empty($redirected)) {
         $this->handleSignupFormSubmit();
     } else {
         $this->track('signup-start');
     }
     /**
      * OPS-6556 Special:UserSignup daily vists
      * Contact: ruggero@wikia-inc.com or michal@wikia-inc.com
      */
     \Wikia\Logger\WikiaLogger::instance()->info('OPS-6556', ['i18n' => RequestContext::getMain()->getLanguage()->getCode(), 'skin' => RequestContext::getMain()->getSkin()->getSkinName()]);
 }