Example #1
0
	/**
	 * @param $user User
	 * @param $context IContextSource
	 * @param $defaultPreferences
	 * @return void
	 */
	static function profilePreferences( $user, IContextSource $context, &$defaultPreferences ) {
		global $wgAuth, $wgContLang, $wgParser, $wgCookieExpiration, $wgLanguageCode,
			$wgDisableTitleConversion, $wgDisableLangConversion, $wgMaxSigChars,
			$wgEnableEmail, $wgEmailConfirmToEdit, $wgEnableUserEmail, $wgEmailAuthentication,
			$wgEnotifWatchlist, $wgEnotifUserTalk, $wgEnotifRevealEditorAddress,
			$wgSecureLogin;

		// retrieving user name for GENDER and misc.
		$userName = $user->getName();

		## User info #####################################
		// Information panel
		$defaultPreferences['username'] = array(
			'type' => 'info',
			'label-message' => array( 'username', $userName ),
			'default' => $userName,
			'section' => 'personal/info',
		);

		$defaultPreferences['userid'] = array(
			'type' => 'info',
			'label-message' => array( 'uid', $userName ),
			'default' => $user->getId(),
			'section' => 'personal/info',
		);

		# Get groups to which the user belongs
		$userEffectiveGroups = $user->getEffectiveGroups();
		$userGroups = $userMembers = array();
		foreach ( $userEffectiveGroups as $ueg ) {
			if ( $ueg == '*' ) {
				// Skip the default * group, seems useless here
				continue;
			}
			$groupName = User::getGroupName( $ueg );
			$userGroups[] = User::makeGroupLinkHTML( $ueg, $groupName );

			$memberName = User::getGroupMember( $ueg, $userName );
			$userMembers[] = User::makeGroupLinkHTML( $ueg, $memberName );
		}
		asort( $userGroups );
		asort( $userMembers );

		$lang = $context->getLanguage();

		$defaultPreferences['usergroups'] = array(
			'type' => 'info',
			'label' => $context->msg( 'prefs-memberingroups' )->numParams(
				count( $userGroups ) )->params( $userName )->parse(),
			'default' => $context->msg( 'prefs-memberingroups-type',
				$lang->commaList( $userGroups ),
				$lang->commaList( $userMembers )
			)->plain(),
			'raw' => true,
			'section' => 'personal/info',
		);

		$editCount = Linker::link( SpecialPage::getTitleFor( "Contributions", $userName ),
			$lang->formatNum( $user->getEditCount() ) );

		$defaultPreferences['editcount'] = array(
			'type' => 'info',
			'raw' => true,
			'label-message' => 'prefs-edits',
			'default' => $editCount,
			'section' => 'personal/info',
		);

		if ( $user->getRegistration() ) {
			$displayUser = $context->getUser();
			$userRegistration = $user->getRegistration();
			$defaultPreferences['registrationdate'] = array(
				'type' => 'info',
				'label-message' => 'prefs-registration',
				'default' => $context->msg(
					'prefs-registration-date-time',
					$lang->userTimeAndDate( $userRegistration, $displayUser ),
					$lang->userDate( $userRegistration, $displayUser ),
					$lang->userTime( $userRegistration, $displayUser )
				)->parse(),
				'section' => 'personal/info',
			);
		}

		$canViewPrivateInfo = $user->isAllowed( 'viewmyprivateinfo' );
		$canEditPrivateInfo = $user->isAllowed( 'editmyprivateinfo' );

		// Actually changeable stuff
		$defaultPreferences['realname'] = array(
			// (not really "private", but still shouldn't be edited without permission)
			'type' => $canEditPrivateInfo && $wgAuth->allowPropChange( 'realname' ) ? 'text' : 'info',
			'default' => $user->getRealName(),
			'section' => 'personal/info',
			'label-message' => 'yourrealname',
			'help-message' => 'prefs-help-realname',
		);

		if ( $canEditPrivateInfo && $wgAuth->allowPasswordChange() ) {
			$link = Linker::link( SpecialPage::getTitleFor( 'ChangePassword' ),
				$context->msg( 'prefs-resetpass' )->escaped(), array(),
				array( 'returnto' => SpecialPage::getTitleFor( 'Preferences' )->getPrefixedText() ) );

			$defaultPreferences['password'] = array(
				'type' => 'info',
				'raw' => true,
				'default' => $link,
				'label-message' => 'yourpassword',
				'section' => 'personal/info',
			);
		}
		if ( $wgCookieExpiration > 0 ) {
			$defaultPreferences['rememberpassword'] = array(
				'type' => 'toggle',
				'label' => $context->msg( 'tog-rememberpassword' )->numParams(
					ceil( $wgCookieExpiration / ( 3600 * 24 ) ) )->text(),
				'section' => 'personal/info',
			);
		}
		// Only show preferhttps if secure login is turned on
		if ( $wgSecureLogin && wfCanIPUseHTTPS( $context->getRequest()->getIP() ) ) {
			$defaultPreferences['prefershttps'] = array(
				'type' => 'toggle',
				'label-message' => 'tog-prefershttps',
				'help-message' => 'prefs-help-prefershttps',
				'section' => 'personal/info'
			);
		}

		// Language
		$languages = Language::fetchLanguageNames( null, 'mw' );
		if ( !array_key_exists( $wgLanguageCode, $languages ) ) {
			$languages[$wgLanguageCode] = $wgLanguageCode;
		}
		ksort( $languages );

		$options = array();
		foreach ( $languages as $code => $name ) {
			$display = wfBCP47( $code ) . ' - ' . $name;
			$options[$display] = $code;
		}
		$defaultPreferences['language'] = array(
			'type' => 'select',
			'section' => 'personal/i18n',
			'options' => $options,
			'label-message' => 'yourlanguage',
		);

		$defaultPreferences['gender'] = array(
			'type' => 'radio',
			'section' => 'personal/i18n',
			'options' => array(
				$context->msg( 'parentheses',
					$context->msg( 'gender-unknown' )->text()
				)->text() => 'unknown',
				$context->msg( 'gender-female' )->text() => 'female',
				$context->msg( 'gender-male' )->text() => 'male',
			),
			'label-message' => 'yourgender',
			'help-message' => 'prefs-help-gender',
		);

		// see if there are multiple language variants to choose from
		if ( !$wgDisableLangConversion ) {
			foreach ( LanguageConverter::$languagesWithVariants as $langCode ) {
				if ( $langCode == $wgContLang->getCode() ) {
					$variants = $wgContLang->getVariants();

					if ( count( $variants ) <= 1 ) {
						continue;
					}

					$variantArray = array();
					foreach ( $variants as $v ) {
						$v = str_replace( '_', '-', strtolower( $v ) );
						$variantArray[$v] = $lang->getVariantname( $v, false );
					}

					$options = array();
					foreach ( $variantArray as $code => $name ) {
						$display = wfBCP47( $code ) . ' - ' . $name;
						$options[$display] = $code;
					}

					$defaultPreferences['variant'] = array(
						'label-message' => 'yourvariant',
						'type' => 'select',
						'options' => $options,
						'section' => 'personal/i18n',
						'help-message' => 'prefs-help-variant',
					);

					if ( !$wgDisableTitleConversion ) {
						$defaultPreferences['noconvertlink'] = array(
							'type' => 'toggle',
							'section' => 'personal/i18n',
							'label-message' => 'tog-noconvertlink',
						);
					}
				} else {
					$defaultPreferences["variant-$langCode"] = array(
						'type' => 'api',
					);
				}
			}
		}

		// Stuff from Language::getExtraUserToggles()
		// FIXME is this dead code? $extraUserToggles doesn't seem to be defined for any language
		$toggles = $wgContLang->getExtraUserToggles();

		foreach ( $toggles as $toggle ) {
			$defaultPreferences[$toggle] = array(
				'type' => 'toggle',
				'section' => 'personal/i18n',
				'label-message' => "tog-$toggle",
			);
		}

		// show a preview of the old signature first
		$oldsigWikiText = $wgParser->preSaveTransform( "~~~", $context->getTitle(), $user, ParserOptions::newFromContext( $context ) );
		$oldsigHTML = $context->getOutput()->parseInline( $oldsigWikiText, true, true );
		$defaultPreferences['oldsig'] = array(
			'type' => 'info',
			'raw' => true,
			'label-message' => 'tog-oldsig',
			'default' => $oldsigHTML,
			'section' => 'personal/signature',
		);
		$defaultPreferences['nickname'] = array(
			'type' => $wgAuth->allowPropChange( 'nickname' ) ? 'text' : 'info',
			'maxlength' => $wgMaxSigChars,
			'label-message' => 'yournick',
			'validation-callback' => array( 'Preferences', 'validateSignature' ),
			'section' => 'personal/signature',
			'filter-callback' => array( 'Preferences', 'cleanSignature' ),
		);
		$defaultPreferences['fancysig'] = array(
			'type' => 'toggle',
			'label-message' => 'tog-fancysig',
			'help-message' => 'prefs-help-signature', // show general help about signature at the bottom of the section
			'section' => 'personal/signature'
		);

		## Email stuff

		if ( $wgEnableEmail ) {
			if ( $canViewPrivateInfo ) {
				$helpMessages[] = $wgEmailConfirmToEdit
						? 'prefs-help-email-required'
						: 'prefs-help-email';

				if ( $wgEnableUserEmail ) {
					// additional messages when users can send email to each other
					$helpMessages[] = 'prefs-help-email-others';
				}

				$emailAddress = $user->getEmail() ? htmlspecialchars( $user->getEmail() ) : '';
				if ( $canEditPrivateInfo && $wgAuth->allowPropChange( 'emailaddress' ) ) {
					$link = Linker::link(
						SpecialPage::getTitleFor( 'ChangeEmail' ),
						$context->msg( $user->getEmail() ? 'prefs-changeemail' : 'prefs-setemail' )->escaped(),
						array(),
						array( 'returnto' => SpecialPage::getTitleFor( 'Preferences' )->getPrefixedText() ) );

					$emailAddress .= $emailAddress == '' ? $link : (
						$context->msg( 'word-separator' )->plain()
						. $context->msg( 'parentheses' )->rawParams( $link )->plain()
					);
				}

				$defaultPreferences['emailaddress'] = array(
					'type' => 'info',
					'raw' => true,
					'default' => $emailAddress,
					'label-message' => 'youremail',
					'section' => 'personal/email',
					'help-messages' => $helpMessages,
					# 'cssclass' chosen below
				);
			}

			$disableEmailPrefs = false;

			if ( $wgEmailAuthentication ) {
				$emailauthenticationclass = 'mw-email-not-authenticated';
				if ( $user->getEmail() ) {
					if ( $user->getEmailAuthenticationTimestamp() ) {
						// date and time are separate parameters to facilitate localisation.
						// $time is kept for backward compat reasons.
						// 'emailauthenticated' is also used in SpecialConfirmemail.php
						$displayUser = $context->getUser();
						$emailTimestamp = $user->getEmailAuthenticationTimestamp();
						$time = $lang->userTimeAndDate( $emailTimestamp, $displayUser );
						$d = $lang->userDate( $emailTimestamp, $displayUser );
						$t = $lang->userTime( $emailTimestamp, $displayUser );
						$emailauthenticated = $context->msg( 'emailauthenticated',
							$time, $d, $t )->parse() . '<br />';
						$disableEmailPrefs = false;
						$emailauthenticationclass = 'mw-email-authenticated';
					} else {
						$disableEmailPrefs = true;
						$emailauthenticated = $context->msg( 'emailnotauthenticated' )->parse() . '<br />' .
							Linker::linkKnown(
								SpecialPage::getTitleFor( 'Confirmemail' ),
								$context->msg( 'emailconfirmlink' )->escaped()
							) . '<br />';
						$emailauthenticationclass = "mw-email-not-authenticated";
					}
				} else {
					$disableEmailPrefs = true;
					$emailauthenticated = $context->msg( 'noemailprefs' )->escaped();
					$emailauthenticationclass = 'mw-email-none';
				}

				if ( $canViewPrivateInfo ) {
					$defaultPreferences['emailauthentication'] = array(
						'type' => 'info',
						'raw' => true,
						'section' => 'personal/email',
						'label-message' => 'prefs-emailconfirm-label',
						'default' => $emailauthenticated,
						# Apply the same CSS class used on the input to the message:
						'cssclass' => $emailauthenticationclass,
					);
					$defaultPreferences['emailaddress']['cssclass'] = $emailauthenticationclass;
				}
			}

			if ( $wgEnableUserEmail && $user->isAllowed( 'sendemail' ) ) {
				$defaultPreferences['disablemail'] = array(
					'type' => 'toggle',
					'invert' => true,
					'section' => 'personal/email',
					'label-message' => 'allowemail',
					'disabled' => $disableEmailPrefs,
				);
				$defaultPreferences['ccmeonemails'] = array(
					'type' => 'toggle',
					'section' => 'personal/email',
					'label-message' => 'tog-ccmeonemails',
					'disabled' => $disableEmailPrefs,
				);
			}

			if ( $wgEnotifWatchlist ) {
				$defaultPreferences['enotifwatchlistpages'] = array(
					'type' => 'toggle',
					'section' => 'personal/email',
					'label-message' => 'tog-enotifwatchlistpages',
					'disabled' => $disableEmailPrefs,
				);
			}
			if ( $wgEnotifUserTalk ) {
				$defaultPreferences['enotifusertalkpages'] = array(
					'type' => 'toggle',
					'section' => 'personal/email',
					'label-message' => 'tog-enotifusertalkpages',
					'disabled' => $disableEmailPrefs,
				);
			}
			if ( $wgEnotifUserTalk || $wgEnotifWatchlist ) {
				$defaultPreferences['enotifminoredits'] = array(
					'type' => 'toggle',
					'section' => 'personal/email',
					'label-message' => 'tog-enotifminoredits',
					'disabled' => $disableEmailPrefs,
				);

				if ( $wgEnotifRevealEditorAddress ) {
					$defaultPreferences['enotifrevealaddr'] = array(
						'type' => 'toggle',
						'section' => 'personal/email',
						'label-message' => 'tog-enotifrevealaddr',
						'disabled' => $disableEmailPrefs,
					);
				}
			}
		}
	}
Example #2
0
 /**
  * @param $user User
  * @param $defaultPreferences
  * @return void
  */
 static function profilePreferences($user, &$defaultPreferences)
 {
     global $wgLang, $wgUser;
     ## User info #####################################
     // Information panel
     $defaultPreferences['username'] = array('type' => 'info', 'label-message' => 'username', 'default' => $user->getName(), 'section' => 'personal/info');
     $defaultPreferences['userid'] = array('type' => 'info', 'label-message' => 'uid', 'default' => $user->getId(), 'section' => 'personal/info');
     # Get groups to which the user belongs
     $userEffectiveGroups = $user->getEffectiveGroups();
     $userGroups = $userMembers = array();
     foreach ($userEffectiveGroups as $ueg) {
         if ($ueg == '*') {
             // Skip the default * group, seems useless here
             continue;
         }
         $groupName = User::getGroupName($ueg);
         $userGroups[] = User::makeGroupLinkHTML($ueg, $groupName);
         $memberName = User::getGroupMember($ueg);
         $userMembers[] = User::makeGroupLinkHTML($ueg, $memberName);
     }
     asort($userGroups);
     asort($userMembers);
     $defaultPreferences['usergroups'] = array('type' => 'info', 'label' => wfMsgExt('prefs-memberingroups', 'parseinline', $wgLang->formatNum(count($userGroups))), 'default' => wfMsgExt('prefs-memberingroups-type', array(), $wgLang->commaList($userGroups), $wgLang->commaList($userMembers)), 'raw' => true, 'section' => 'personal/info');
     $defaultPreferences['editcount'] = array('type' => 'info', 'label-message' => 'prefs-edits', 'default' => $wgLang->formatNum($user->getEditCount()), 'section' => 'personal/info');
     if ($user->getRegistration()) {
         $defaultPreferences['registrationdate'] = array('type' => 'info', 'label-message' => 'prefs-registration', 'default' => wfMsgExt('prefs-registration-date-time', 'parsemag', $wgLang->timeanddate($user->getRegistration(), true), $wgLang->date($user->getRegistration(), true), $wgLang->time($user->getRegistration(), true)), 'section' => 'personal/info');
     }
     // Actually changeable stuff
     global $wgAuth;
     $defaultPreferences['realname'] = array('type' => $wgAuth->allowPropChange('realname') ? 'text' : 'info', 'default' => $user->getRealName(), 'section' => 'personal/info', 'label-message' => 'yourrealname', 'help-message' => 'prefs-help-realname');
     $defaultPreferences['gender'] = array('type' => 'select', 'section' => 'personal/info', 'options' => array(wfMsg('gender-male') => 'male', wfMsg('gender-female') => 'female', wfMsg('gender-unknown') => 'unknown'), 'label-message' => 'yourgender', 'help-message' => 'prefs-help-gender');
     if ($wgAuth->allowPasswordChange()) {
         $link = $wgUser->getSkin()->link(SpecialPage::getTitleFor('ChangePassword'), wfMsgHtml('prefs-resetpass'), array(), array('returnto' => SpecialPage::getTitleFor('Preferences')));
         $defaultPreferences['password'] = array('type' => 'info', 'raw' => true, 'default' => $link, 'label-message' => 'yourpassword', 'section' => 'personal/info');
     }
     global $wgCookieExpiration;
     if ($wgCookieExpiration > 0) {
         $defaultPreferences['rememberpassword'] = array('type' => 'toggle', 'label' => wfMsgExt('tog-rememberpassword', array('parsemag'), $wgLang->formatNum(ceil($wgCookieExpiration / (3600 * 24)))), 'section' => 'personal/info');
     }
     // Language
     global $wgLanguageCode;
     $languages = Language::getLanguageNames(false);
     if (!array_key_exists($wgLanguageCode, $languages)) {
         $languages[$wgLanguageCode] = $wgLanguageCode;
     }
     ksort($languages);
     $options = array();
     foreach ($languages as $code => $name) {
         $display = wfBCP47($code) . ' - ' . $name;
         $options[$display] = $code;
     }
     $defaultPreferences['language'] = array('type' => 'select', 'section' => 'personal/i18n', 'options' => $options, 'label-message' => 'yourlanguage');
     global $wgContLang, $wgDisableLangConversion;
     global $wgDisableTitleConversion;
     /* see if there are multiple language variants to choose from*/
     $variantArray = array();
     if (!$wgDisableLangConversion) {
         $variants = $wgContLang->getVariants();
         $languages = Language::getLanguageNames(true);
         foreach ($variants as $v) {
             $v = str_replace('_', '-', strtolower($v));
             if (array_key_exists($v, $languages)) {
                 // If it doesn't have a name, we'll pretend it doesn't exist
                 $variantArray[$v] = $languages[$v];
             }
         }
         $options = array();
         foreach ($variantArray as $code => $name) {
             $display = wfBCP47($code) . ' - ' . $name;
             $options[$display] = $code;
         }
         if (count($variantArray) > 1) {
             $defaultPreferences['variant'] = array('label-message' => 'yourvariant', 'type' => 'select', 'options' => $options, 'section' => 'personal/i18n');
         }
     }
     if (count($variantArray) > 1 && !$wgDisableLangConversion && !$wgDisableTitleConversion) {
         $defaultPreferences['noconvertlink'] = array('type' => 'toggle', 'section' => 'personal/i18n', 'label-message' => 'tog-noconvertlink');
     }
     global $wgMaxSigChars, $wgOut, $wgParser;
     // show a preview of the old signature first
     $oldsigWikiText = $wgParser->preSaveTransform("~~~", new Title(), $user, new ParserOptions());
     $oldsigHTML = $wgOut->parseInline($oldsigWikiText);
     $defaultPreferences['oldsig'] = array('type' => 'info', 'raw' => true, 'label-message' => 'tog-oldsig', 'default' => $oldsigHTML, 'section' => 'personal/signature');
     $defaultPreferences['nickname'] = array('type' => $wgAuth->allowPropChange('nickname') ? 'text' : 'info', 'maxlength' => $wgMaxSigChars, 'label-message' => 'yournick', 'validation-callback' => array('Preferences', 'validateSignature'), 'section' => 'personal/signature', 'filter-callback' => array('Preferences', 'cleanSignature'));
     $defaultPreferences['fancysig'] = array('type' => 'toggle', 'label-message' => 'tog-fancysig', 'help-message' => 'prefs-help-signature', 'section' => 'personal/signature');
     ## Email stuff
     global $wgEnableEmail;
     if ($wgEnableEmail) {
         global $wgEmailConfirmToEdit;
         global $wgEnableUserEmail;
         $helpMessages[] = $wgEmailConfirmToEdit ? 'prefs-help-email-required' : 'prefs-help-email';
         if ($wgEnableUserEmail) {
             // additional messages when users can send email to each other
             $helpMessages[] = 'prefs-help-email-others';
         }
         $defaultPreferences['emailaddress'] = array('type' => $wgAuth->allowPropChange('emailaddress') ? 'email' : 'info', 'default' => $user->getEmail(), 'section' => 'personal/email', 'label-message' => 'youremail', 'help-messages' => $helpMessages, 'validation-callback' => array('Preferences', 'validateEmail'));
         global $wgEmailAuthentication;
         $disableEmailPrefs = false;
         if ($wgEmailAuthentication) {
             if ($user->getEmail()) {
                 if ($user->getEmailAuthenticationTimestamp()) {
                     // date and time are separate parameters to facilitate localisation.
                     // $time is kept for backward compat reasons.
                     // 'emailauthenticated' is also used in SpecialConfirmemail.php
                     $time = $wgLang->timeAndDate($user->getEmailAuthenticationTimestamp(), true);
                     $d = $wgLang->date($user->getEmailAuthenticationTimestamp(), true);
                     $t = $wgLang->time($user->getEmailAuthenticationTimestamp(), true);
                     $emailauthenticated = wfMsgExt('emailauthenticated', 'parseinline', array($time, $d, $t)) . '<br />';
                     $disableEmailPrefs = false;
                 } else {
                     $disableEmailPrefs = true;
                     $skin = $wgUser->getSkin();
                     $emailauthenticated = wfMsgExt('emailnotauthenticated', 'parseinline') . '<br />' . $skin->link(SpecialPage::getTitleFor('Confirmemail'), wfMsg('emailconfirmlink'), array(), array(), array('known', 'noclasses')) . '<br />';
                 }
             } else {
                 $disableEmailPrefs = true;
                 $emailauthenticated = wfMsgHtml('noemailprefs');
             }
             $defaultPreferences['emailauthentication'] = array('type' => 'info', 'raw' => true, 'section' => 'personal/email', 'label-message' => 'prefs-emailconfirm-label', 'default' => $emailauthenticated);
         }
         if ($wgEnableUserEmail && $user->isAllowed('sendemail')) {
             $defaultPreferences['disablemail'] = array('type' => 'toggle', 'invert' => true, 'section' => 'personal/email', 'label-message' => 'allowemail', 'disabled' => $disableEmailPrefs);
             $defaultPreferences['ccmeonemails'] = array('type' => 'toggle', 'section' => 'personal/email', 'label-message' => 'tog-ccmeonemails', 'disabled' => $disableEmailPrefs);
         }
         global $wgEnotifWatchlist;
         if ($wgEnotifWatchlist) {
             $defaultPreferences['enotifwatchlistpages'] = array('type' => 'toggle', 'section' => 'personal/email', 'label-message' => 'tog-enotifwatchlistpages', 'disabled' => $disableEmailPrefs);
         }
         global $wgEnotifUserTalk;
         if ($wgEnotifUserTalk) {
             $defaultPreferences['enotifusertalkpages'] = array('type' => 'toggle', 'section' => 'personal/email', 'label-message' => 'tog-enotifusertalkpages', 'disabled' => $disableEmailPrefs);
         }
         if ($wgEnotifUserTalk || $wgEnotifWatchlist) {
             $defaultPreferences['enotifminoredits'] = array('type' => 'toggle', 'section' => 'personal/email', 'label-message' => 'tog-enotifminoredits', 'disabled' => $disableEmailPrefs);
             global $wgEnotifRevealEditorAddress;
             if ($wgEnotifRevealEditorAddress) {
                 $defaultPreferences['enotifrevealaddr'] = array('type' => 'toggle', 'section' => 'personal/email', 'label-message' => 'tog-enotifrevealaddr', 'disabled' => $disableEmailPrefs);
             }
         }
     }
 }
    /**
     * @access private
     */
    function mainPrefsForm($status, $message = '')
    {
        global $wgUser, $wgOut, $wgLang, $wgContLang, $wgAuth;
        global $wgAllowRealName, $wgImageLimits, $wgThumbLimits;
        global $wgDisableLangConversion, $wgDisableTitleConversion;
        global $wgEnotifWatchlist, $wgEnotifUserTalk, $wgEnotifMinorEdits;
        global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress;
        global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
        global $wgContLanguageCode, $wgDefaultSkin, $wgCookieExpiration;
        global $wgEmailConfirmToEdit, $wgEnableMWSuggest, $wgLocalTZoffset;
        $wgOut->setPageTitle(wfMsg('preferences'));
        $wgOut->setArticleRelated(false);
        $wgOut->setRobotPolicy('noindex,nofollow');
        $wgOut->addScriptFile('prefs.js');
        $wgOut->disallowUserJs();
        # Prevent hijacked user scripts from sniffing passwords etc.
        if ($this->mSuccess || 'success' == $status) {
            $wgOut->wrapWikiMsg('<div class="successbox"><strong>$1</strong></div>', 'savedprefs');
        } else {
            if ('error' == $status) {
                $wgOut->addWikiText('<div class="errorbox"><strong>' . $message . '</strong></div>');
            } else {
                if ('' != $status) {
                    $wgOut->addWikiText($message . "\n----");
                }
            }
        }
        $qbs = $wgLang->getQuickbarSettings();
        $mathopts = $wgLang->getMathNames();
        $dateopts = $wgLang->getDatePreferences();
        $togs = User::getToggles();
        $titleObj = SpecialPage::getTitleFor('Preferences');
        # Pre-expire some toggles so they won't show if disabled
        $this->mUsedToggles['shownumberswatching'] = true;
        $this->mUsedToggles['showupdated'] = true;
        $this->mUsedToggles['enotifwatchlistpages'] = true;
        $this->mUsedToggles['enotifusertalkpages'] = true;
        $this->mUsedToggles['enotifminoredits'] = true;
        $this->mUsedToggles['enotifrevealaddr'] = true;
        $this->mUsedToggles['ccmeonemails'] = true;
        $this->mUsedToggles['uselivepreview'] = true;
        $this->mUsedToggles['noconvertlink'] = true;
        if (!$this->mEmailFlag) {
            $emfc = 'checked="checked"';
        } else {
            $emfc = '';
        }
        if ($wgEmailAuthentication && $this->mUserEmail != '') {
            if ($wgUser->getEmailAuthenticationTimestamp()) {
                // date and time are separate parameters to facilitate localisation.
                // $time is kept for backward compat reasons.
                // 'emailauthenticated' is also used in SpecialConfirmemail.php
                $time = $wgLang->timeAndDate($wgUser->getEmailAuthenticationTimestamp(), true);
                $d = $wgLang->date($wgUser->getEmailAuthenticationTimestamp(), true);
                $t = $wgLang->time($wgUser->getEmailAuthenticationTimestamp(), true);
                $emailauthenticated = wfMsg('emailauthenticated', $time, $d, $t) . '<br />';
                $disableEmailPrefs = false;
            } else {
                $disableEmailPrefs = true;
                $skin = $wgUser->getSkin();
                $emailauthenticated = wfMsg('emailnotauthenticated') . '<br />' . $skin->makeKnownLinkObj(SpecialPage::getTitleFor('Confirmemail'), wfMsg('emailconfirmlink')) . '<br />';
            }
        } else {
            $emailauthenticated = '';
            $disableEmailPrefs = false;
        }
        if ($this->mUserEmail == '') {
            $emailauthenticated = wfMsg('noemailprefs') . '<br />';
        }
        $ps = $this->namespacesCheckboxes();
        $enotifwatchlistpages = $wgEnotifWatchlist ? $this->getToggle('enotifwatchlistpages', false, $disableEmailPrefs) : '';
        $enotifusertalkpages = $wgEnotifUserTalk ? $this->getToggle('enotifusertalkpages', false, $disableEmailPrefs) : '';
        $enotifminoredits = $wgEnotifWatchlist && $wgEnotifMinorEdits ? $this->getToggle('enotifminoredits', false, $disableEmailPrefs) : '';
        $enotifrevealaddr = ($wgEnotifWatchlist || $wgEnotifUserTalk) && $wgEnotifRevealEditorAddress ? $this->getToggle('enotifrevealaddr', false, $disableEmailPrefs) : '';
        # </FIXME>
        $wgOut->addHTML(Xml::openElement('form', array('action' => $titleObj->getLocalUrl(), 'method' => 'post', 'id' => 'mw-preferences-form')) . Xml::openElement('div', array('id' => 'preferences')));
        # User data
        $wgOut->addHTML(Xml::fieldset(wfMsg('prefs-personal')) . Xml::openElement('table') . $this->tableRow(Xml::element('h2', null, wfMsg('prefs-personal'))));
        # Get groups to which the user belongs
        $userEffectiveGroups = $wgUser->getEffectiveGroups();
        $userEffectiveGroupsArray = array();
        foreach ($userEffectiveGroups as $ueg) {
            if ($ueg == '*') {
                // Skip the default * group, seems useless here
                continue;
            }
            $userEffectiveGroupsArray[] = User::makeGroupLinkHTML($ueg);
        }
        asort($userEffectiveGroupsArray);
        $sk = $wgUser->getSkin();
        $toolLinks = array();
        $toolLinks[] = $sk->makeKnownLinkObj(SpecialPage::getTitleFor('ListGroupRights'), wfMsg('listgrouprights'));
        # At the moment one tool link only but be prepared for the future...
        # FIXME: Add a link to Special:Userrights for users who are allowed to use it.
        # $wgUser->isAllowed( 'userrights' ) seems to strict in some cases
        $userInformationHtml = $this->tableRow(wfMsgHtml('username'), htmlspecialchars($wgUser->getName())) . $this->tableRow(wfMsgHtml('uid'), $wgLang->formatNum(htmlspecialchars($wgUser->getId()))) . $this->tableRow(wfMsgExt('prefs-memberingroups', array('parseinline'), count($userEffectiveGroupsArray)), $wgLang->commaList($userEffectiveGroupsArray) . '<br />(' . implode(' | ', $toolLinks) . ')') . $this->tableRow(wfMsgHtml('prefs-edits'), $wgLang->formatNum($wgUser->getEditCount()));
        if (wfRunHooks('PreferencesUserInformationPanel', array($this, &$userInformationHtml))) {
            $wgOut->addHTML($userInformationHtml);
        }
        if ($wgAllowRealName) {
            $wgOut->addHTML($this->tableRow(Xml::label(wfMsg('yourrealname'), 'wpRealName'), Xml::input('wpRealName', 25, $this->mRealName, array('id' => 'wpRealName')), Xml::tags('div', array('class' => 'prefsectiontip'), wfMsgExt('prefs-help-realname', 'parseinline'))));
        }
        if ($wgEnableEmail) {
            $wgOut->addHTML($this->tableRow(Xml::label(wfMsg('youremail'), 'wpUserEmail'), Xml::input('wpUserEmail', 25, $this->mUserEmail, array('id' => 'wpUserEmail')), Xml::tags('div', array('class' => 'prefsectiontip'), wfMsgExt($wgEmailConfirmToEdit ? 'prefs-help-email-required' : 'prefs-help-email', 'parseinline'))));
        }
        global $wgParser, $wgMaxSigChars;
        if (mb_strlen($this->mNick) > $wgMaxSigChars) {
            $invalidSig = $this->tableRow('&nbsp;', Xml::element('span', array('class' => 'error'), wfMsgExt('badsiglength', 'parsemag', $wgLang->formatNum($wgMaxSigChars))));
        } elseif (!empty($this->mToggles['fancysig']) && false === $wgParser->validateSig($this->mNick)) {
            $invalidSig = $this->tableRow('&nbsp;', Xml::element('span', array('class' => 'error'), wfMsg('badsig')));
        } else {
            $invalidSig = '';
        }
        $wgOut->addHTML($this->tableRow(Xml::label(wfMsg('yournick'), 'wpNick'), Xml::input('wpNick', 25, $this->mNick, array('id' => 'wpNick', 'maxlength' => $wgMaxSigChars))) . $invalidSig . $this->tableRow('&nbsp;', $this->getToggle('fancysig')));
        list($lsLabel, $lsSelect) = Xml::languageSelector($this->mUserLanguage);
        $wgOut->addHTML($this->tableRow($lsLabel, $lsSelect));
        /* see if there are multiple language variants to choose from*/
        if (!$wgDisableLangConversion) {
            $variants = $wgContLang->getVariants();
            $variantArray = array();
            $languages = Language::getLanguageNames(true);
            foreach ($variants as $v) {
                $v = str_replace('_', '-', strtolower($v));
                if (array_key_exists($v, $languages)) {
                    // If it doesn't have a name, we'll pretend it doesn't exist
                    $variantArray[$v] = $languages[$v];
                }
            }
            $options = "\n";
            foreach ($variantArray as $code => $name) {
                $selected = $code == $this->mUserVariant;
                $options .= Xml::option("{$code} - {$name}", $code, $selected) . "\n";
            }
            if (count($variantArray) > 1) {
                $wgOut->addHTML($this->tableRow(Xml::label(wfMsg('yourvariant'), 'wpUserVariant'), Xml::tags('select', array('name' => 'wpUserVariant', 'id' => 'wpUserVariant'), $options)));
            }
            if (count($variantArray) > 1 && !$wgDisableLangConversion && !$wgDisableTitleConversion) {
                $wgOut->addHTML(Xml::tags('tr', null, Xml::tags('td', array('colspan' => '2'), $this->getToggle("noconvertlink"))));
            }
        }
        # Password
        if ($wgAuth->allowPasswordChange()) {
            $link = $wgUser->getSkin()->link(SpecialPage::getTitleFor('ResetPass'), wfMsgHtml('prefs-resetpass'), array(), array('returnto' => SpecialPage::getTitleFor('Preferences')));
            $wgOut->addHTML($this->tableRow(Xml::element('h2', null, wfMsg('changepassword'))) . $this->tableRow('<ul><li>' . $link . '</li></ul>'));
        }
        # <FIXME>
        # Enotif
        if ($wgEnableEmail) {
            $moreEmail = '';
            if ($wgEnableUserEmail) {
                // fixme -- the "allowemail" pseudotoggle is a hacked-together
                // inversion for the "disableemail" preference.
                $emf = wfMsg('allowemail');
                $disabled = $disableEmailPrefs ? ' disabled="disabled"' : '';
                $moreEmail = "<input type='checkbox' {$emfc} {$disabled} value='1' name='wpEmailFlag' id='wpEmailFlag' /> <label for='wpEmailFlag'>{$emf}</label>" . $this->getToggle('ccmeonemails', '', $disableEmailPrefs);
            }
            $wgOut->addHTML($this->tableRow(Xml::element('h2', null, wfMsg('email'))) . $this->tableRow($emailauthenticated . $enotifrevealaddr . $enotifwatchlistpages . $enotifusertalkpages . $enotifminoredits . $moreEmail));
        }
        # </FIXME>
        $wgOut->addHTML(Xml::closeElement('table') . Xml::closeElement('fieldset'));
        # Quickbar
        #
        if ($this->mSkin == 'cologneblue' || $this->mSkin == 'standard') {
            $wgOut->addHTML("<fieldset>\n<legend>" . wfMsg('qbsettings') . "</legend>\n");
            for ($i = 0; $i < count($qbs); ++$i) {
                if ($i == $this->mQuickbar) {
                    $checked = ' checked="checked"';
                } else {
                    $checked = "";
                }
                $wgOut->addHTML("<div><label><input type='radio' name='wpQuickbar' value=\"{$i}\"{$checked} />{$qbs[$i]}</label></div>\n");
            }
            $wgOut->addHTML("</fieldset>\n\n");
        } else {
            # Need to output a hidden option even if the relevant skin is not in use,
            # otherwise the preference will get reset to 0 on submit
            $wgOut->addHTML(Xml::hidden('wpQuickbar', $this->mQuickbar));
        }
        # Skin
        #
        global $wgAllowUserSkin;
        if ($wgAllowUserSkin) {
            $wgOut->addHTML("<fieldset>\n<legend>\n" . wfMsg('skin') . "</legend>\n");
            $mptitle = Title::newMainPage();
            $previewtext = wfMsg('skin-preview');
            # Only show members of Skin::getSkinNames() rather than
            # $skinNames (skins is all skin names from Language.php)
            $validSkinNames = Skin::getUsableSkins();
            # Sort by UI skin name. First though need to update validSkinNames as sometimes
            # the skinkey & UI skinname differ (e.g. "standard" skinkey is "Classic" in the UI).
            foreach ($validSkinNames as $skinkey => &$skinname) {
                $msgName = "skinname-{$skinkey}";
                $localisedSkinName = wfMsg($msgName);
                if (!wfEmptyMsg($msgName, $localisedSkinName)) {
                    $skinname = $localisedSkinName;
                }
            }
            asort($validSkinNames);
            foreach ($validSkinNames as $skinkey => $sn) {
                $checked = $skinkey == $this->mSkin ? ' checked="checked"' : '';
                $mplink = htmlspecialchars($mptitle->getLocalURL("useskin={$skinkey}"));
                $previewlink = "(<a target='_blank' href=\"{$mplink}\">{$previewtext}</a>)";
                if ($skinkey == $wgDefaultSkin) {
                    $sn .= ' (' . wfMsg('default') . ')';
                }
                $wgOut->addHTML("<input type='radio' name='wpSkin' id=\"wpSkin{$skinkey}\" value=\"{$skinkey}\"{$checked} /> <label for=\"wpSkin{$skinkey}\">{$sn}</label> {$previewlink}<br />\n");
            }
            $wgOut->addHTML("</fieldset>\n\n");
        }
        # Math
        #
        global $wgUseTeX;
        if ($wgUseTeX) {
            $wgOut->addHTML("<fieldset>\n<legend>" . wfMsg('math') . '</legend>');
            foreach ($mathopts as $k => $v) {
                $checked = $k == $this->mMath;
                $wgOut->addHTML(Xml::openElement('div') . Xml::radioLabel(wfMsg($v), 'wpMath', $k, "mw-sp-math-{$k}", $checked) . Xml::closeElement('div') . "\n");
            }
            $wgOut->addHTML("</fieldset>\n\n");
        }
        # Files
        #
        $imageLimitOptions = null;
        foreach ($wgImageLimits as $index => $limits) {
            $selected = $index == $this->mImageSize;
            $imageLimitOptions .= Xml::option("{$limits[0]}×{$limits[1]}" . wfMsg('unit-pixel'), $index, $selected);
        }
        $imageThumbOptions = null;
        foreach ($wgThumbLimits as $index => $size) {
            $selected = $index == $this->mThumbSize;
            $imageThumbOptions .= Xml::option($size . wfMsg('unit-pixel'), $index, $selected);
        }
        $imageSizeId = 'wpImageSize';
        $thumbSizeId = 'wpThumbSize';
        $wgOut->addHTML(Xml::fieldset(wfMsg('files')) . "\n" . Xml::openElement('table') . '<tr>
					<td class="mw-label">' . Xml::label(wfMsg('imagemaxsize'), $imageSizeId) . '</td>
					<td class="mw-input">' . Xml::openElement('select', array('name' => $imageSizeId, 'id' => $imageSizeId)) . $imageLimitOptions . Xml::closeElement('select') . '</td>
				</tr><tr>
					<td class="mw-label">' . Xml::label(wfMsg('thumbsize'), $thumbSizeId) . '</td>
					<td class="mw-input">' . Xml::openElement('select', array('name' => $thumbSizeId, 'id' => $thumbSizeId)) . $imageThumbOptions . Xml::closeElement('select') . '</td>
				</tr>' . Xml::closeElement('table') . Xml::closeElement('fieldset'));
        # Date format
        #
        # Date/Time
        #
        $wgOut->addHTML(Xml::openElement('fieldset') . Xml::element('legend', null, wfMsg('datetime')) . "\n");
        if ($dateopts) {
            $wgOut->addHTML(Xml::openElement('fieldset') . Xml::element('legend', null, wfMsg('dateformat')) . "\n");
            $idCnt = 0;
            $epoch = '20010115161234';
            # Wikipedia day
            foreach ($dateopts as $key) {
                if ($key == 'default') {
                    $formatted = wfMsg('datedefault');
                } else {
                    $formatted = $wgLang->timeanddate($epoch, false, $key);
                }
                $wgOut->addHTML(Xml::tags('div', null, Xml::radioLabel($formatted, 'wpDate', $key, "wpDate{$idCnt}", $key == $this->mDate)) . "\n");
                $idCnt++;
            }
            $wgOut->addHTML(Xml::closeElement('fieldset') . "\n");
        }
        $nowlocal = Xml::openElement('span', array('id' => 'wpLocalTime')) . $wgLang->time($now = wfTimestampNow(), true) . Xml::closeElement('span');
        $nowserver = $wgLang->time($now, false) . Xml::hidden('wpServerTime', substr($now, 8, 2) * 60 + substr($now, 10, 2));
        $wgOut->addHTML(Xml::openElement('fieldset') . Xml::element('legend', null, wfMsg('timezonelegend')) . Xml::openElement('table') . $this->addRow(wfMsg('servertime'), $nowserver) . $this->addRow(wfMsg('localtime'), $nowlocal));
        $opt = Xml::openElement('select', array('name' => 'wpTimeZone', 'id' => 'wpTimeZone', 'onchange' => 'javascript:updateTimezoneSelection(false)'));
        $opt .= Xml::option(wfMsg('timezoneuseserverdefault'), "System|{$wgLocalTZoffset}", $this->mTimeZone === "System|{$wgLocalTZoffset}");
        $opt .= Xml::option(wfMsg('timezoneuseoffset'), 'Offset', $this->mTimeZone === 'Offset');
        if (function_exists('timezone_identifiers_list')) {
            $optgroup = '';
            $tzs = timezone_identifiers_list();
            sort($tzs);
            $selZone = explode('|', $this->mTimeZone, 3);
            $selZone = $selZone[0] == 'ZoneInfo' ? $selZone[2] : null;
            $now = date_create('now');
            foreach ($tzs as $tz) {
                $z = explode('/', $tz, 2);
                # timezone_identifiers_list() returns a number of
                # backwards-compatibility entries. This filters them out of the
                # list presented to the user.
                if (count($z) != 2 || !in_array($z[0], array('Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific'))) {
                    continue;
                }
                if ($optgroup != $z[0]) {
                    if ($optgroup !== '') {
                        $opt .= Xml::closeElement('optgroup');
                    }
                    $optgroup = $z[0];
                    $opt .= Xml::openElement('optgroup', array('label' => $z[0]));
                }
                $minDiff = floor(timezone_offset_get(timezone_open($tz), $now) / 60);
                $opt .= Xml::option(str_replace('_', ' ', $tz), "ZoneInfo|{$minDiff}|{$tz}", $selZone === $tz, array('label' => $z[1]));
            }
            if ($optgroup !== '') {
                $opt .= Xml::closeElement('optgroup');
            }
        }
        $opt .= Xml::closeElement('select');
        $wgOut->addHTML($this->addRow(Xml::label(wfMsg('timezoneselect'), 'wpTimeZone'), $opt));
        $wgOut->addHTML($this->addRow(Xml::label(wfMsg('timezoneoffset'), 'wpHourDiff'), Xml::input('wpHourDiff', 6, $this->mHourDiff, array('id' => 'wpHourDiff', 'onfocus' => 'javascript:updateTimezoneSelection(true)', 'onblur' => 'javascript:updateTimezoneSelection(false)'))) . "<tr>\n\t\t\t\t<td></td>\n\t\t\t\t<td class='mw-submit'>" . Xml::element('input', array('type' => 'button', 'value' => wfMsg('guesstimezone'), 'onclick' => 'javascript:guessTimezone()', 'id' => 'guesstimezonebutton', 'style' => 'display:none;')) . "</td>\n\t\t\t</tr>" . Xml::closeElement('table') . Xml::tags('div', array('class' => 'prefsectiontip'), wfMsgExt('timezonetext', 'parseinline')) . Xml::closeElement('fieldset') . Xml::closeElement('fieldset') . "\n\n");
        # Editing
        #
        global $wgLivePreview;
        $wgOut->addHTML(Xml::fieldset(wfMsg('textboxsize')) . wfMsgHTML('prefs-edit-boxsize') . ' ' . Xml::inputLabel(wfMsg('rows'), 'wpRows', 'wpRows', 3, $this->mRows) . ' ' . Xml::inputLabel(wfMsg('columns'), 'wpCols', 'wpCols', 3, $this->mCols) . $this->getToggles(array('editsection', 'editsectiononrightclick', 'editondblclick', 'editwidth', 'showtoolbar', 'previewonfirst', 'previewontop', 'minordefault', 'externaleditor', 'externaldiff', $wgLivePreview ? 'uselivepreview' : false, 'forceeditsummary')));
        $wgOut->addHTML(Xml::closeElement('fieldset'));
        # Recent changes
        global $wgRCMaxAge;
        $wgOut->addHTML(Xml::fieldset(wfMsg('prefs-rc')) . Xml::openElement('table') . '<tr>
					<td class="mw-label">' . Xml::label(wfMsg('recentchangesdays'), 'wpRecentDays') . '</td>
					<td class="mw-input">' . Xml::input('wpRecentDays', 3, $this->mRecentDays, array('id' => 'wpRecentDays')) . ' ' . wfMsgExt('recentchangesdays-max', 'parsemag', $wgLang->formatNum(ceil($wgRCMaxAge / (3600 * 24)))) . '</td>
				</tr><tr>
					<td class="mw-label">' . Xml::label(wfMsg('recentchangescount'), 'wpRecent') . '</td>
					<td class="mw-input">' . Xml::input('wpRecent', 3, $this->mRecent, array('id' => 'wpRecent')) . '</td>
				</tr>' . Xml::closeElement('table') . '<br />');
        $toggles[] = 'hideminor';
        if ($wgRCShowWatchingUsers) {
            $toggles[] = 'shownumberswatching';
        }
        $toggles[] = 'usenewrc';
        $wgOut->addHTML($this->getToggles($toggles) . Xml::closeElement('fieldset'));
        # Watchlist
        $wgOut->addHTML(Xml::fieldset(wfMsg('prefs-watchlist')) . Xml::inputLabel(wfMsg('prefs-watchlist-days'), 'wpWatchlistDays', 'wpWatchlistDays', 3, $this->mWatchlistDays) . ' ' . wfMsgHTML('prefs-watchlist-days-max') . '<br /><br />' . $this->getToggle('extendwatchlist') . Xml::inputLabel(wfMsg('prefs-watchlist-edits'), 'wpWatchlistEdits', 'wpWatchlistEdits', 3, $this->mWatchlistEdits) . ' ' . wfMsgHTML('prefs-watchlist-edits-max') . '<br /><br />' . $this->getToggles(array('watchlisthideminor', 'watchlisthidebots', 'watchlisthideown', 'watchlisthideanons', 'watchlisthideliu')));
        if ($wgUser->isAllowed('createpage') || $wgUser->isAllowed('createtalk')) {
            $wgOut->addHTML($this->getToggle('watchcreations'));
        }
        foreach (array('edit' => 'watchdefault', 'move' => 'watchmoves', 'delete' => 'watchdeletion') as $action => $toggle) {
            if ($wgUser->isAllowed($action)) {
                $wgOut->addHTML($this->getToggle($toggle));
            }
        }
        $this->mUsedToggles['watchcreations'] = true;
        $this->mUsedToggles['watchdefault'] = true;
        $this->mUsedToggles['watchmoves'] = true;
        $this->mUsedToggles['watchdeletion'] = true;
        $wgOut->addHTML(Xml::closeElement('fieldset'));
        # Search
        $mwsuggest = $wgEnableMWSuggest ? $this->addRow(Xml::label(wfMsg('mwsuggest-disable'), 'wpDisableMWSuggest'), Xml::check('wpDisableMWSuggest', $this->mDisableMWSuggest, array('id' => 'wpDisableMWSuggest'))) : '';
        $wgOut->addHTML(Xml::openElement('fieldset') . Xml::element('legend', null, wfMsg('searchresultshead')) . Xml::openElement('fieldset') . Xml::element('legend', null, wfMsg('prefs-searchoptions')) . Xml::openElement('table') . $this->addRow(Xml::label(wfMsg('resultsperpage'), 'wpSearch'), Xml::input('wpSearch', 4, $this->mSearch, array('id' => 'wpSearch'))) . $this->addRow(Xml::label(wfMsg('contextlines'), 'wpSearchLines'), Xml::input('wpSearchLines', 4, $this->mSearchLines, array('id' => 'wpSearchLines'))) . $this->addRow(Xml::label(wfMsg('contextchars'), 'wpSearchChars'), Xml::input('wpSearchChars', 4, $this->mSearchChars, array('id' => 'wpSearchChars'))) . $mwsuggest . Xml::closeElement('table') . Xml::closeElement('fieldset') . Xml::openElement('fieldset') . Xml::element('legend', null, wfMsg('prefs-namespaces')) . wfMsgExt('defaultns', array('parse')) . $ps . Xml::closeElement('fieldset') . Xml::closeElement('fieldset'));
        # Misc
        #
        $wgOut->addHTML('<fieldset><legend>' . wfMsg('prefs-misc') . '</legend>');
        $wgOut->addHTML('<label for="wpStubs">' . wfMsg('stub-threshold') . '</label>&nbsp;');
        $wgOut->addHTML(Xml::input('wpStubs', 6, $this->mStubs, array('id' => 'wpStubs')));
        $msgUnderline = htmlspecialchars(wfMsg('tog-underline'));
        $msgUnderlinenever = htmlspecialchars(wfMsg('underline-never'));
        $msgUnderlinealways = htmlspecialchars(wfMsg('underline-always'));
        $msgUnderlinedefault = htmlspecialchars(wfMsg('underline-default'));
        $uopt = $wgUser->getOption("underline");
        $s0 = $uopt == 0 ? ' selected="selected"' : '';
        $s1 = $uopt == 1 ? ' selected="selected"' : '';
        $s2 = $uopt == 2 ? ' selected="selected"' : '';
        $wgOut->addHTML("\n<div class='toggle'><p><label for='wpOpunderline'>{$msgUnderline}</label>\n<select name='wpOpunderline' id='wpOpunderline'>\n<option value=\"0\"{$s0}>{$msgUnderlinenever}</option>\n<option value=\"1\"{$s1}>{$msgUnderlinealways}</option>\n<option value=\"2\"{$s2}>{$msgUnderlinedefault}</option>\n</select></p></div>");
        foreach ($togs as $tname) {
            if (!array_key_exists($tname, $this->mUsedToggles)) {
                if ($tname == 'norollbackdiff' && $wgUser->isAllowed('rollback')) {
                    $wgOut->addHTML($this->getToggle($tname));
                } else {
                    $wgOut->addHTML($this->getToggle($tname));
                }
            }
        }
        $wgOut->addHTML('</fieldset>');
        wfRunHooks('RenderPreferencesForm', array($this, $wgOut));
        $token = htmlspecialchars($wgUser->editToken());
        $skin = $wgUser->getSkin();
        $wgOut->addHTML("\n\t<div id='prefsubmit'>\n\t<div>\n\t\t<input type='submit' name='wpSaveprefs' class='btnSavePrefs' value=\"" . wfMsgHtml('saveprefs') . '"' . $skin->tooltipAndAccesskey('save') . " />\n\t\t<input type='submit' name='wpReset' value=\"" . wfMsgHtml('resetprefs') . "\" />\n\t</div>\n\n\t</div>\n\n\t<input type='hidden' name='wpEditToken' value=\"{$token}\" />\n\t</div></form>\n");
        $wgOut->addHTML(Xml::tags('div', array('class' => "prefcache"), wfMsgExt('clearyourcache', 'parseinline')));
    }
Example #4
0
 /**
  * Format a link to a group description page
  *
  * @param string $group Group name
  * @param string $username Username
  * @return string
  */
 protected static function buildGroupLink($group, $username)
 {
     return User::makeGroupLinkHTML($group, User::getGroupMember($group, $username));
 }
 /**
  * Get the list of groups of user
  * @param User $user The user object to get the list from
  * @return string comma separated list of user groups
  */
 function listGroups(User $user)
 {
     # Get groups to which the user belongs
     $userGroups = $user->getGroups();
     $userMembers = array();
     foreach ($userGroups as $n => $ug) {
         $memberName = User::getGroupMember($ug, $user->getName());
         if ($n == 0) {
             $memberName = $this->getLanguage()->ucfirst($memberName);
         }
         $userMembers[] = User::makeGroupLinkHTML($ug, $memberName);
     }
     return $this->getLanguage()->commaList($userMembers);
 }
Example #6
0
 /**
  * @param $user User
  * @param $context IContextSource
  * @param $defaultPreferences
  * @return void
  */
 static function profilePreferences($user, IContextSource $context, &$defaultPreferences)
 {
     global $wgAuth, $wgContLang, $wgParser, $wgCookieExpiration, $wgLanguageCode, $wgDisableTitleConversion, $wgDisableLangConversion, $wgMaxSigChars, $wgEnableEmail, $wgEmailConfirmToEdit, $wgEnableUserEmail, $wgEmailAuthentication, $wgEnotifWatchlist, $wgEnotifUserTalk, $wgEnotifRevealEditorAddress;
     ## User info #####################################
     // Information panel
     $defaultPreferences['username'] = array('type' => 'info', 'label-message' => 'username', 'default' => $user->getName(), 'section' => 'personal/info');
     $defaultPreferences['userid'] = array('type' => 'info', 'label-message' => 'uid', 'default' => $user->getId(), 'section' => 'personal/info');
     # Get groups to which the user belongs
     $userEffectiveGroups = $user->getEffectiveGroups();
     $userGroups = $userMembers = array();
     foreach ($userEffectiveGroups as $ueg) {
         if ($ueg == '*') {
             // Skip the default * group, seems useless here
             continue;
         }
         $groupName = User::getGroupName($ueg);
         $userGroups[] = User::makeGroupLinkHTML($ueg, $groupName);
         $memberName = User::getGroupMember($ueg, $user->getName());
         $userMembers[] = User::makeGroupLinkHTML($ueg, $memberName);
     }
     asort($userGroups);
     asort($userMembers);
     $lang = $context->getLanguage();
     $defaultPreferences['usergroups'] = array('type' => 'info', 'label' => $context->msg('prefs-memberingroups')->numParams(count($userGroups))->parse(), 'default' => $context->msg('prefs-memberingroups-type', $lang->commaList($userGroups), $lang->commaList($userMembers))->plain(), 'raw' => true, 'section' => 'personal/info');
     $defaultPreferences['editcount'] = array('type' => 'info', 'label-message' => 'prefs-edits', 'default' => $lang->formatNum($user->getEditCount()), 'section' => 'personal/info');
     if ($user->getRegistration()) {
         $displayUser = $context->getUser();
         $userRegistration = $user->getRegistration();
         $defaultPreferences['registrationdate'] = array('type' => 'info', 'label-message' => 'prefs-registration', 'default' => $context->msg('prefs-registration-date-time', $lang->userTimeAndDate($userRegistration, $displayUser), $lang->userDate($userRegistration, $displayUser), $lang->userTime($userRegistration, $displayUser))->parse(), 'section' => 'personal/info');
     }
     // Actually changeable stuff
     $defaultPreferences['realname'] = array('type' => $wgAuth->allowPropChange('realname') ? 'text' : 'info', 'default' => $user->getRealName(), 'section' => 'personal/info', 'label-message' => 'yourrealname', 'help-message' => 'prefs-help-realname');
     $defaultPreferences['gender'] = array('type' => 'select', 'section' => 'personal/info', 'options' => array($context->msg('gender-male')->text() => 'male', $context->msg('gender-female')->text() => 'female', $context->msg('gender-unknown')->text() => 'unknown'), 'label-message' => 'yourgender', 'help-message' => 'prefs-help-gender');
     if ($wgAuth->allowPasswordChange()) {
         $link = Linker::link(SpecialPage::getTitleFor('ChangePassword'), $context->msg('prefs-resetpass')->escaped(), array(), array('returnto' => SpecialPage::getTitleFor('Preferences')));
         $defaultPreferences['password'] = array('type' => 'info', 'raw' => true, 'default' => $link, 'label-message' => 'yourpassword', 'section' => 'personal/info');
     }
     if ($wgCookieExpiration > 0) {
         $defaultPreferences['rememberpassword'] = array('type' => 'toggle', 'label' => $context->msg('tog-rememberpassword')->numParams(ceil($wgCookieExpiration / (3600 * 24)))->text(), 'section' => 'personal/info');
     }
     // Language
     /** WIKIA CHANGE BEGIN **/
     $languages = wfGetFixedLanguageNames();
     /** WIKIA CHANGE END **/
     if (!array_key_exists($wgLanguageCode, $languages)) {
         $languages[$wgLanguageCode] = $wgLanguageCode;
     }
     ksort($languages);
     $options = array();
     foreach ($languages as $code => $name) {
         $display = wfBCP47($code) . ' - ' . $name;
         $options[$display] = $code;
     }
     $defaultPreferences['language'] = array('type' => 'select', 'section' => 'personal/i18n', 'options' => $options, 'label-message' => 'yourlanguage');
     /* see if there are multiple language variants to choose from*/
     $variantArray = array();
     if (!$wgDisableLangConversion) {
         $variants = $wgContLang->getVariants();
         foreach ($variants as $v) {
             $v = str_replace('_', '-', strtolower($v));
             $variantArray[$v] = $wgContLang->getVariantname($v, false);
         }
         $options = array();
         foreach ($variantArray as $code => $name) {
             $display = wfBCP47($code) . ' - ' . $name;
             $options[$display] = $code;
         }
         if (count($variantArray) > 1) {
             $defaultPreferences['variant'] = array('label-message' => 'yourvariant', 'type' => 'select', 'options' => $options, 'section' => 'personal/i18n', 'help-message' => 'prefs-help-variant');
         }
     }
     if (count($variantArray) > 1 && !$wgDisableLangConversion && !$wgDisableTitleConversion) {
         $defaultPreferences['noconvertlink'] = array('type' => 'toggle', 'section' => 'personal/i18n', 'label-message' => 'tog-noconvertlink');
     }
     // show a preview of the old signature first
     $oldsigWikiText = $wgParser->preSaveTransform("~~~", $context->getTitle(), $user, ParserOptions::newFromContext($context));
     $oldsigHTML = $context->getOutput()->parseInline($oldsigWikiText, true, true);
     $defaultPreferences['oldsig'] = array('type' => 'info', 'raw' => true, 'label-message' => 'tog-oldsig', 'default' => $oldsigHTML, 'section' => 'personal/signature');
     $defaultPreferences['nickname'] = array('type' => $wgAuth->allowPropChange('nickname') ? 'text' : 'info', 'maxlength' => $wgMaxSigChars, 'label-message' => 'yournick', 'validation-callback' => array('Preferences', 'validateSignature'), 'section' => 'personal/signature', 'filter-callback' => array('Preferences', 'cleanSignature'));
     $defaultPreferences['fancysig'] = array('type' => 'toggle', 'label-message' => 'tog-fancysig', 'help-message' => 'prefs-help-signature', 'section' => 'personal/signature');
     ## Email stuff
     if ($wgEnableEmail) {
         $helpMessages[] = $wgEmailConfirmToEdit ? 'prefs-help-email-required' : 'prefs-help-email';
         if ($wgEnableUserEmail) {
             // additional messages when users can send email to each other
             $helpMessages[] = 'prefs-help-email-others';
         }
         $link = Linker::link(SpecialPage::getTitleFor('ChangeEmail'), $context->msg($user->getEmail() ? 'prefs-changeemail' : 'prefs-setemail')->escaped(), array(), array('returnto' => SpecialPage::getTitleFor('Preferences')));
         $emailAddress = $user->getEmail() ? htmlspecialchars($user->getEmail()) : '';
         if ($wgAuth->allowPropChange('emailaddress')) {
             $emailAddress .= $emailAddress == '' ? $link : " ({$link})";
         }
         $defaultPreferences['emailaddress'] = array('type' => 'info', 'raw' => true, 'default' => $emailAddress, 'label-message' => 'youremail', 'section' => 'personal/email', 'help-messages' => $helpMessages);
         $disableEmailPrefs = false;
         if ($wgEmailAuthentication) {
             /* Wikia change - begin */
             $emailauthenticated = '';
             wfRunHooks('PreferencesGetEmailAuthentication', array(&$user, $context, &$disableEmailPrefs, &$emailauthenticated));
             if (empty($emailauthenticated)) {
                 /* Wikia change - end */
                 if ($user->getEmail()) {
                     if ($user->getEmailAuthenticationTimestamp()) {
                         // date and time are separate parameters to facilitate localisation.
                         // $time is kept for backward compat reasons.
                         // 'emailauthenticated' is also used in SpecialConfirmemail.php
                         $displayUser = $context->getUser();
                         $emailTimestamp = $user->getEmailAuthenticationTimestamp();
                         $time = $lang->userTimeAndDate($emailTimestamp, $displayUser);
                         $d = $lang->userDate($emailTimestamp, $displayUser);
                         $t = $lang->userTime($emailTimestamp, $displayUser);
                         $emailauthenticated = $context->msg('emailauthenticated', $time, $d, $t)->parse() . '<br />';
                         $disableEmailPrefs = false;
                     } else {
                         $disableEmailPrefs = true;
                         $emailauthenticated = $context->msg('emailnotauthenticated')->parse() . '<br />' . Linker::linkKnown(SpecialPage::getTitleFor('Confirmemail'), $context->msg('emailconfirmlink')->escaped()) . '<br />';
                     }
                 } else {
                     $disableEmailPrefs = true;
                     $emailauthenticated = $context->msg('noemailprefs')->escaped();
                 }
             }
             $defaultPreferences['emailauthentication'] = array('type' => 'info', 'raw' => true, 'section' => 'personal/email', 'label-message' => 'prefs-emailconfirm-label', 'default' => $emailauthenticated);
         }
         if ($wgEnableUserEmail && $user->isAllowed('sendemail')) {
             $defaultPreferences['disablemail'] = array('type' => 'toggle', 'invert' => true, 'section' => 'personal/email', 'label-message' => 'allowemail', 'disabled' => $disableEmailPrefs);
             $defaultPreferences['ccmeonemails'] = array('type' => 'toggle', 'section' => 'personal/email', 'label-message' => 'tog-ccmeonemails', 'disabled' => $disableEmailPrefs);
         }
         if ($wgEnotifWatchlist) {
             $defaultPreferences['enotifwatchlistpages'] = array('type' => 'toggle', 'section' => 'personal/email', 'label-message' => 'tog-enotifwatchlistpages', 'disabled' => $disableEmailPrefs);
         }
         if ($wgEnotifUserTalk) {
             $defaultPreferences['enotifusertalkpages'] = array('type' => 'toggle', 'section' => 'personal/email', 'label-message' => 'tog-enotifusertalkpages', 'disabled' => $disableEmailPrefs);
         }
         if ($wgEnotifUserTalk || $wgEnotifWatchlist) {
             $defaultPreferences['enotifminoredits'] = array('type' => 'toggle', 'section' => 'personal/email', 'label-message' => 'tog-enotifminoredits', 'disabled' => $disableEmailPrefs);
             if ($wgEnotifRevealEditorAddress) {
                 $defaultPreferences['enotifrevealaddr'] = array('type' => 'toggle', 'section' => 'personal/email', 'label-message' => 'tog-enotifrevealaddr', 'disabled' => $disableEmailPrefs);
             }
         }
         /* Wikia change begin - @author: Inez */
         $defaultPreferences['marketingallowed'] = array('type' => 'toggle', 'section' => 'personal/email', 'label-message' => 'tog-marketingallowed');
         /* Wikia change end */
     }
 }
 function showCredentials()
 {
     $reqUser = $this->getUser();
     $out = $this->getOutput();
     $titleObj = SpecialPage::getTitleFor('UserCredentials');
     $row = $this->getAccountData();
     if (!$row) {
         $out->addHTML($this->msg('usercredentials-badid')->escaped());
         return;
     }
     $out->addWikiMsg('usercredentials-text');
     $user = User::newFromName($this->target);
     $list = array();
     foreach ($user->getGroups() as $group) {
         $list[] = User::makeGroupLinkHTML($group, User::getGroupMember($group, $user->getName()));
     }
     $grouplist = '';
     if (count($list) > 0) {
         $grouplist = '<tr><td>' . $this->msg('usercredentials-member')->escaped() . '</td><td>' . implode(', ', $list) . '</td></tr>';
     }
     $form = "<fieldset>";
     $form .= '<legend>' . $this->msg('usercredentials-leg-user')->escaped() . '</legend>';
     $form .= '<table style="padding:4px;">';
     $form .= "<tr><td>" . $this->msg('username')->escaped() . "</td>";
     $form .= "<td>" . Linker::makeLinkObj($user->getUserPage(), htmlspecialchars($user->getUserPage()->getText())) . "</td></tr>\n";
     $econf = $row->acd_email_authenticated ? ' <strong>' . $this->msg('confirmaccount-econf')->escaped() . '</strong>' : '';
     $form .= "<tr><td>" . $this->msg('usercredentials-email')->escaped() . "</td>";
     $form .= "<td>" . htmlspecialchars($row->acd_email) . $econf . "</td></tr>\n";
     $form .= $grouplist;
     $form .= '</table></fieldset>';
     $areaSet = UserAccountRequest::expandAreas($row->acd_areas);
     $userAreas = ConfirmAccount::getUserAreaConfig();
     if (count($userAreas) > 0) {
         $form .= '<fieldset>';
         $form .= '<legend>' . $this->msg('confirmaccount-leg-areas')->escaped() . '</legend>';
         $form .= "<div style='height:150px; overflow:scroll; background-color:#f9f9f9;'>";
         $form .= "<table style='border-spacing:5px; padding:0px; background-color:#f9f9f9;'><tr style='vertical-align: top;'>";
         $count = 0;
         $att = array('disabled' => 'disabled');
         foreach ($userAreas as $name => $conf) {
             $count++;
             if ($count > 5) {
                 $form .= "</tr><tr style='vertical-align: top;'>";
                 $count = 1;
             }
             $formName = "wpArea-" . htmlspecialchars(str_replace(' ', '_', $name));
             if ($conf['project'] != '') {
                 $pg = Linker::linkKnown(Title::newFromText($name), $this->msg('requestaccount-info')->escaped());
             } else {
                 $pg = '';
             }
             $form .= "<td>" . Xml::checkLabel($name, $formName, $formName, in_array($formName, $areaSet), $att) . " {$pg}</td>\n";
         }
         $form .= "</tr></table></div>";
         $form .= '</fieldset>';
     }
     $form .= '<fieldset>';
     $form .= '<legend>' . $this->msg('usercredentials-leg-person')->escaped() . '</legend>';
     $form .= '<table style="padding:4px;">';
     $form .= "<tr><td>" . $this->msg('usercredentials-real')->escaped() . "</td>";
     $form .= "<td>" . htmlspecialchars($row->acd_real_name) . "</td></tr>\n";
     $form .= '</table>';
     $form .= "<p>" . $this->msg('usercredentials-bio')->escaped() . "</p>";
     $form .= "<p><textarea tabindex='1' readonly='readonly' name='wpBio' id='wpNewBio' rows='10' cols='80' style='width:100%'>" . htmlspecialchars($row->acd_bio) . "</textarea></p>\n";
     $form .= '</fieldset>';
     $form .= '<fieldset>';
     $form .= '<legend>' . $this->msg('usercredentials-leg-other')->escaped() . '</legend>';
     if ($this->hasItem('CV') || $this->hasItem('Notes') || $this->hasItem('Links')) {
         $form .= '<p>' . $this->msg('usercredentials-attach')->escaped() . ' ';
         if ($row->acd_filename) {
             $form .= Linker::makeKnownLinkObj($titleObj, htmlspecialchars($row->acd_filename), 'file=' . $row->acd_storage_key);
         } else {
             $form .= $this->msg('confirmaccount-none-p')->escaped();
         }
         $form .= "</p><p>" . $this->msg('usercredentials-notes')->escaped() . "</p>\n";
         $form .= "<p><textarea tabindex='1' readonly='readonly' name='wpNotes' id='wpNotes' rows='3' cols='80' style='width:100%'>" . htmlspecialchars($row->acd_notes) . "</textarea></p>\n";
         $form .= "<p>" . $this->msg('usercredentials-urls')->escaped() . "</p>\n";
         $form .= ConfirmAccountsPage::parseLinks($row->acd_urls);
     }
     $form .= '</fieldset>';
     if ($reqUser->isAllowed('requestips')) {
         $form .= '<fieldset>';
         $form .= '<legend>' . $this->msg('usercredentials-leg-ip')->escaped() . '</legend>';
         $form .= "<p>" . $this->msg('usercredentials-ip')->escaped() . " " . htmlspecialchars($row->acd_ip) . "</p>\n";
         if ($row->acd_xff) {
             $form .= "<p>" . $this->msg('usercredentials-xff')->escaped() . " " . htmlspecialchars($row->acd_xff) . "</p>\n";
         }
         if ($row->acd_agent) {
             $form .= "<p>" . $this->msg('usercredentials-agent')->escaped() . " " . htmlspecialchars($row->acd_agent) . "</p>\n";
         }
         $form .= '</fieldset>';
     }
     $out->addHTML($form);
 }
Example #8
0
 function formatResult($skin, $result)
 {
     $userPage = Title::makeTitle($result->namespace, $result->title);
     $name = $skin->makeLinkObj($userPage, htmlspecialchars($userPage->getText()));
     $groups = null;
     if (!isset($result->numgroups) || $result->numgroups > 0) {
         $dbr =& wfGetDB(DB_SLAVE);
         $result = $dbr->select('user_groups', array('ug_group'), array('ug_user' => $result->user_id), 'ListUsersPage::formatResult');
         $groups = array();
         while ($row = $dbr->fetchObject($result)) {
             $groups[$row->ug_group] = User::getGroupMember($row->ug_group);
         }
         $dbr->freeResult($result);
         if (count($groups) > 0) {
             foreach ($groups as $group => $desc) {
                 $list[] = User::makeGroupLinkHTML($group, $desc);
             }
             $groups = implode(', ', $list);
         } else {
             $groups = '';
         }
     }
     return wfSpecialList($name, $groups);
 }
Example #9
0
 /**
  * Format a link to a group member description page
  *
  * @param string $group
  * @return string
  */
 private static function buildGroupMemberLink($group)
 {
     return User::makeGroupLinkHTML($group, User::getGroupMember($group));
 }
	/**
	 * Get the link to the specified user's userpage and group membership
	 * for administrators and ShoutWiki staff.
	 * For anonymous users, no link is generated, only the system message
	 * is returned.
	 *
	 * @param $username String: username
	 * @return HTML
	 */
	public static function getUserLink( $username ) {
		global $wgContLang, $wgUser;

		if ( $username ) {
			$retVal = Linker::link(
				Title::newFromText( $wgContLang->getNsText( NS_USER ) . ':' . $username ),
				htmlspecialchars( $username ) // @todo FIXME/CHECKME: double-escaping or not?
			);

			$groups = User::newFromName( $username )->getEffectiveGroups();
			// @todo FIXME: this code is horrible, it basically does
			// special-casing for staff and sysop groups
			// instead it should handle only staff as a special case
			// and treat bureaucrat, sysop etc. normally
			//
			// Staff tag for staff members
			// This is a horrible, ShoutWiki-specific hack
			$isStaff = in_array( 'staff', $groups );
			if ( $isStaff && function_exists( 'wfStaffSig' ) ) {
				global $wgOut;
				$staffSig = $wgOut->parse( '<staff />' );
				// copied from extensions/Comments/CommentClass.php
				// really bad hack because we want to parse=firstline, but
				// don't want wrapping <p> tags
				if ( substr( $staffSig, 0 , 3 ) == '<p>' ) {
					$staffSig = substr( $staffSig, 3 );
				}

				if ( substr( $staffSig, strlen( $staffSig ) - 4, 4 ) == '</p>' ) {
					$staffSig = substr( $staffSig, 0, strlen( $staffSig ) - 4 );
				}
				// end copied bad hack
				$retVal = $retVal . $staffSig;
			} elseif ( in_array( 'sysop', $groups ) && !$isStaff ) {
				// we <3 i18n
				$retVal = $retVal . wfMsg( 'word-separator' ) .
					wfMsg(
						'parentheses',
						User::makeGroupLinkHTML( 'sysop', User::getGroupMember( 'sysop', $username ) )
					);
			} elseif ( in_array( 'forumadmin', $groups ) && !$isStaff ) {
				// this madness has to stop...really...
				$retVal = $retVal . wfMsg( 'word-separator' ) .
					wfMsg(
						'parentheses',
						User::makeGroupLinkHTML( 'forumadmin', User::getGroupMember( 'forumadmin', $username ) )
					);
			}
			return $retVal;
		} else {
			return wfMsg( 'wikiforum-anonymous' );
		}
	}