[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Allow users to prevent new users from sending them email.

2017-12-12 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/391342 )

Change subject: Allow users to prevent new users from sending them email.
..


Allow users to prevent new users from sending them email.

Users now have the option to prevent Newbie users from sending
them emails.

Bug: T138165
Change-Id: I5d5332e50971fbcd1fa630d6bd03bdf757a9d1f1
---
M includes/DefaultSettings.php
M includes/Preferences.php
M includes/htmlform/fields/HTMLUsersMultiselectField.php
M includes/specials/SpecialEmailuser.php
M languages/i18n/en.json
M languages/i18n/qqq.json
M resources/Resources.php
A resources/src/mediawiki.special/mediawiki.special.preferences.personalEmail.js
8 files changed, 58 insertions(+), 7 deletions(-)

Approvals:
  jenkins-bot: Verified
  Kaldari: Looks good to me, approved



diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index a7b34a1..e50b7a7 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -4851,6 +4851,7 @@
'editfont' => 'monospace',
'editondblclick' => 0,
'editsectiononrightclick' => 0,
+   'email-allow-new-users' => 1,
'enotifminoredits' => 0,
'enotifrevealaddr' => 0,
'enotifusertalkpages' => 1,
diff --git a/includes/Preferences.php b/includes/Preferences.php
index 878462d..33a975d 100644
--- a/includes/Preferences.php
+++ b/includes/Preferences.php
@@ -534,12 +534,22 @@
 
if ( $config->get( 'EnableUserEmail' ) && 
$user->isAllowed( 'sendemail' ) ) {
$defaultPreferences['disablemail'] = [
+   'id' => 'wpAllowEmail',
'type' => 'toggle',
'invert' => true,
'section' => 'personal/email',
'label-message' => 'allowemail',
'disabled' => $disableEmailPrefs,
];
+
+   $defaultPreferences['email-allow-new-users'] = [
+   'id' => 'wpAllowEmailFromNewUsers',
+   'type' => 'toggle',
+   'section' => 'personal/email',
+   'label-message' => 
'email-allow-new-users-label',
+   'disabled' => $disableEmailPrefs,
+   ];
+
$defaultPreferences['ccmeonemails'] = [
'type' => 'toggle',
'section' => 'personal/email',
@@ -547,10 +557,7 @@
'disabled' => $disableEmailPrefs,
];
 
-   if ( $config->get( 'EnableUserEmailBlacklist' )
-&& !$disableEmailPrefs
-&& !(bool)$user->getOption( 
'disablemail' )
-   ) {
+   if ( $config->get( 'EnableUserEmailBlacklist' ) 
) {
$lookup = CentralIdLookup::factory();
$ids = $user->getOption( 
'email-blacklist', [] );
$names = $ids ? 
$lookup->namesFromCentralIds( $ids, $user ) : [];
@@ -560,6 +567,7 @@
'label-message' => 
'email-blacklist-label',
'section' => 'personal/email',
'default' => implode( "\n", 
$names ),
+   'disabled' => 
$disableEmailPrefs,
];
}
}
diff --git a/includes/htmlform/fields/HTMLUsersMultiselectField.php 
b/includes/htmlform/fields/HTMLUsersMultiselectField.php
index f094745..46cc6d3 100644
--- a/includes/htmlform/fields/HTMLUsersMultiselectField.php
+++ b/includes/htmlform/fields/HTMLUsersMultiselectField.php
@@ -56,6 +56,14 @@
public function getInputOOUI( $value ) {
$params = [ 'name' => $this->mName ];
 
+   if ( isset( $this->mParams['id'] ) ) {
+   $params['id'] = $this->mParams['id'];
+   }
+
+   if ( isset( $this->mParams['disabled'] ) ) {
+   $params['disabled'] = $this->mParams['disabled'];
+   }
+
if ( isset( $this->mParams['default'] ) ) {
$params['default'] = $this->mParams['default'];
}
diff --git a/includes/specials/SpecialEmailuser.php 
b/includes/specials/SpecialEmailuser.php
index 

[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Allow users to prevent new users from sending them email.

2017-11-14 Thread Dbarratt (Code Review)
Dbarratt has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/391342 )

Change subject: Allow users to prevent new users from sending them email.
..

Allow users to prevent new users from sending them email.

Users now have the option to prevent Newbie users from sending
them emails.

Bug: T138165
Change-Id: I5d5332e50971fbcd1fa630d6bd03bdf757a9d1f1
---
M includes/DefaultSettings.php
M includes/Preferences.php
M includes/specials/SpecialEmailuser.php
M languages/i18n/en.json
M languages/i18n/qqq.json
5 files changed, 19 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/42/391342/1

diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index 3cd7ef1..3308f63 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -4869,6 +4869,7 @@
'editfont' => 'monospace',
'editondblclick' => 0,
'editsectiononrightclick' => 0,
+   'email-allow-new-users' => 1,
'enotifminoredits' => 0,
'enotifrevealaddr' => 0,
'enotifusertalkpages' => 1,
diff --git a/includes/Preferences.php b/includes/Preferences.php
index 94854fa..c324f26 100644
--- a/includes/Preferences.php
+++ b/includes/Preferences.php
@@ -548,6 +548,14 @@
'label-message' => 'allowemail',
'disabled' => $disableEmailPrefs,
];
+
+   $defaultPreferences['email-allow-new-users'] = [
+   'type' => 'toggle',
+   'section' => 'personal/email',
+   'label-message' => 
'email-allow-new-users-label',
+   'disabled' => $disableEmailPrefs,
+   ];
+
$defaultPreferences['ccmeonemails'] = [
'type' => 'toggle',
'section' => 'personal/email',
diff --git a/includes/specials/SpecialEmailuser.php 
b/includes/specials/SpecialEmailuser.php
index 30eb38d..edc6068 100644
--- a/includes/specials/SpecialEmailuser.php
+++ b/includes/specials/SpecialEmailuser.php
@@ -243,6 +243,14 @@
return 'nowikiemail';
}
}
+
+   if ( !$target->getOption( 'email-allow-new-users' ) ) {
+   if ( $sender->isNewbie() ) {
+   wfDebug( "User does not allow user 
emails from new users.\n" );
+
+   return 'nowikiemail';
+   }
+   }
}
 
return '';
diff --git a/languages/i18n/en.json b/languages/i18n/en.json
index dc5d97d..5164f86 100644
--- a/languages/i18n/en.json
+++ b/languages/i18n/en.json
@@ -1062,6 +1062,7 @@
"timezoneregion-indian": "Indian Ocean",
"timezoneregion-pacific": "Pacific Ocean",
"allowemail": "Allow other users to email me",
+   "email-allow-new-users-label": "Allow emails from brand-new users",
"email-blacklist-label": "Prohibit these users from emailing me:",
"prefs-searchoptions": "Search",
"prefs-namespaces": "Namespaces",
diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json
index 862f64c..9cb5fa0 100644
--- a/languages/i18n/qqq.json
+++ b/languages/i18n/qqq.json
@@ -1256,6 +1256,7 @@
"timezoneregion-indian": "Used in \"Time zone\" listbox in 
[[Special:Preferences#mw-prefsection-datetime|preferences]], \"date and time\" 
tab.\n{{Related|Timezoneregion}}",
"timezoneregion-pacific": "Used in \"Time zone\" listbox in 
[[Special:Preferences#mw-prefsection-datetime|preferences]], \"date and time\" 
tab.\n{{Related|Timezoneregion}}",
"allowemail": "Used in [[Special:Preferences]] > {{int:prefs-personal}} 
> {{int:email}}.",
+   "email-allow-new-users-label": "Used in [[Special:Preferences]] > 
{{int:prefs-prohibit}} > {{int:email}}.",
"email-blacklist-label": "Used in [[Special:Preferences]] > 
{{int:prefs-prohibit}} > {{int:email}}.",
"prefs-searchoptions": "{{Identical|Search}}",
"prefs-namespaces": "Shown as legend of the second fieldset of the tab 
'Search' in [[Special:Preferences]]\n{{Identical|Namespace}}",

-- 
To view, visit https://gerrit.wikimedia.org/r/391342
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5d5332e50971fbcd1fa630d6bd03bdf757a9d1f1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Dbarratt 

___
MediaWiki-commits mailing list