You are here

function webform_update_8622 in Webform 6.x

Issue #174151 Webform Contact Form - open mail relay.

File

includes/webform.install.update.inc, line 4220
Archived Webform update hooks.

Code

function webform_update_8622() {
  $config_factory = \Drupal::configFactory();
  $config = $config_factory
    ->getEditable('webform.webform.contact');
  if (!$config) {
    return;
  }
  $to_mail = $config
    ->get('handlers.email_confirmation.settings.to_mail');
  if ($to_mail === '[webform_submission:values:email:raw]') {
    $config
      ->set('handlers.email_confirmation.settings.to_mail', '[current-user:mail]');
    $config
      ->save();

    /** @var \Drupal\webform\WebformHelpManagerInterface $help_manager */
    $help_manager = \Drupal::service('webform.help_manager');
    $help_manager
      ->addNotification('webform_update_8622', t("<strong>ATTENTION!!!</strong> The default Contact webform, included with the Webform module, has been updated to send the confirmation email to an authenticated user's email address.") . ' ' . t('<a href=":href">Learn more</a>', [
      ':href' => 'https://www.drupal.org/project/webform/releases/6.0.2',
    ]), 'warning');
  }
}