Follow-up r84814: revert redundant summary message addition.
[lhc/web/wiklou.git] / includes / Preferences.php
index 9eb7d89..37563dd 100644 (file)
@@ -325,19 +325,27 @@ class Preferences {
                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-message' => $wgEmailConfirmToEdit
-                                       ? 'prefs-help-email-required'
-                                       : 'prefs-help-email',
+                               'help-messages' => $helpMessages,
                                'validation-callback' => array( 'Preferences', 'validateEmail' ),
                        );
 
-                       global $wgEnableUserEmail, $wgEmailAuthentication;
+                       global $wgEmailAuthentication;
 
                        $disableEmailPrefs = false;
 
@@ -1280,7 +1288,8 @@ class Preferences {
                                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' ) {
@@ -1306,6 +1315,16 @@ class Preferences {
                        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();