Merge "Allow users to restrict who can send them direct emails via Special:EmailUser"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 14 Sep 2017 01:02:25 +0000 (01:02 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 14 Sep 2017 01:02:25 +0000 (01:02 +0000)
1  2 
includes/DefaultSettings.php
includes/Preferences.php
includes/skins/Skin.php

@@@ -1603,6 -1603,13 +1603,13 @@@ $wgEnableEmail = true
   */
  $wgEnableUserEmail = true;
  
+ /**
+  * Set to true to enable user-to-user e-mail blacklist.
+  *
+  * @since 1.30
+  */
+ $wgEnableUserEmailBlacklist = false;
  /**
   * If true put the sending user's email in a Reply-To header
   * instead of From (false). ($wgPasswordSender will be used as From.)
@@@ -6850,6 -6857,13 +6857,6 @@@ $wgStructuredChangeFiltersShowPreferenc
   */
  $wgStructuredChangeFiltersEnableExperimentalViews = false;
  
 -/**
 - * Whether to allow users to use the experimental live update feature in the new RecentChanges UI
 - *
 - * Temporary variable during development and will be removed.
 - */
 -$wgStructuredChangeFiltersEnableLiveUpdate = false;
 -
  /**
   * Whether to enable RCFilters app on Special:Watchlist
   *
diff --combined includes/Preferences.php
@@@ -554,6 -554,22 +554,22 @@@ class Preferences 
                                        'label-message' => 'tog-ccmeonemails',
                                        'disabled' => $disableEmailPrefs,
                                ];
+                               if ( $config->get( 'EnableUserEmailBlacklist' )
+                                        && !$disableEmailPrefs
+                                        && !(bool)$user->getOption( 'disablemail' )
+                               ) {
+                                       $lookup = CentralIdLookup::factory();
+                                       $ids = $user->getOption( 'email-blacklist', [] );
+                                       $names = $ids ? $lookup->namesFromCentralIds( $ids, $user ) : [];
+                                       $defaultPreferences['email-blacklist'] = [
+                                               'type' => 'usersmultiselect',
+                                               'label-message' => 'email-blacklist-label',
+                                               'section' => 'personal/email',
+                                               'default' => implode( "\n", $names ),
+                                       ];
+                               }
                        }
  
                        if ( $config->get( 'EnotifWatchlist' ) ) {
                $htmlForm->setSubmitText( $context->msg( 'saveprefs' )->text() );
                # Used message keys: 'accesskey-preferences-save', 'tooltip-preferences-save'
                $htmlForm->setSubmitTooltip( 'preferences-save' );
 -              $htmlForm->setSubmitID( 'prefsubmit' );
 +              $htmlForm->setSubmitID( 'prefcontrol' );
                $htmlForm->setSubmitCallback( [ 'Preferences', 'tryFormSubmit' ] );
  
                return $htmlForm;
diff --combined includes/skins/Skin.php
@@@ -1057,10 -1057,10 +1057,10 @@@ abstract class Skin extends ContextSour
                        $targetUser = User::newFromId( $id );
                }
  
-               # The sending user must have a confirmed email address and the target
-               # user must have a confirmed email address and allow emails from users.
-               return $this->getUser()->canSendEmail() &&
-                       $targetUser->canReceiveEmail();
+               # The sending user must have a confirmed email address and the receiving
+               # user must accept emails from the sender.
+               return $this->getUser()->canSendEmail()
+                       && SpecialEmailUser::validateTarget( $targetUser, $this->getUser() ) === '';
        }
  
        /**
  
                $attribs = [];
                if ( !is_null( $tooltip ) ) {
 -                      # T27462: undo double-escaping.
 -                      $tooltip = Sanitizer::decodeCharReferences( $tooltip );
                        $attribs['title'] = wfMessage( 'editsectionhint' )->rawParams( $tooltip )
                                ->inLanguage( $lang )->text();
                }