function msgWiki($str)
 {
     // exists
     if ($this->campaign && wfMessage("customusertemplate-{$this->campaign}-{$str}")->exists()) {
         $this->msgWikiCustom("customusertemplate-{$this->campaign}-{$str}", false);
     } else {
         parent::msgWiki($str);
     }
 }
 /**
  * @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);
 }
	/**
	 * @private
	 */
	function mainSignupForm( $msg, $msgtype = 'error' ) {
		global $wgUser, $wgOut, $wgHiddenPrefs, $wgRequest;
		global $wgEnableEmail, $wgEnableUserEmail;
		global $wgLoginLanguageSelector;
		global $wgAuth, $wgEmailConfirmToEdit, $wgCookieExpiration;
		global $wgSecureLogin, $wgPasswordResetRoutes;

		$titleObj = SpecialPage::getTitleFor( 'Usersignup' );

		// 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( $wgUser->isBlockedFromCreateAccount() );
			return;
		} elseif ( count( $permErrors = $titleObj->getUserPermissionsErrors( 'createaccount', $wgUser, true ) )>0 ) {
			$wgOut->showPermissionsErrorPage( $permErrors, 'createaccount' );
			return;
		}

		if ( $this->mUsername == '' ) {
			if ( $wgUser->isLoggedIn() ) {
				$this->mUsername = $wgUser->getName();
			} else {
				$this->mUsername = $wgRequest->getCookie( 'UserName' );
			}
		}

		$template = new UsercreateTemplate();
		$q = "action=submitlogin&type=signup&wpSourceAction=$this->mSourceAction&wpSourceNS=$this->mSourceNS&wpSourceArticle=$this->msourceArticle";
		$linkq = 'type=login';
		$linkmsg = 'gotaccount';

		if ( !empty( $this->mReturnTo ) ) {
			$returnto = '&returnto=' . wfUrlencode( $this->mReturnTo );
			if ( !empty( $this->mReturnToQuery ) ) {
				$returnto .= '&returntoquery=' .
					wfUrlencode( $this->mReturnToQuery );
			}
			$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', wfMsgExt( $linkmsg, array( 'parseinline', 'replaceafter' ), $link ) );
		} 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 && $wgUser->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', $wgUser->isLoggedIn() );
		$template->set( 'remember', $wgUser->getOption( 'rememberpassword' ) || $this->mRemember );
		$template->set( 'cansecurelogin', ( $wgSecureLogin === true ) );
		$template->set( 'stickHTTPS', $this->mStickHTTPS );

		$template->set( 'wpSourceAction', $this->mSourceAction );
		$template->set( 'wpSourceNS', $this->mSourceNS );
		$template->set( 'wpSourceArticle', $this->msourceArticle );

		if ( !self::getCreateaccountToken() ) {
			self::setCreateaccountToken();
		}
		$template->set( 'token', self::getCreateaccountToken() );

		# 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, $this->mType );

		wfRunHooks( 'UserCreateForm', array( &$template ) );
		wfRunHooks( 'SignupForm' );

		// Changes the title depending on permissions for creating account
		if ( $wgUser->isAllowed( 'createaccount' ) ) {
			$wgOut->setPageTitle( wfMsg( 'userlogin' ) );
		} else {
			$wgOut->setPageTitle( wfMsg( 'userloginnocreate' ) );
		}

		$wgOut->disallowUserJs(); // just in case...
		$wgOut->addTemplate( $template );

	}
Пример #4
0
 /**
  * @private
  * Wikia change - add new param ($errParam)
  */
 function mainLoginForm($msg, $msgtype = 'error', $errParam = '')
 {
     global $wgEnableEmail, $wgEnableUserEmail;
     global $wgHiddenPrefs, $wgLoginLanguageSelector;
     global $wgAuth, $wgEmailConfirmToEdit, $wgCookieExpiration;
     global $wgSecureLogin, $wgPasswordResetRoutes;
     global $wgOut;
     $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';
         $q2 = 'action=submitlogin&type=login';
         $linkq = 'type=login';
         $linkmsg = 'gotaccount';
         // ADi: marketing opt-in/out checkbox added
         $template->addInputItem('wpMarketingOptIn', 1, 'checkbox', 'tog-marketingallowed');
     } else {
         $template = new UserloginTemplate();
         $q = 'action=submitlogin&type=login';
         $q2 = '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;
         $q2 .= $returnto;
         //$linkq2 .= $returnto; // not used anywhere else... FIXME: REMOVE
     }
     # 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('actioncreate', $titleObj->getLocalUrl($q));
     $template->set('actionlogin', $titleObj->getLocalUrl($q2));
     $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->getGlobalPreference('rememberpassword') || $this->mRemember);
     $template->set('cansecurelogin', $wgSecureLogin === true);
     $template->set('stickHTTPS', $this->mStickHTTPS);
     $template->set('birthyear', $this->wpBirthYear);
     $template->set('birthmonth', $this->wpBirthMonth);
     $template->set('birthday', $this->wpBirthDay);
     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);
 }
Пример #5
0
 public static function getRegisterJS()
 {
     $tpl = new UsercreateTemplate();
     ob_start();
     $tpl->executeRegisterJS();
     $out = ob_get_contents();
     ob_end_clean();
     return $out;
 }
Пример #6
0
 public function onUserCreateForm(\UsercreateTemplate &$template)
 {
     $template->set('header', $this->installHtml());
     return true;
 }