'searchlimit' => array( 'Preferences', 'filterIntval' ),
);
+ /**
+ * @throws MWException
+ * @param $user User
+ * @return array|null
+ */
static function getPreferences( $user ) {
- if ( self::$defaultPreferences )
+ if ( self::$defaultPreferences ) {
return self::$defaultPreferences;
+ }
$defaultPreferences = array();
self::profilePreferences( $user, $defaultPreferences );
self::skinPreferences( $user, $defaultPreferences );
self::filesPreferences( $user, $defaultPreferences );
- self::mathPreferences( $user, $defaultPreferences );
self::datetimePreferences( $user, $defaultPreferences );
self::renderingPreferences( $user, $defaultPreferences );
self::editingPreferences( $user, $defaultPreferences );
return $defaultPreferences;
}
- // Pull option from a user account. Handles stuff like array-type preferences.
+ /**
+ * Pull option from a user account. Handles stuff like array-type preferences.
+ *
+ * @param $name
+ * @param $info
+ * @param $user User
+ * @return array|String
+ */
static function getOptionFromUser( $name, $info, $user ) {
$val = $user->getOption( $name );
return $val;
}
+ /**
+ * @param $user User
+ * @param $defaultPreferences
+ * @return void
+ */
static function profilePreferences( $user, &$defaultPreferences ) {
global $wgLang, $wgUser;
## User info #####################################
);
if ( $wgAuth->allowPasswordChange() ) {
- $link = $wgUser->getSkin()->link( SpecialPage::getTitleFor( 'Resetpass' ),
+ $link = $wgUser->getSkin()->link( SpecialPage::getTitleFor( 'ChangePassword' ),
wfMsgHtml( 'prefs-resetpass' ), array(),
array( 'returnto' => SpecialPage::getTitleFor( 'Preferences' ) ) );
global $wgMaxSigChars, $wgOut, $wgParser;
// show a preview of the old signature first
- $oldsigWikiText = $wgParser->preSaveTransform( "~~~", new Title , $user, new ParserOptions );
+ $oldsigWikiText = $wgParser->preSaveTransform( "~~~", new Title, $user, new ParserOptions );
$oldsigHTML = $wgOut->parseInline( $oldsigWikiText );
$defaultPreferences['oldsig'] = array(
'type' => 'info',
$helpMessages[] = $wgEmailConfirmToEdit
? 'prefs-help-email-required'
: 'prefs-help-email' ;
- $helpMessages[] = $wgEnableUserEmail
- ? 'prefs-help-email-others'
- : 'tototo' ;
+
+ 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',
}
}
+ /**
+ * @param $user User
+ * @param $defaultPreferences
+ * @return void
+ */
static function skinPreferences( $user, &$defaultPreferences ) {
## Skin #####################################
global $wgLang, $wgAllowUserCss, $wgAllowUserJs;
}
}
- static function mathPreferences( $user, &$defaultPreferences ) {
- ## Math #####################################
- global $wgUseTeX, $wgLang;
- if ( $wgUseTeX ) {
- $defaultPreferences['math'] = array(
- 'type' => 'radio',
- 'options' => array_flip( array_map( 'wfMsgHtml', $wgLang->getMathNames() ) ),
- 'label' => ' ',
- 'section' => 'rendering/math',
- );
- }
- }
-
static function filesPreferences( $user, &$defaultPreferences ) {
## Files #####################################
$defaultPreferences['imagesize'] = array(
);
}
+ /**
+ * @param $user User
+ * @param $defaultPreferences
+ * @return void
+ */
static function datetimePreferences( $user, &$defaultPreferences ) {
global $wgLang;
}
// Info
+ $now = wfTimestampNow();
$nowlocal = Xml::element( 'span', array( 'id' => 'wpLocalTime' ),
- $wgLang->time( $now = wfTimestampNow(), true ) );
+ $wgLang->time( $now, true ) );
$nowserver = $wgLang->time( $now, false ) .
- Html::hidden( 'wpServerTime', substr( $now, 8, 2 ) * 60 + substr( $now, 10, 2 ) );
+ Html::hidden( 'wpServerTime', (int)substr( $now, 8, 2 ) * 60 + (int)substr( $now, 10, 2 ) );
$defaultPreferences['nowserver'] = array(
'type' => 'info',
'label-message' => 'tog-forceeditsummary',
);
-
+
$defaultPreferences['uselivepreview'] = array(
'type' => 'toggle',
'section' => 'editing/advancedediting',
}
}
+ /**
+ * @param $user User
+ * @param $defaultPreferences
+ * @return void
+ */
static function watchlistPreferences( $user, &$defaultPreferences ) {
global $wgUseRCPatrol, $wgEnableAPI;
'section' => 'searchoptions/displaysearchoptions',
'min' => 0,
);
- $defaultPreferences['contextlines'] = array(
- 'type' => 'int',
- 'label-message' => 'contextlines',
- 'section' => 'searchoptions/displaysearchoptions',
- 'min' => 0,
- );
- $defaultPreferences['contextchars'] = array(
- 'type' => 'int',
- 'label-message' => 'contextchars',
- 'section' => 'searchoptions/displaysearchoptions',
- 'min' => 0,
- );
global $wgEnableMWSuggest;
if ( $wgEnableMWSuggest ) {
'section' => 'searchoptions/displaysearchoptions',
);
}
-
+
global $wgVectorUseSimpleSearch;
if ( $wgVectorUseSimpleSearch ) {
$defaultPreferences['vector-simplesearch'] = array(
'section' => 'searchoptions/advancedsearchoptions',
);
- // Searchable namespaces back-compat with old format
- $searchableNamespaces = SearchEngine::searchableNamespaces();
-
$nsOptions = array();
foreach ( $wgContLang->getNamespaces() as $ns => $name ) {
}
/**
- * @param $user The User object
+ * @param $user User The User object
* @return Array: text/links to display as key; $skinkey as value
*/
static function generateSkinOptions( $user ) {
}
static function validateEmail( $email, $alldata ) {
- if ( $email && !User::isValidEmailAddr( $email ) ) {
+ if ( $email && !Sanitizer::validateEmail( $email ) ) {
return wfMsgExt( 'invalidemailaddress', 'parseinline' );
}
}
return $opt;
}
-
+
static function filterIntval( $value, $alldata ){
return intval( $value );
}
if ( $wgEmailAuthentication ) {
# Mail a temporary password to the dirty address.
# User can come back through the confirmation URL to re-enable email.
- $result = $wgUser->sendConfirmationMail( $oldaddr != '' );
+ $type = $oldaddr != '' ? 'changed' : 'set';
+ $result = $wgUser->sendConfirmationMail( $type );
if ( !$result->isGood() ) {
return htmlspecialchars( $result->getWikiText( 'mailerror' ) );
} elseif ( $entryPoint == 'ui' ) {
unset( $formData[$b] );
}
+ # If users have saved a value for a preference which has subsequently been disabled
+ # via $wgHiddenPrefs, we don't want to destroy that setting in case the preference
+ # is subsequently re-enabled
+ # TODO: maintenance script to actually delete these
+ foreach( $wgHiddenPrefs as $pref ){
+ # If the user has not set a non-default value here, the default will be returned
+ # and subsequently discarded
+ $formData[$pref] = $wgUser->getOption( $pref, null, true );
+ }
+
// Keeps old preferences from interfering due to back-compat
// code, etc.
$wgUser->resetOptions();
return Status::newGood();
}
+ /**
+ * @param $user User
+ * @return array
+ */
public static function loadOldSearchNs( $user ) {
$searchableNamespaces = SearchEngine::searchableNamespaces();
// Back compat with old format