r80281 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80280‎ | r80281 | r80282 >
Date:16:53, 14 January 2011
Author:hashar
Status:resolved (Comments)
Tags:
Comment:
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
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/HTMLForm.php (modified) (history)
  • /trunk/phase3/includes/Preferences.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUserlogin.php (modified) (history)
  • /trunk/phase3/includes/templates/Userlogin.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/messages.inc
@@ -1014,8 +1014,12 @@
10151015 'prefs-help-gender',
10161016 'email',
10171017 'prefs-help-realname',
 1018+
 1019+ # 3 messages depending upon wgEmailConfirmToEdit and $wgEnableUserEmail
10181020 'prefs-help-email',
 1021+ 'prefs-help-email-others',
10191022 'prefs-help-email-required',
 1023+
10201024 'prefs-info',
10211025 'prefs-i18n',
10221026 'prefs-signature',
Index: trunk/phase3/includes/HTMLForm.php
@@ -33,6 +33,10 @@
3434 * 'help-message' -- message key for a message to use as a help text.
3535 * can be an array of msg key and then parameters to
3636 * the message.
 37+ * Overwrites 'help-messages'.
 38+ * 'help-messages' -- array of message key. As above, each item can
 39+ * be an array of msg key and then parameters.
 40+ * Overwrites 'help-message'.
3741 * 'required' -- passed through to the object, indicating that it
3842 * is a required field.
3943 * 'size' -- the length of text fields
@@ -898,6 +902,17 @@
899903 # Never mind
900904 $helptext = null;
901905 }
 906+ } elseif ( isset( $this->mParams['help-messages'] ) ) {
 907+ # help-message can be passed a message key (string) or an array containing
 908+ # a message key and additional parameters. This makes it impossible to pass
 909+ # an array of message key
 910+ foreach( $this->mParams['help-messages'] as $msg ) {
 911+ $candidate = wfMsgExt( $msg, 'parseinline' );
 912+ if( wfEmptyMsg( $msg ) ) {
 913+ $candidate = null;
 914+ }
 915+ $helptext .= $candidate; // append message
 916+ }
902917 } elseif ( isset( $this->mParams['help'] ) ) {
903918 $helptext = $this->mParams['help'];
904919 }
Index: trunk/phase3/includes/specials/SpecialUserlogin.php
@@ -925,7 +925,8 @@
926926 * @private
927927 */
928928 function mainLoginForm( $msg, $msgtype = 'error' ) {
929 - global $wgUser, $wgOut, $wgHiddenPrefs, $wgEnableEmail;
 929+ global $wgUser, $wgOut, $wgHiddenPrefs;
 930+ global $wgEnableEmail, $wgEnableUserEmail;
930931 global $wgRequest, $wgLoginLanguageSelector;
931932 global $wgAuth, $wgEmailConfirmToEdit, $wgCookieExpiration;
932933 global $wgSecureLogin;
@@ -1014,6 +1015,7 @@
10151016 $template->set( 'userealname', !in_array( 'realname', $wgHiddenPrefs ) );
10161017 $template->set( 'useemail', $wgEnableEmail );
10171018 $template->set( 'emailrequired', $wgEmailConfirmToEdit );
 1019+ $template->set( 'emailothers', $wgEnableUserEmail );
10181020 $template->set( 'canreset', $wgAuth->allowPasswordChange() );
10191021 $template->set( 'canremember', ( $wgCookieExpiration > 0 ) );
10201022 $template->set( 'usereason', $wgUser->isLoggedIn() );
Index: trunk/phase3/includes/Preferences.php
@@ -325,19 +325,25 @@
326326 global $wgEnableEmail;
327327 if ( $wgEnableEmail ) {
328328 global $wgEmailConfirmToEdit;
 329+ global $wgEnableUserEmail;
329330
 331+ $helpMessages[] = $wgEmailConfirmToEdit
 332+ ? 'prefs-help-email-required'
 333+ : 'prefs-help-email' ;
 334+ $helpMessages[] = $wgEnableUserEmail
 335+ ? 'prefs-help-email-others'
 336+ : 'tototo' ;
 337+
330338 $defaultPreferences['emailaddress'] = array(
331339 'type' => $wgAuth->allowPropChange( 'emailaddress' ) ? 'email' : 'info',
332340 'default' => $user->getEmail(),
333341 'section' => 'personal/email',
334342 'label-message' => 'youremail',
335 - 'help-message' => $wgEmailConfirmToEdit
336 - ? 'prefs-help-email-required'
337 - : 'prefs-help-email',
 343+ 'help-messages' => $helpMessages,
338344 'validation-callback' => array( 'Preferences', 'validateEmail' ),
339345 );
340346
341 - global $wgEnableUserEmail, $wgEmailAuthentication;
 347+ global $wgEmailAuthentication;
342348
343349 $disableEmailPrefs = false;
344350
Index: trunk/phase3/includes/templates/Userlogin.php
@@ -255,11 +255,15 @@
256256 'size' => '20'
257257 ) ); ?>
258258 <div class="prefsectiontip">
259 - <?php if( $this->data['emailrequired'] ) {
260 - $this->msgWiki('prefs-help-email-required');
261 - } else {
262 - $this->msgWiki('prefs-help-email');
263 - } ?>
 259+ <?php // duplicated in Preferences.php profilePreferences()
 260+ if( $this->data['emailrequired'] ) {
 261+ $this->msgWiki('prefs-help-email-required');
 262+ } else {
 263+ $this->msgWiki('prefs-help-email');
 264+ }
 265+ if( $this->data['emailothers'] ) {
 266+ $this->msgWiki('prefs-help-email-others');
 267+ } ?>
264268 </div>
265269 </td>
266270 <td></td>
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1839,8 +1839,8 @@
18401840 'email' => 'E-mail',
18411841 'prefs-help-realname' => 'Real name is optional.
18421842 If you choose to provide it, this will be used for giving you attribution for your work.',
1843 -'prefs-help-email' => 'E-mail address is optional, but is needed for password resets, should you forget your password.
1844 -You can also choose to let others contact you through your user or talk page without needing to reveal your identity.',
 1843+'prefs-help-email' => 'E-mail address is optional, but is needed for password resets, should you forget your password.',
 1844+'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.',
18451845 'prefs-help-email-required' => 'E-mail address is required.',
18461846 'prefs-info' => 'Basic information',
18471847 'prefs-i18n' => 'Internationalisation',
Index: trunk/phase3/RELEASE-NOTES
@@ -77,6 +77,8 @@
7878 selected when the action is "purge".
7979 * (bug 14267) Support a MediaWiki:Mainpage-nstab override for the subject namespace
8080 tab on the mainpage of a wiki.
 81+* (bug 10158) Do not mention allowing others to contact you when the feature
 82+ is disabled ($wgEnableUserEmail=false)
8183
8284 === API changes in 1.18 ===
8385 * (bug 26339) Throw warning when truncating an overlarge API result

Follow-up revisions

RevisionCommit summaryAuthorDate
r80323Remove debugging issue in user preferences...hashar20:43, 14 January 2011

Comments

#Comment by Nikerabbit (talk | contribs)   19:58, 14 January 2011

Could use the new wfMessage method. Not worth fixme.

#Comment by Jack Phoenix (talk | contribs)   20:04, 14 January 2011
+			$helpMessages[] = $wgEmailConfirmToEdit
+					? 'prefs-help-email-required'
+					: 'prefs-help-email' ;
+			$helpMessages[] = $wgEnableUserEmail
+					? 'prefs-help-email-others'
+					: 'tototo' ;

Very minor spacing issue there (no need for the space before the semicolon), but 'tototo' looks just plain wrong. ;-)

#Comment by Hashar (talk | contribs)   20:45, 14 January 2011

r80323 handles the 'tototo' message.

The space after the message key makes it easier to copy/paste. Feel free to get ride of it ;-)

Status & tagging log