bug 10158 : do not mention allowing others to contact you if $wgEnableUserEmail=false
authorAntoine Musso <hashar@users.mediawiki.org>
Fri, 14 Jan 2011 16:53:36 +0000 (16:53 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Fri, 14 Jan 2011 16:53:36 +0000 (16:53 +0000)
This required to tweak HTMLForm to support an array of message keys
for help message. I could reuse help-message but since this helper
also supports array, I created an additional helper for array of
messages.

To test use variations of $wgEnableUserEmail and $wgEmailConfirmToEdit.

Path adapted from jopiswezggzmw at mailinator dot com

RELEASE-NOTES
includes/HTMLForm.php
includes/Preferences.php
includes/specials/SpecialUserlogin.php
includes/templates/Userlogin.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc

index b332496..df87557 100644 (file)
@@ -77,6 +77,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   selected when the action is "purge".
 * (bug 14267) Support a MediaWiki:Mainpage-nstab override for the subject namespace
   tab on the mainpage of a wiki.
+* (bug 10158) Do not mention allowing others to contact you when the feature
+  is disabled ($wgEnableUserEmail=false)
 
 === API changes in 1.18 ===
 * (bug 26339) Throw warning when truncating an overlarge API result
index d462754..2e7e399 100644 (file)
  *     'help-message'        -- message key for a message to use as a help text.
  *                              can be an array of msg key and then parameters to
  *                              the message.
+ *                           Overwrites 'help-messages'.
+ *  'help-messages'       -- array of message key. As above, each item can
+ *                           be an array of msg key and then parameters.
+ *                           Overwrites 'help-message'.
  *     'required'            -- passed through to the object, indicating that it
  *                              is a required field.
  *     'size'                -- the length of text fields
@@ -898,6 +902,17 @@ abstract class HTMLFormField {
                                # Never mind
                                $helptext = null;
                        }
+               } elseif ( isset( $this->mParams['help-messages'] ) ) {
+                       # help-message can be passed a message key (string) or an array containing
+                       # a message key and additional parameters. This makes it impossible to pass
+                       # an array of message key
+                       foreach( $this->mParams['help-messages'] as $msg ) {
+                               $candidate = wfMsgExt( $msg, 'parseinline' );
+                               if( wfEmptyMsg( $msg ) ) {
+                                       $candidate = null;
+                               }
+                               $helptext .= $candidate; // append message
+                       }       
                } elseif ( isset( $this->mParams['help'] ) ) {
                        $helptext = $this->mParams['help'];
                }
index 9eb7d89..28ad9d3 100644 (file)
@@ -325,19 +325,25 @@ class Preferences {
                global $wgEnableEmail;
                if ( $wgEnableEmail ) {
                        global $wgEmailConfirmToEdit;
+                       global $wgEnableUserEmail;
+
+                       $helpMessages[] = $wgEmailConfirmToEdit
+                                       ? 'prefs-help-email-required'
+                                       : 'prefs-help-email' ;
+                       $helpMessages[] = $wgEnableUserEmail
+                                       ? 'prefs-help-email-others'
+                                       : 'tototo' ;
 
                        $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;
 
index 26b9c94..69f55aa 100644 (file)
@@ -925,7 +925,8 @@ class LoginForm extends SpecialPage {
         * @private
         */
        function mainLoginForm( $msg, $msgtype = 'error' ) {
-               global $wgUser, $wgOut, $wgHiddenPrefs, $wgEnableEmail;
+               global $wgUser, $wgOut, $wgHiddenPrefs;
+               global $wgEnableEmail, $wgEnableUserEmail;
                global $wgRequest, $wgLoginLanguageSelector;
                global $wgAuth, $wgEmailConfirmToEdit, $wgCookieExpiration;
                global $wgSecureLogin;
@@ -1014,6 +1015,7 @@ class LoginForm extends SpecialPage {
                $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( 'canremember', ( $wgCookieExpiration > 0 ) );
                $template->set( 'usereason', $wgUser->isLoggedIn() );
index 6ad2afe..34a5db7 100644 (file)
@@ -255,11 +255,15 @@ class UsercreateTemplate extends QuickTemplate {
                        'size' => '20'
                ) ); ?>
                                        <div class="prefsectiontip">
-                                               <?php if( $this->data['emailrequired'] ) {
-                                                                       $this->msgWiki('prefs-help-email-required');
-                                                     } else {
-                                                                       $this->msgWiki('prefs-help-email');
-                                                     } ?>
+                                               <?php  // duplicated in Preferences.php profilePreferences()
+                                                       if( $this->data['emailrequired'] ) {
+                                                               $this->msgWiki('prefs-help-email-required');
+                                                       } else {
+                                                               $this->msgWiki('prefs-help-email');
+                                                       }
+                                                       if( $this->data['emailothers'] ) {
+                                                               $this->msgWiki('prefs-help-email-others');
+                                                       } ?>
                                        </div>
                                </td>
                                <td></td>
index a60a26c..2dd951f 100644 (file)
@@ -1839,8 +1839,8 @@ This information will be public.',
 'email'                         => 'E-mail',
 'prefs-help-realname'           => 'Real name is optional.
 If you choose to provide it, this will be used for giving you attribution for your work.',
-'prefs-help-email'              => 'E-mail address is optional, but is needed for password resets, should you forget your password.
-You can also choose to let others contact you through your user or talk page without needing to reveal your identity.',
+'prefs-help-email'              => 'E-mail address is optional, but is needed for password resets, should you forget your password.',
+'prefs-help-email-others'       => 'You can also choose to let others contact you through your user or talk page without needing to reveal your identity.',
 'prefs-help-email-required'     => 'E-mail address is required.',
 'prefs-info'                    => 'Basic information',
 'prefs-i18n'                    => 'Internationalisation',
index e7d891a..6260ebb 100644 (file)
@@ -1014,8 +1014,12 @@ $wgMessageStructure = array(
                'prefs-help-gender',
                'email',
                'prefs-help-realname',
+
+               # 3 messages depending upon wgEmailConfirmToEdit and $wgEnableUserEmail
                'prefs-help-email',
+               'prefs-help-email-others',
                'prefs-help-email-required',
+       
                'prefs-info',
                'prefs-i18n',
                'prefs-signature',