/** * Get a signup token * @return string signupToken */ public static function getSignupToken() { if (!LoginForm::getCreateaccountToken()) { // Init session if necessary if (session_id() == '') { wfSetupSession(); } LoginForm::setCreateaccountToken(); } return LoginForm::getCreateaccountToken(); }
/** * Generates a template with the login form and registration form already filled into * it and other settings populated as well. This template can then be executed with * different EasyTemplates to give different results such as one view for ajax dialogs * and one view for standalone pages (such as Special:Signup). */ public static function getTemplateForCombinedForms($static = false, $lastmsg = "", &$ajaxLoginForm = "") { global $wgRequest; // Setup the data for the templates, similar to GetComboAjaxLogin. if (session_id() == '') { wfSetupSession(); } // TODO: Invstigate why this was here. //if ($wgRequest->getCheck( 'wpCreateaccount' )) { // return "error"; //} $tmpl = new EasyTemplate(dirname(__FILE__) . '/templates/'); $response = new AjaxResponse(); $type = $wgRequest->getVal('type', ''); if (!wfReadOnly()) { if (empty($ajaxLoginForm)) { $ajaxLoginForm = new AjaxLoginForm($wgRequest); } $ajaxLoginForm->execute($type); if (!empty($ajaxLoginForm->ajaxTemplate)) { $lastmsg = $ajaxLoginForm->ajaxTemplate->data['message']; $tmpl->set('message', $ajaxLoginForm->ajaxTemplate->data['message']); $tmpl->set('messagetype', $ajaxLoginForm->ajaxTemplate->data['messagetype']); } $tmpl->set("registerAjax", $ajaxLoginForm->ajaxRender()); } $isReadOnly = wfReadOnly() ? 1 : 0; $tmpl->set("isReadOnly", $isReadOnly); if (!LoginForm::getLoginToken()) { LoginForm::setLoginToken(); } $tmpl->set("loginToken", LoginForm::getLoginToken()); if (!LoginForm::getCreateaccountToken()) { LoginForm::setCreateaccountToken(); } $tmpl->set("createToken", LoginForm::getCreateaccountToken()); // Use the existing settings to generate the login portion of the form, which will then // be fed back into the bigger template in this case (it is not always fed into ComboAjaxLogin template). $returnto = $wgRequest->getVal('returnto', ''); if (!($returnto == '')) { $returnto = "&returnto=" . wfUrlencode($returnto); } $returntoquery = $wgRequest->getVal('returntoquery', ''); if (!($returntoquery == '')) { $returntoquery = "&returntoquery=" . wfUrlencode($returntoquery); } $loginaction = Skin::makeSpecialUrl('Signup', "type=login&action=submitlogin" . $returnto . $returntoquery); $signupaction = Skin::makeSpecialUrl('Signup', "type=signup" . $returnto . $returntoquery); $tmpl->set("loginaction", $loginaction); $tmpl->set("signupaction", $signupaction); $tmpl->set("loginerror", $lastmsg); $tmpl->set("actiontype", $type); $tmpl->set("showRegister", false); $tmpl->set("showLogin", false); if ($static) { if (strtolower($type) == "login") { $tmpl->set("showLogin", true); } else { if (!$isReadOnly) { $tmpl->set("showRegister", true); } } } $tmpl->set("ajaxLoginComponent", $tmpl->render('AjaxLoginComponent')); return $tmpl; }
protected function setUp() { parent::setUp(); LoginForm::setCreateaccountToken(); $this->setMwGlobals(array('wgEnableEmail' => true)); }
private function displayForm() { if (session_id() == '') { wfSetupSession(); } if (!LoginForm::getCreateaccountToken()) { LoginForm::setCreateaccountToken(); } $token = LoginForm::getCreateaccountToken(); # block_join $html = Xml::openElement('div', array('class' => 'block block_join')); $html .= Xml::element('h3', array('class' => 'title'), wfMessage('sz-mp-joinus')->text()); # inside $html .= Xml::openElement('div', array('class' => 'inside')); global $wgServer; $html .= Xml::openElement('form', array('id' => 'userloginS', 'action' => $wgServer . '/index.php?title=Special:UserLogin&action=submitlogin&type=signup&from=SpecialWelcome', 'method' => 'post', 'name' => 'userlogin')); $html .= Xml::openElement('p'); $html .= Xml::element('label', array('for' => 'wpNameS', 'class' => 'sread'), wfMessage('yourname')->text()); $html .= Xml::element('input', array('id' => 'wpNameS', 'name' => 'wpName', 'placeholder' => wfMessage('sz-mp-yourname')->text())); $html .= Xml::closeElement('p'); $html .= Xml::openElement('p'); $html .= Xml::element('label', array('for' => 'wpPasswordS', 'class' => 'sread'), wfMessage('yourpassword')->text()); $html .= Xml::element('input', array('id' => 'wpPasswordS', 'type' => 'password', 'name' => 'wpPassword', 'placeholder' => wfMessage('sz-mp-yourpassword')->text())); $html .= Xml::closeElement('p'); $html .= Xml::openElement('p'); $html .= Xml::element('label', array('for' => 'wpRetypeS', 'class' => 'sread'), wfMessage('yourpasswordagain')->text()); $html .= Xml::element('input', array('id' => 'wpRetypeS', 'type' => 'password', 'name' => 'wpRetype', 'placeholder' => wfMessage('sz-mp-yourpasswordagain')->text())); $html .= Xml::closeElement('p'); $html .= Xml::openElement('p'); $html .= Xml::element('label', array('for' => 'wpEmailS', 'class' => 'sread'), wfMessage('youremail')->text()); $html .= Xml::element('input', array('id' => 'wpEmailS', 'name' => 'wpEmail', 'placeholder' => wfMessage('sz-mp-youremail')->text())); $html .= Xml::closeElement('p'); $html .= Xml::openElement('p', array('class' => 'submit')); $html .= Linker::link(SpecialPage::getTitleFor('UserLogin'), wfMessage('login')->text()); $html .= Xml::element('label', array('for' => 'wpCreateaccountS', 'class' => 'sread'), wfMessage('createaccount')->text()); $html .= Xml::element('input', array('id' => 'wpCreateaccountS', 'name' => 'wpCreateaccount', 'type' => 'submit', 'value' => wfMessage('sz-mp-enter')->text())); $html .= Xml::closeElement('p'); $html .= Xml::element('input', array('name' => 'wpCreateaccountToken', 'type' => 'hidden', 'value' => $token)); $html .= Xml::closeElement('form'); # /inside $html .= Xml::closeElement('div'); # /block $html .= Xml::closeElement('div'); return $html; }