r99204 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99203‎ | r99204 | r99205 >
Date:10:05, 7 October 2011
Author:siebrand
Status:deferred (Comments)
Tags:
Comment:
* Follow-up r99112: use $user instead of $wgUser.
* Introduce $wgTranslateNewsletterPreference was introduced (default: false). Setting this to true, will once again add the "Do not send me e-mail newsletters" preference.
Modified paths:
  • /trunk/extensions/Translate/README (modified) (history)
  • /trunk/extensions/Translate/Translate.php (modified) (history)
  • /trunk/extensions/Translate/utils/UserToggles.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/Translate.php
@@ -15,7 +15,7 @@
1616 /**
1717 * Version number used in extension credits and in other placed where needed.
1818 */
19 -define( 'TRANSLATE_VERSION', '2011-09-29' );
 19+define( 'TRANSLATE_VERSION', '2011-10-07' );
2020
2121 /**
2222 * Extension credits properties.
@@ -214,6 +214,11 @@
215215 $wgTranslateFuzzyBotName = 'FuzzyBot';
216216
217217 /**
 218+ * Add a preference "Do not send me e-mail newsletters" in the e-mail preferences.
 219+ */
 220+$wgTranslateNewsletterPreference = false;
 221+
 222+/**
218223 * Default values for list of languages to show translators as an aid when
219224 * translating. Each user can override this setting in their preferences.
220225 * Example:
Index: trunk/extensions/Translate/README
@@ -29,6 +29,10 @@
3030 http://translatewiki.net/docs/Translate/html/
3131
3232 == Change log ==
 33+* 2011-10-07
 34+- $wgTranslateNewsletterPreference was introduced (default: false). Setting this
 35+ to true, will once again add the "Do not send me e-mail newsletters"
 36+ preference.
3337 * 2011-10-03
3438 - MessageIndex can now be stored in object cache (default) or in a file.
3539 - Fixed an error that sometimes prevented translating messages that had
Index: trunk/extensions/Translate/utils/UserToggles.php
@@ -15,31 +15,34 @@
1616 class TranslatePreferences {
1717 /**
1818 * Add 'translate-pref-nonewsletter' preference.
19 - * This is actually specific to translatewiki.net
 19+ * This is most probably specific to translatewiki.net. Can be enabled
 20+ * with $wgTranslateNewsletterPreference.
2021 *
2122 * @param $user User
2223 * @param $preferences array
2324 * @return bool true
2425 */
2526 public static function onGetPreferences( $user, &$preferences ) {
26 - global $wgEnableEmail, $wgUser, $wgEnotifRevealEditorAddress;
 27+ global $wgTranslateNewsletterPreference;
2728
28 - // TODO: Shouldn't we use $user here?
29 - // Only show is e-mail is enabled and user has a confirmed e-mail address.
30 - if ( $wgEnableEmail && $wgUser->isEmailConfirmed() ) {
31 - // 'translate-pref-nonewsletter' is used as opt-out for
32 - // users with a confirmed e-mail address
33 - $prefs = array(
34 - 'translate-nonewsletter' => array(
35 - 'type' => 'toggle',
36 - 'section' => 'personal/email',
37 - 'label-message' => 'translate-pref-nonewsletter'
38 - )
39 - );
 29+ if( $wgTranslateNewsletterPreference === true ) {
 30+ global $wgEnableEmail, $wgEnotifRevealEditorAddress;
 31+ // Only show is e-mail is enabled and user has a confirmed e-mail address.
 32+ if ( $wgEnableEmail && $user->isEmailConfirmed() ) {
 33+ // 'translate-pref-nonewsletter' is used as opt-out for
 34+ // users with a confirmed e-mail address
 35+ $prefs = array(
 36+ 'translate-nonewsletter' => array(
 37+ 'type' => 'toggle',
 38+ 'section' => 'personal/email',
 39+ 'label-message' => 'translate-pref-nonewsletter'
 40+ )
 41+ );
4042
41 - // Add setting after 'enotifrevealaddr'
42 - $preferences = wfArrayInsertAfter( $preferences, $prefs,
43 - $wgEnotifRevealEditorAddress ? 'enotifrevealaddr' : 'enotifminoredits' );
 43+ // Add setting after 'enotifrevealaddr'
 44+ $preferences = wfArrayInsertAfter( $preferences, $prefs,
 45+ $wgEnotifRevealEditorAddress ? 'enotifrevealaddr' : 'enotifminoredits' );
 46+ }
4447 }
4548
4649 return true;

Follow-up revisions

RevisionCommit summaryAuthorDate
r99391Follow-up r99204 per CR comment:...siebrand07:45, 10 October 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r99112More documentation updates and additions...reedy15:18, 6 October 2011

Comments

#Comment by Nikerabbit (talk | contribs)   17:45, 7 October 2011

=== true is redundant with booleans, and instead of indenting the whole thing inside if, you could do if ( !$foo ) { return true; }

Status & tagging log