'editfont' => 'monospace',
'editondblclick' => 0,
'editsectiononrightclick' => 0,
+ 'email-allow-new-users' => 1,
'enotifminoredits' => 0,
'enotifrevealaddr' => 0,
'enotifusertalkpages' => 1,
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',
'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 ) : [];
'label-message' => 'email-blacklist-label',
'section' => 'personal/email',
'default' => implode( "\n", $names ),
+ 'disabled' => $disableEmailPrefs,
];
}
}
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'];
}
return 'nowikiemail';
}
- if (
- $target->getEditCount() === 0
- && ( $sender === null || !$sender->isAllowed( 'sendemail-new-users' ) )
+ if ( $target->getEditCount() === 0 &&
+ ( $sender === null || !$sender->isAllowed( 'sendemail-new-users' ) )
) {
// Determine if target has any other logged actions.
$dbr = wfGetDB( DB_REPLICA );
}
}
+ if ( $sender !== null && !$target->getOption( 'email-allow-new-users' ) &&
+ $sender->isNewbie()
+ ) {
+ wfDebug( "User does not allow user emails from new users.\n" );
+
+ return 'nowikiemail';
+ }
+
if ( $sender !== null ) {
$blacklist = $target->getOption( 'email-blacklist', [] );
if ( $blacklist ) {
"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",
"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}}",
'resources/src/mediawiki.special/mediawiki.special.preferences.convertmessagebox.js',
'resources/src/mediawiki.special/mediawiki.special.preferences.tabs.js',
'resources/src/mediawiki.special/mediawiki.special.preferences.timezone.js',
+ 'resources/src/mediawiki.special/mediawiki.special.preferences.personalEmail.js',
],
'messages' => [
'prefs-tabs-navigation-hint',
--- /dev/null
+/*!
+ * JavaScript for Special:Preferences: Email preferences better UX
+ */
+( function ( $ ) {
+ $( function () {
+ var allowEmail, allowEmailFromNewUsers;
+
+ allowEmail = $( '#wpAllowEmail' );
+ allowEmailFromNewUsers = $( '#wpAllowEmailFromNewUsers' );
+
+ function toggleDisabled() {
+ if ( allowEmail.is( ':checked' ) && allowEmail.is( ':enabled' ) ) {
+ allowEmailFromNewUsers.prop( 'disabled', false );
+ } else {
+ allowEmailFromNewUsers.prop( 'disabled', true );
+ }
+ }
+
+ if ( allowEmail ) {
+ allowEmail.on( 'change', toggleDisabled );
+ toggleDisabled();
+ }
+ } );
+}( jQuery ) );