wfRunHooks( 'GetPreferences', array( $user, &$defaultPreferences ) );
+ self::loadPreferenceValues( $user, $context, $defaultPreferences );
+ self::$defaultPreferences = $defaultPreferences;
+ return $defaultPreferences;
+ }
+
+ /**
+ * Loads existing values for a given array of preferences
+ * @throws MWException
+ * @param User $user
+ * @param IContextSource $context
+ * @param array $defaultPreferences Array to load values for
+ * @return array|null
+ */
+ static function loadPreferenceValues( $user, $context, &$defaultPreferences ) {
## Remove preferences that wikis don't want to use
global $wgHiddenPrefs;
foreach ( $wgHiddenPrefs as $pref ) {
}
}
- self::$defaultPreferences = $defaultPreferences;
-
return $defaultPreferences;
}
* @return void
*/
static function profilePreferences( $user, IContextSource $context, &$defaultPreferences ) {
- global $wgAuth, $wgContLang, $wgParser, $wgCookieExpiration, $wgLanguageCode,
+ global $wgAuth, $wgContLang, $wgParser, $wgLanguageCode,
$wgDisableLangConversion, $wgMaxSigChars,
$wgEnableEmail, $wgEmailConfirmToEdit, $wgEnableUserEmail, $wgEmailAuthentication,
$wgEnotifWatchlist, $wgEnotifUserTalk, $wgEnotifRevealEditorAddress,
## Skin #####################################
global $wgAllowUserCss, $wgAllowUserJs;
- $defaultPreferences['skin'] = array(
- 'type' => 'radio',
- 'options' => self::generateSkinOptions( $user, $context ),
- 'label' => ' ',
- 'section' => 'rendering/skin',
- );
+ // Skin selector, if there is at least one valid skin
+ $skinOptions = self::generateSkinOptions( $user, $context );
+ if ( $skinOptions ) {
+ $defaultPreferences['skin'] = array(
+ 'type' => 'radio',
+ 'options' => $skinOptions,
+ 'label' => ' ',
+ 'section' => 'rendering/skin',
+ );
+ }
# Create links to user CSS/JS pages for all skins
# This code is basically copied from generateSkinOptions(). It'd
'type' => 'select',
'section' => 'rendering/advancedrendering',
'options' => $stubThresholdOptions,
- 'size' => 20,
'label-raw' => $context->msg( 'stub-threshold' )->text(), // Raw HTML message. Yay?
);
$watchTypes['read'] = 'watchcreations';
}
+ if ( $user->isAllowed( 'rollback' ) ) {
+ $watchTypes['rollback'] = 'watchrollback';
+ }
+
foreach ( $watchTypes as $action => $pref ) {
if ( $user->isAllowed( $action ) ) {
// Messages:
// tog-watchdefault, tog-watchmoves, tog-watchdeletion, tog-watchcreations
+ // tog-watchrollback
$defaultPreferences[$pref] = array(
'type' => 'toggle',
'section' => 'watchlist/advancedwatchlist',
*/
static function searchPreferences( $user, IContextSource $context, &$defaultPreferences ) {
foreach ( MWNamespace::getValidNamespaces() as $n ) {
- $defaultPreferences[ 'searchNs' . $n ] = array(
+ $defaultPreferences['searchNs' . $n] = array(
'type' => 'api',
);
}
}
asort( $validSkinNames );
+ $foundDefault = false;
foreach ( $validSkinNames as $skinkey => $sn ) {
$linkTools = array();
# Mark the default skin
if ( $skinkey == $wgDefaultSkin ) {
$linkTools[] = $context->msg( 'default' )->escaped();
+ $foundDefault = true;
}
# Create preview link
$ret[$display] = $skinkey;
}
+ if ( !$foundDefault ) {
+ // If the default skin is not available, things are going to break horribly because the
+ // default value for skin selector will not be a valid value. Let's just not show it then.
+ return array();
+ }
+
return $ret;
}
return array( $result, 'mailerror' );
}
}
-
- /**
- * @deprecated since 1.19
- * @param User $user
- * @return array
- */
- public static function loadOldSearchNs( $user ) {
- wfDeprecated( __METHOD__, '1.19' );
-
- $searchableNamespaces = SearchEngine::searchableNamespaces();
- // Back compat with old format
- $arr = array();
-
- foreach ( $searchableNamespaces as $ns => $name ) {
- if ( $user->getOption( 'searchNs' . $ns ) ) {
- $arr[] = $ns;
- }
- }
-
- return $arr;
- }
}
/** Some tweaks to allow js prefs to work */