From: Antoine Musso Date: Fri, 14 Jan 2011 16:53:36 +0000 (+0000) Subject: bug 10158 : do not mention allowing others to contact you if $wgEnableUserEmail=false X-Git-Tag: 1.31.0-rc.0~32542 X-Git-Url: http://git.cyclocoop.org/clavettes/images/siteon3.jpg?a=commitdiff_plain;h=83848f26d9155e6a9ce712d886393bd2702641c1;p=lhc%2Fweb%2Fwiklou.git bug 10158 : do not mention allowing others to contact you if $wgEnableUserEmail=false 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 --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index b3324968cd..df875578f7 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 diff --git a/includes/HTMLForm.php b/includes/HTMLForm.php index d46275481e..2e7e3999bd 100644 --- a/includes/HTMLForm.php +++ b/includes/HTMLForm.php @@ -33,6 +33,10 @@ * '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']; } diff --git a/includes/Preferences.php b/includes/Preferences.php index 9eb7d89269..28ad9d371f 100644 --- a/includes/Preferences.php +++ b/includes/Preferences.php @@ -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; diff --git a/includes/specials/SpecialUserlogin.php b/includes/specials/SpecialUserlogin.php index 26b9c940ff..69f55aa592 100644 --- a/includes/specials/SpecialUserlogin.php +++ b/includes/specials/SpecialUserlogin.php @@ -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() ); diff --git a/includes/templates/Userlogin.php b/includes/templates/Userlogin.php index 6ad2afe94e..34a5db7ab2 100644 --- a/includes/templates/Userlogin.php +++ b/includes/templates/Userlogin.php @@ -255,11 +255,15 @@ class UsercreateTemplate extends QuickTemplate { 'size' => '20' ) ); ?>
- data['emailrequired'] ) { - $this->msgWiki('prefs-help-email-required'); - } else { - $this->msgWiki('prefs-help-email'); - } ?> + data['emailrequired'] ) { + $this->msgWiki('prefs-help-email-required'); + } else { + $this->msgWiki('prefs-help-email'); + } + if( $this->data['emailothers'] ) { + $this->msgWiki('prefs-help-email-others'); + } ?>
diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index a60a26c63b..2dd951f3ed 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -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', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index e7d891a9d8..6260ebba15 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -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',