function msgWiki($str)
 {
     // exists
     if ($this->campaign && wfMessage("customusertemplate-{$this->campaign}-{$str}")->exists()) {
         $this->msgWikiCustom("customusertemplate-{$this->campaign}-{$str}", false);
     } else {
         parent::msgWiki($str);
     }
 }
예제 #2
0
 /**
  * @private
  */
 function mainLoginForm($msg, $msgtype = 'error')
 {
     global $wgUser, $wgOut, $wgAllowRealName, $wgEnableEmail;
     global $wgCookiePrefix, $wgAuth, $wgLoginLanguageSelector;
     global $wgAuth;
     if ($this->mType == 'signup') {
         if (!$wgUser->isAllowed('createaccount')) {
             $this->userNotPrivilegedMessage();
             return;
         } elseif ($wgUser->isBlockedFromCreateAccount()) {
             $this->userBlockedMessage();
             return;
         }
     }
     if ('' == $this->mName) {
         if ($wgUser->isLoggedIn()) {
             $this->mName = $wgUser->getName();
         } else {
             $this->mName = isset($_COOKIE[$wgCookiePrefix . 'UserName']) ? $_COOKIE[$wgCookiePrefix . 'UserName'] : null;
         }
     }
     $titleObj = SpecialPage::getTitleFor('Userlogin');
     if ($this->mType == 'signup') {
         $template = new UsercreateTemplate();
         $q = 'action=submitlogin&type=signup';
         $linkq = 'type=login';
         $linkmsg = 'gotaccount';
     } else {
         $template = new UserloginTemplate();
         $q = 'action=submitlogin&type=login';
         $linkq = 'type=signup';
         $linkmsg = 'nologin';
     }
     if (!empty($this->mReturnTo)) {
         $returnto = '&returnto=' . wfUrlencode($this->mReturnTo);
         $q .= $returnto;
         $linkq .= $returnto;
     }
     # Pass any language selection on to the mode switch link
     if ($wgLoginLanguageSelector && $this->mLanguage) {
         $linkq .= '&uselang=' . $this->mLanguage;
     }
     $link = '<a href="' . htmlspecialchars($titleObj->getLocalUrl($linkq)) . '">';
     $link .= wfMsgHtml($linkmsg . 'link');
     $link .= '</a>';
     # Don't show a "create account" link if the user can't
     if ($this->showCreateOrLoginLink($wgUser)) {
         $template->set('link', wfMsgHtml($linkmsg, $link));
     } else {
         $template->set('link', '');
     }
     $template->set('header', '');
     $template->set('name', $this->mName);
     $template->set('password', $this->mPassword);
     $template->set('retype', $this->mRetype);
     $template->set('email', $this->mEmail);
     $template->set('realname', $this->mRealName);
     $template->set('domain', $this->mDomain);
     $template->set('action', $titleObj->getLocalUrl($q));
     $template->set('message', $msg);
     $template->set('messagetype', $msgtype);
     $template->set('createemail', $wgEnableEmail && $wgUser->isLoggedIn());
     $template->set('userealname', $wgAllowRealName);
     $template->set('useemail', $wgEnableEmail);
     $template->set('canreset', $wgAuth->allowPasswordChange());
     $template->set('remember', $wgUser->getOption('rememberpassword') or $this->mRemember);
     # Prepare language selection links as needed
     if ($wgLoginLanguageSelector) {
         $template->set('languages', $this->makeLanguageSelector());
         if ($this->mLanguage) {
             $template->set('uselang', $this->mLanguage);
         }
     }
     // Give authentication and captcha plugins a chance to modify the form
     $wgAuth->modifyUITemplate($template);
     if ($this->mType == 'signup') {
         wfRunHooks('UserCreateForm', array(&$template));
     } else {
         wfRunHooks('UserLoginForm', array(&$template));
     }
     $wgOut->setPageTitle(wfMsg('userlogin'));
     $wgOut->setRobotpolicy('noindex,nofollow');
     $wgOut->setArticleRelated(false);
     $wgOut->addTemplate($template);
 }
예제 #3
0
 /**
  * @private
  */
 function mainLoginForm($msg, $msgtype = 'error')
 {
     global $wgUser, $wgOut, $wgAllowRealName, $wgEnableEmail;
     global $wgCookiePrefix, $wgLoginLanguageSelector;
     global $wgAuth, $wgEmailConfirmToEdit, $wgCookieExpiration;
     $titleObj = SpecialPage::getTitleFor('Userlogin');
     if ($this->mType == 'signup') {
         // Block signup here if in readonly. Keeps user from
         // going through the process (filling out data, etc)
         // and being informed later.
         if (wfReadOnly()) {
             $wgOut->readOnlyPage();
             return;
         } elseif ($wgUser->isBlockedFromCreateAccount()) {
             $this->userBlockedMessage();
             return;
         } elseif (count($permErrors = $titleObj->getUserPermissionsErrors('createaccount', $wgUser, true)) > 0) {
             $wgOut->showPermissionsErrorPage($permErrors, 'createaccount');
             return;
         }
     }
     if ('' == $this->mName) {
         if ($wgUser->isLoggedIn()) {
             $this->mName = $wgUser->getName();
         } else {
             $this->mName = isset($_COOKIE[$wgCookiePrefix . 'UserName']) ? $_COOKIE[$wgCookiePrefix . 'UserName'] : null;
         }
     }
     $titleObj = SpecialPage::getTitleFor('Userlogin');
     if ($this->mType == 'signup') {
         $template = new UsercreateTemplate();
         $q = 'action=submitlogin&type=signup';
         $linkq = 'type=login';
         $linkmsg = 'gotaccount';
     } else {
         $template = new UserloginTemplate();
         $q = 'action=submitlogin&type=login';
         $linkq = 'type=signup';
         $linkmsg = 'nologin';
     }
     if (!empty($this->mReturnTo)) {
         $returnto = '&returnto=' . wfUrlencode($this->mReturnTo);
         $q .= $returnto;
         $linkq .= $returnto;
     }
     # Pass any language selection on to the mode switch link
     if ($wgLoginLanguageSelector && $this->mLanguage) {
         $linkq .= '&uselang=' . $this->mLanguage;
     }
     $link = '<a href="' . htmlspecialchars($titleObj->getLocalUrl($linkq)) . '">';
     $link .= wfMsgHtml($linkmsg . 'link');
     # Calling either 'gotaccountlink' or 'nologinlink'
     $link .= '</a>';
     # Don't show a "create account" link if the user can't
     if ($this->showCreateOrLoginLink($wgUser)) {
         $template->set('link', wfMsgHtml($linkmsg, $link));
     } else {
         $template->set('link', '');
     }
     $template->set('header', '');
     $template->set('name', $this->mName);
     $template->set('password', $this->mPassword);
     $template->set('retype', $this->mRetype);
     $template->set('email', $this->mEmail);
     $template->set('realname', $this->mRealName);
     $template->set('domain', $this->mDomain);
     $template->set('action', $titleObj->getLocalUrl($q));
     $template->set('message', $msg);
     $template->set('messagetype', $msgtype);
     $template->set('createemail', $wgEnableEmail && $wgUser->isLoggedIn());
     $template->set('userealname', $wgAllowRealName);
     $template->set('useemail', $wgEnableEmail);
     $template->set('emailrequired', $wgEmailConfirmToEdit);
     $template->set('canreset', $wgAuth->allowPasswordChange());
     $template->set('canremember', $wgCookieExpiration > 0);
     $template->set('remember', $wgUser->getOption('rememberpassword') or $this->mRemember);
     # Prepare language selection links as needed
     if ($wgLoginLanguageSelector) {
         $template->set('languages', $this->makeLanguageSelector());
         if ($this->mLanguage) {
             $template->set('uselang', $this->mLanguage);
         }
     }
     // Give authentication and captcha plugins a chance to modify the form
     $wgAuth->modifyUITemplate($template);
     if ($this->mType == 'signup') {
         wfRunHooks('UserCreateForm', array(&$template));
     } else {
         wfRunHooks('UserLoginForm', array(&$template));
     }
     $wgOut->setPageTitle(wfMsg('userlogin'));
     $wgOut->setRobotPolicy('noindex,nofollow');
     $wgOut->setArticleRelated(false);
     $wgOut->disallowUserJs();
     // just in case...
     $wgOut->addTemplate($template);
 }
예제 #4
0
 /**
  * @private
  */
 function mainLoginForm($msg, $msgtype = 'error')
 {
     global $wgUser, $wgOut, $wgAllowRealName, $wgEnableEmail;
     global $wgCookiePrefix, $wgAuth, $wgLoginLanguageSelector;
     global $wgAuth, $wgEmailConfirmToEdit, $wgSSLsite;
     if ($this->mType == 'signup') {
         if (!$wgUser->isAllowed('createaccount')) {
             $this->userNotPrivilegedMessage();
             return;
         } elseif ($wgUser->isBlockedFromCreateAccount()) {
             $this->userBlockedMessage();
             return;
         }
     }
     if ('' == $this->mName) {
         if ($wgUser->isLoggedIn()) {
             $this->mName = $wgUser->getName();
         } else {
             $this->mName = isset($_COOKIE[$wgCookiePrefix . 'UserName']) ? $_COOKIE[$wgCookiePrefix . 'UserName'] : null;
         }
     }
     if (SSL_LOGIN_DOMAIN && !$wgSSLsite) {
         header('Location: https://' . SSL_LOGIN_DOMAIN . @$_SERVER['REQUEST_URI']);
         exit;
     }
     $titleObj = SpecialPage::getTitleFor('Userlogin');
     if ($this->mType == 'signup') {
         $template = new UsercreateTemplate();
         $q = 'action=submitlogin&type=signup';
         $linkq = 'type=login';
         $linkmsg = 'gotaccount';
     } else {
         $template = new UserloginTemplate();
         $q = 'action=submitlogin&type=login';
         $linkq = 'type=signup';
         $linkmsg = 'nologin';
     }
     if (!empty($this->mReturnTo)) {
         $returnto = '&returnto=' . wfUrlencode($this->mReturnTo);
         $q .= $returnto;
         $linkq .= $returnto;
     }
     if (!empty($this->mAutoRedirect)) {
         $autoredirect = '&autoredirect=' . wfUrlencode($this->mAutoRedirect);
         $q .= $autoredirect;
     }
     # Pass any language selection on to the mode switch link
     if ($wgLoginLanguageSelector && $this->mLanguage) {
         $linkq .= '&uselang=' . $this->mLanguage;
     }
     $link = '<a href="' . htmlspecialchars($titleObj->getLocalUrl($linkq)) . '">';
     $link .= wfMsgHtml($linkmsg . 'link');
     # Calling either 'gotaccountlink' or 'nologinlink'
     $link .= '</a>';
     $linkPassword = "******";
     //htmlspecialchars( $titleObj->getLocalUrl( 'type=forgotpassword' . $returnto ) );
     $linkUsername = htmlspecialchars($titleObj->getLocalUrl('type=forgotusername' . $returnto));
     # Don't show a "create account" link if the user can't
     if ($this->showCreateOrLoginLink($wgUser)) {
         $template->set('link', wfMsgHtml($linkmsg, $link));
         $this->mLink = wfMsgHtml($linkmsg, $link);
     } else {
         $template->set('link', '');
         $this->mLink = '';
     }
     $template->set('forgotPassword', $linkPassword);
     $template->set('forgotUsername', $linkUsername);
     $template->set('createLink', $link);
     $template->set('header', '');
     $template->set('name', $this->mName);
     $template->set('password', $this->mPassword);
     $template->set('retype', $this->mRetype);
     $template->set('retypeEmail', $this->mRetypeEmail);
     $template->set('email', $this->mEmail);
     $template->set('realname', $this->mRealName);
     $template->set('domain', $this->mDomain);
     $template->set('action', $titleObj->getLocalUrl($q));
     $template->set('message', $msg);
     $template->set('messagetype', $msgtype);
     $template->set('createemail', $wgEnableEmail && $wgUser->isLoggedIn());
     //$template->set( 'userealname', $wgAllowRealName );
     $template->set('userealname', false);
     $template->set('useemail', $wgEnableEmail);
     $template->set('emailrequired', $wgEmailConfirmToEdit);
     $template->set('canreset', $wgAuth->allowPasswordChange());
     $template->set('remember', $wgUser->getOption('rememberpassword') or $this->mRemember);
     # Prepare language selection links as needed
     if ($wgLoginLanguageSelector) {
         $template->set('languages', $this->makeLanguageSelector());
         if ($this->mLanguage) {
             $template->set('uselang', $this->mLanguage);
         }
     }
     // Give authentication and captcha plugins a chance to modify the form
     $wgAuth->modifyUITemplate($template);
     if ($this->mType == 'signup' || $this->mType == 'forgotusername') {
         wfRunHooks('UserCreateForm', array(&$template));
     } else {
         wfRunHooks('UserLoginForm', array(&$template));
     }
     $wgOut->setPageTitle(wfMsg('userlogin'));
     $wgOut->setRobotpolicy('noindex,nofollow');
     $wgOut->setArticleRelated(false);
     $wgOut->disallowUserJs();
     // just in case...
     $wgOut->addTemplate($template);
 }
 /**
  * @param string $msg
  * @param string $msgtype
  * @throws ErrorPageError
  * @throws Exception
  * @throws FatalError
  * @throws MWException
  * @throws PermissionsError
  * @throws ReadOnlyError
  * @private
  */
 function mainLoginForm($msg, $msgtype = 'error')
 {
     global $wgEnableEmail, $wgEnableUserEmail;
     global $wgHiddenPrefs, $wgLoginLanguageSelector;
     global $wgAuth, $wgEmailConfirmToEdit;
     global $wgSecureLogin, $wgPasswordResetRoutes;
     global $wgExtendedLoginCookieExpiration, $wgCookieExpiration;
     $titleObj = $this->getPageTitle();
     $user = $this->getUser();
     $out = $this->getOutput();
     if ($this->mType == 'signup') {
         // Block signup here if in readonly. Keeps user from
         // going through the process (filling out data, etc)
         // and being informed later.
         $permErrors = $titleObj->getUserPermissionsErrors('createaccount', $user, true);
         if (count($permErrors)) {
             throw new PermissionsError('createaccount', $permErrors);
         } elseif ($user->isBlockedFromCreateAccount()) {
             $this->userBlockedMessage($user->isBlockedFromCreateAccount());
             return;
         } elseif (wfReadOnly()) {
             throw new ReadOnlyError();
         }
     }
     // Pre-fill username (if not creating an account, bug 44775).
     if ($this->mUsername == '' && $this->mType != 'signup') {
         if ($user->isLoggedIn()) {
             $this->mUsername = $user->getName();
         } else {
             $this->mUsername = $this->getRequest()->getCookie('UserName');
         }
     }
     // Generic styles and scripts for both login and signup form
     $out->addModuleStyles(array('mediawiki.ui', 'mediawiki.ui.button', 'mediawiki.ui.checkbox', 'mediawiki.ui.input', 'mediawiki.special.userlogin.common.styles'));
     if ($this->mType == 'signup') {
         // XXX hack pending RL or JS parse() support for complex content messages
         // https://bugzilla.wikimedia.org/show_bug.cgi?id=25349
         $out->addJsConfigVars('wgCreateacctImgcaptchaHelp', $this->msg('createacct-imgcaptcha-help')->parse());
         // Additional styles and scripts for signup form
         $out->addModules(array('mediawiki.special.userlogin.signup.js'));
         $out->addModuleStyles(array('mediawiki.special.userlogin.signup.styles'));
         $template = new UsercreateTemplate($this->getConfig());
         // Must match number of benefits defined in messages
         $template->set('benefitCount', 3);
         $q = 'action=submitlogin&type=signup';
         $linkq = 'type=login';
     } else {
         // Additional styles for login form
         $out->addModuleStyles(array('mediawiki.special.userlogin.login.styles'));
         $template = new UserloginTemplate($this->getConfig());
         $q = 'action=submitlogin&type=login';
         $linkq = 'type=signup';
     }
     if ($this->mReturnTo !== '') {
         $returnto = '&returnto=' . wfUrlencode($this->mReturnTo);
         if ($this->mReturnToQuery !== '') {
             $returnto .= '&returntoquery=' . wfUrlencode($this->mReturnToQuery);
         }
         $q .= $returnto;
         $linkq .= $returnto;
     }
     # Don't show a "create account" link if the user can't.
     if ($this->showCreateOrLoginLink($user)) {
         # Pass any language selection on to the mode switch link
         if ($wgLoginLanguageSelector && $this->mLanguage) {
             $linkq .= '&uselang=' . $this->mLanguage;
         }
         // Supply URL, login template creates the button.
         $template->set('createOrLoginHref', $titleObj->getLocalURL($linkq));
     } else {
         $template->set('link', '');
     }
     $resetLink = $this->mType == 'signup' ? null : is_array($wgPasswordResetRoutes) && in_array(true, array_values($wgPasswordResetRoutes));
     $template->set('header', '');
     $template->set('formheader', '');
     $template->set('skin', $this->getSkin());
     $template->set('name', $this->mUsername);
     $template->set('password', $this->mPassword);
     $template->set('retype', $this->mRetype);
     $template->set('createemailset', $this->mCreateaccountMail);
     $template->set('email', $this->mEmail);
     $template->set('realname', $this->mRealName);
     $template->set('domain', $this->mDomain);
     $template->set('reason', $this->mReason);
     $template->set('action', $titleObj->getLocalURL($q));
     $template->set('message', $msg);
     $template->set('messagetype', $msgtype);
     $template->set('createemail', $wgEnableEmail && $user->isLoggedIn());
     $template->set('userealname', !in_array('realname', $wgHiddenPrefs));
     $template->set('useemail', $wgEnableEmail);
     $template->set('emailrequired', $wgEmailConfirmToEdit);
     $template->set('emailothers', $wgEnableUserEmail);
     $template->set('canreset', $wgAuth->allowPasswordChange());
     $template->set('resetlink', $resetLink);
     $template->set('canremember', $wgExtendedLoginCookieExpiration === null ? $wgCookieExpiration > 0 : $wgExtendedLoginCookieExpiration > 0);
     $template->set('usereason', $user->isLoggedIn());
     $template->set('remember', $this->mRemember);
     $template->set('cansecurelogin', $wgSecureLogin === true);
     $template->set('stickhttps', (int) $this->mStickHTTPS);
     $template->set('loggedin', $user->isLoggedIn());
     $template->set('loggedinuser', $user->getName());
     if ($this->mType == 'signup') {
         if (!self::getCreateaccountToken()) {
             self::setCreateaccountToken();
         }
         $template->set('token', self::getCreateaccountToken());
     } else {
         if (!self::getLoginToken()) {
             self::setLoginToken();
         }
         $template->set('token', self::getLoginToken());
     }
     # Prepare language selection links as needed
     if ($wgLoginLanguageSelector) {
         $template->set('languages', $this->makeLanguageSelector());
         if ($this->mLanguage) {
             $template->set('uselang', $this->mLanguage);
         }
     }
     $template->set('secureLoginUrl', $this->mSecureLoginUrl);
     // Use signupend-https for HTTPS requests if it's not blank, signupend otherwise
     $usingHTTPS = $this->mRequest->getProtocol() == 'https';
     $signupendHTTPS = $this->msg('signupend-https');
     if ($usingHTTPS && !$signupendHTTPS->isBlank()) {
         $template->set('signupend', $signupendHTTPS->parse());
     } else {
         $template->set('signupend', $this->msg('signupend')->parse());
     }
     // If using HTTPS coming from HTTP, then the 'fromhttp' parameter must be preserved
     if ($usingHTTPS) {
         $template->set('fromhttp', $this->mFromHTTP);
     }
     // Give authentication and captcha plugins a chance to modify the form
     $wgAuth->modifyUITemplate($template, $this->mType);
     if ($this->mType == 'signup') {
         Hooks::run('UserCreateForm', array(&$template));
     } else {
         Hooks::run('UserLoginForm', array(&$template));
     }
     $out->disallowUserJs();
     // just in case...
     $out->addTemplate($template);
 }
예제 #6
0
 /**
  * @private
  */
 function mainLoginForm($msg, $msgtype = 'error')
 {
     global $wgEnableEmail, $wgEnableUserEmail;
     global $wgHiddenPrefs, $wgLoginLanguageSelector;
     global $wgAuth, $wgEmailConfirmToEdit, $wgCookieExpiration;
     global $wgSecureLogin, $wgSecureLoginDefaultHTTPS, $wgPasswordResetRoutes;
     $titleObj = $this->getTitle();
     $user = $this->getUser();
     $out = $this->getOutput();
     if ($this->mType == 'signup') {
         // Block signup here if in readonly. Keeps user from
         // going through the process (filling out data, etc)
         // and being informed later.
         $permErrors = $titleObj->getUserPermissionsErrors('createaccount', $user, true);
         if (count($permErrors)) {
             throw new PermissionsError('createaccount', $permErrors);
         } elseif ($user->isBlockedFromCreateAccount()) {
             $this->userBlockedMessage($user->isBlockedFromCreateAccount());
             return;
         } elseif (wfReadOnly()) {
             throw new ReadOnlyError();
         }
     }
     // Pre-fill username (if not creating an account, bug 44775).
     if ($this->mUsername == '' && $this->mType != 'signup') {
         if ($user->isLoggedIn()) {
             $this->mUsername = $user->getName();
         } else {
             $this->mUsername = $this->getRequest()->getCookie('UserName');
         }
     }
     if ($this->mType == 'signup') {
         $out->addModules('mediawiki.special.userlogin.signup');
         if ($this->mShowVForm) {
             $template = new UsercreateTemplateVForm();
             $out->addModuleStyles(array('mediawiki.ui', 'mediawiki.special.createaccount.vform'));
             // XXX hack pending RL or JS parse() support for complex content messages
             // https://bugzilla.wikimedia.org/show_bug.cgi?id=25349
             $out->addJsConfigVars('wgCreateacctImgcaptchaHelp', $this->msg('createacct-imgcaptcha-help')->parse());
             $out->addModules('mediawiki.special.createaccount.vform.js');
             // Must match number of benefits defined in messages
             $template->set('benefitCount', 3);
         } else {
             $template = new UsercreateTemplate();
         }
         $q = 'action=submitlogin&type=signup';
         $linkq = 'type=login';
         $linkmsg = 'gotaccount';
     } else {
         if ($this->mShowVForm) {
             $template = new UserloginTemplateVForm();
             $out->addModuleStyles(array('mediawiki.ui', 'mediawiki.special.userlogin.vform'));
         } else {
             $template = new UserloginTemplate();
         }
         $q = 'action=submitlogin&type=login';
         $linkq = 'type=signup';
         $linkmsg = 'nologin';
     }
     if ($this->mReturnTo !== '') {
         $returnto = '&returnto=' . wfUrlencode($this->mReturnTo);
         if ($this->mReturnToQuery !== '') {
             $returnto .= '&returntoquery=' . wfUrlencode($this->mReturnToQuery);
         }
         $q .= $returnto;
         $linkq .= $returnto;
     }
     # Don't show a "create account" link if the user can't.
     if ($this->showCreateOrLoginLink($user)) {
         # Pass any language selection on to the mode switch link
         if ($wgLoginLanguageSelector && $this->mLanguage) {
             $linkq .= '&uselang=' . $this->mLanguage;
         }
         if (!$this->mShowVForm) {
             $link = Html::element('a', array('href' => $titleObj->getLocalURL($linkq)), $this->msg($linkmsg . 'link')->text());
             # Calling either 'gotaccountlink' or 'nologinlink'
             $template->set('link', $this->msg($linkmsg)->rawParams($link)->parse());
         } else {
             // Supply URL, login template creates the button.
             // (The template 'link' key, passed above, is obsolete in the VForm design.)
             $template->set('createOrLoginHref', $titleObj->getLocalURL($linkq));
         }
     } else {
         $template->set('link', '');
     }
     // Decide if we default stickHTTPS on
     if ($wgSecureLoginDefaultHTTPS && $this->mAction != 'submitlogin' && !$this->mLoginattempt) {
         $this->mStickHTTPS = true;
     }
     $resetLink = $this->mType == 'signup' ? null : is_array($wgPasswordResetRoutes) && in_array(true, array_values($wgPasswordResetRoutes));
     $template->set('header', '');
     $template->set('skin', $this->getSkin());
     $template->set('name', $this->mUsername);
     $template->set('password', $this->mPassword);
     $template->set('retype', $this->mRetype);
     $template->set('createemailset', $this->mCreateaccountMail);
     $template->set('email', $this->mEmail);
     $template->set('realname', $this->mRealName);
     $template->set('domain', $this->mDomain);
     $template->set('reason', $this->mReason);
     $template->set('action', $titleObj->getLocalURL($q));
     $template->set('message', $msg);
     $template->set('messagetype', $msgtype);
     $template->set('createemail', $wgEnableEmail && $user->isLoggedIn());
     $template->set('userealname', !in_array('realname', $wgHiddenPrefs));
     $template->set('useemail', $wgEnableEmail);
     $template->set('emailrequired', $wgEmailConfirmToEdit);
     $template->set('emailothers', $wgEnableUserEmail);
     $template->set('canreset', $wgAuth->allowPasswordChange());
     $template->set('resetlink', $resetLink);
     $template->set('canremember', $wgCookieExpiration > 0);
     $template->set('usereason', $user->isLoggedIn());
     $template->set('remember', $user->getOption('rememberpassword') || $this->mRemember);
     $template->set('cansecurelogin', $wgSecureLogin === true);
     $template->set('stickHTTPS', $this->mStickHTTPS);
     if ($this->mType == 'signup') {
         if (!self::getCreateaccountToken()) {
             self::setCreateaccountToken();
         }
         $template->set('token', self::getCreateaccountToken());
     } else {
         if (!self::getLoginToken()) {
             self::setLoginToken();
         }
         $template->set('token', self::getLoginToken());
     }
     # Prepare language selection links as needed
     if ($wgLoginLanguageSelector) {
         $template->set('languages', $this->makeLanguageSelector());
         if ($this->mLanguage) {
             $template->set('uselang', $this->mLanguage);
         }
     }
     $template->set('secureLoginUrl', $this->mSecureLoginUrl);
     // Use loginend-https for HTTPS requests if it's not blank, loginend otherwise
     // Ditto for signupend.  New forms use neither.
     $usingHTTPS = WebRequest::detectProtocol() == 'https';
     $loginendHTTPS = $this->msg('loginend-https');
     $signupendHTTPS = $this->msg('signupend-https');
     if ($usingHTTPS && !$loginendHTTPS->isBlank()) {
         $template->set('loginend', $loginendHTTPS->parse());
     } else {
         $template->set('loginend', $this->msg('loginend')->parse());
     }
     if ($usingHTTPS && !$signupendHTTPS->isBlank()) {
         $template->set('signupend', $signupendHTTPS->parse());
     } else {
         $template->set('signupend', $this->msg('signupend')->parse());
     }
     // Give authentication and captcha plugins a chance to modify the form
     $wgAuth->modifyUITemplate($template, $this->mType);
     if ($this->mType == 'signup') {
         wfRunHooks('UserCreateForm', array(&$template));
     } else {
         wfRunHooks('UserLoginForm', array(&$template));
     }
     $out->disallowUserJs();
     // just in case...
     $out->addTemplate($template);
 }
예제 #7
0
 /**
  * @private
  */
 function mainLoginForm($msg, $msgtype = 'error')
 {
     global $wgEnableEmail, $wgEnableUserEmail;
     global $wgHiddenPrefs, $wgLoginLanguageSelector;
     global $wgAuth, $wgEmailConfirmToEdit, $wgCookieExpiration;
     global $wgSecureLogin, $wgPasswordResetRoutes;
     $titleObj = $this->getTitle();
     $user = $this->getUser();
     if ($this->mType == 'signup') {
         // Block signup here if in readonly. Keeps user from
         // going through the process (filling out data, etc)
         // and being informed later.
         $permErrors = $titleObj->getUserPermissionsErrors('createaccount', $user, true);
         if (count($permErrors)) {
             throw new PermissionsError('createaccount', $permErrors);
         } elseif ($user->isBlockedFromCreateAccount()) {
             $this->userBlockedMessage($user->isBlockedFromCreateAccount());
             return;
         } elseif (wfReadOnly()) {
             throw new ReadOnlyError();
         }
     }
     if ($this->mUsername == '') {
         if ($user->isLoggedIn()) {
             $this->mUsername = $user->getName();
         } else {
             $this->mUsername = $this->getRequest()->getCookie('UserName');
         }
     }
     if ($this->mType == 'signup') {
         $template = new UsercreateTemplate();
         $q = 'action=submitlogin&type=signup';
         $linkq = 'type=login';
         $linkmsg = 'gotaccount';
     } else {
         $template = new UserloginTemplate();
         $q = 'action=submitlogin&type=login';
         $linkq = 'type=signup';
         $linkmsg = 'nologin';
     }
     if (!empty($this->mReturnTo)) {
         $returnto = '&returnto=' . wfUrlencode($this->mReturnTo);
         if (!empty($this->mReturnToQuery)) {
             $returnto .= '&returntoquery=' . wfUrlencode($this->mReturnToQuery);
         }
         $q .= $returnto;
         $linkq .= $returnto;
     }
     # Don't show a "create account" link if the user can't
     if ($this->showCreateOrLoginLink($user)) {
         # Pass any language selection on to the mode switch link
         if ($wgLoginLanguageSelector && $this->mLanguage) {
             $linkq .= '&uselang=' . $this->mLanguage;
         }
         $link = Html::element('a', array('href' => $titleObj->getLocalURL($linkq)), $this->msg($linkmsg . 'link')->text());
         # Calling either 'gotaccountlink' or 'nologinlink'
         $template->set('link', $this->msg($linkmsg)->rawParams($link)->parse());
     } else {
         $template->set('link', '');
     }
     $resetLink = $this->mType == 'signup' ? null : is_array($wgPasswordResetRoutes) && in_array(true, array_values($wgPasswordResetRoutes));
     $template->set('header', '');
     $template->set('name', $this->mUsername);
     $template->set('password', $this->mPassword);
     $template->set('retype', $this->mRetype);
     $template->set('email', $this->mEmail);
     $template->set('realname', $this->mRealName);
     $template->set('domain', $this->mDomain);
     $template->set('reason', $this->mReason);
     $template->set('action', $titleObj->getLocalURL($q));
     $template->set('message', $msg);
     $template->set('messagetype', $msgtype);
     $template->set('createemail', $wgEnableEmail && $user->isLoggedIn());
     $template->set('userealname', !in_array('realname', $wgHiddenPrefs));
     $template->set('useemail', $wgEnableEmail);
     $template->set('emailrequired', $wgEmailConfirmToEdit);
     $template->set('emailothers', $wgEnableUserEmail);
     $template->set('canreset', $wgAuth->allowPasswordChange());
     $template->set('resetlink', $resetLink);
     $template->set('canremember', $wgCookieExpiration > 0);
     $template->set('usereason', $user->isLoggedIn());
     $template->set('remember', $user->getOption('rememberpassword') || $this->mRemember);
     $template->set('cansecurelogin', $wgSecureLogin === true);
     $template->set('stickHTTPS', $this->mStickHTTPS);
     if ($this->mType == 'signup') {
         if (!self::getCreateaccountToken()) {
             self::setCreateaccountToken();
         }
         $template->set('token', self::getCreateaccountToken());
     } else {
         if (!self::getLoginToken()) {
             self::setLoginToken();
         }
         $template->set('token', self::getLoginToken());
     }
     # Prepare language selection links as needed
     if ($wgLoginLanguageSelector) {
         $template->set('languages', $this->makeLanguageSelector());
         if ($this->mLanguage) {
             $template->set('uselang', $this->mLanguage);
         }
     }
     // Use loginend-https for HTTPS requests if it's not blank, loginend otherwise
     // Ditto for signupend
     $usingHTTPS = WebRequest::detectProtocol() == 'https';
     $loginendHTTPS = $this->msg('loginend-https');
     $signupendHTTPS = $this->msg('signupend-https');
     if ($usingHTTPS && !$loginendHTTPS->isBlank()) {
         $template->set('loginend', $loginendHTTPS->parse());
     } else {
         $template->set('loginend', $this->msg('loginend')->parse());
     }
     if ($usingHTTPS && !$signupendHTTPS->isBlank()) {
         $template->set('signupend', $signupendHTTPS->parse());
     } else {
         $template->set('signupend', $this->msg('signupend')->parse());
     }
     // Give authentication and captcha plugins a chance to modify the form
     $wgAuth->modifyUITemplate($template, $this->mType);
     if ($this->mType == 'signup') {
         wfRunHooks('UserCreateForm', array(&$template));
     } else {
         wfRunHooks('UserLoginForm', array(&$template));
     }
     $out = $this->getOutput();
     $out->disallowUserJs();
     // just in case...
     $out->addTemplate($template);
 }