Allow e-mail configuration by entity bundle

Created on 23 August 2019, about 5 years ago
Updated 13 October 2023, about 1 year ago

Problem/Motivation

Allow the administrator to customize alert mail by entity bundle.

Proposed resolution

Add option in the Comment notification settings page to customize the notification email per entity bundle.
If the subject or body is empty, use the default email value.

Remaining tasks

  1. ✅ Get maintainer approval for the new feature
  2. ❌ Include default email subject text and default mail text
  3. ❌ Test
Feature request
Status

Needs work

Version

1.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States cedewey Denver, CO

    I tried testing the patch but it did not apply.

    2 out of 6 hunks failed.

    Here is the contents of the src/Form/CommentNotifySettings.php.rej file

    --- src/Form/CommentNotifySettings.php
    +++ src/Form/CommentNotifySettings.php
    @@ -2,6 +2,7 @@
     
     namespace Drupal\comment_notify\Form;
     
    +use Drupal\comment\CommentInterface;
     use Drupal\Component\Utility\Html;
     use Drupal\Core\Entity\EntityInterface;
     use Drupal\Core\Extension\ModuleHandlerInterface;
    @@ -94,22 +95,21 @@ class CommentNotifySettings extends ConfigFormBase {
         $entity_types = [];
         foreach ($bundle_checkboxes as $comment_field_identifier => $bundle_checkbox_label) {
           $comment_field_info = explode('--', $comment_field_identifier);
    -      $entity_type = $comment_field_info[0];
    -      $entity_bundle = $comment_field_info[1];
    -      $field_name = $comment_field_info[2];
    +      [$entity_type, $entity_bundle, $field_name] = $comment_field_info;
           $entity_types[$entity_type][] = $comment_field_identifier;
           $comment_field = FieldConfig::loadByName($entity_type, $entity_bundle, $field_name);
     
    -      if (in_array($entity_type . '--' . $entity_bundle . '--' . $field_name, $enabled_bundles) && $comment_field && $comment_field->getSetting('anonymous') == COMMENT_ANONYMOUS_MAYNOT_CONTACT) {
    -        if (User::getAnonymousUser()->hasPermission('subscribe to comments')) {
    -          // Provide a link if the field_ui module is installed.
    -          if ($this->moduleHandler->moduleExists('field_ui')) {
    -            $link = Link::fromTextAndUrl($comment_field_identifier, $comment_field->toUrl($entity_type . '-field-edit-form'));
    -            $no_allowed_contact_info_field[] = $link->toString();
    -          }
    -          else {
    -            $no_allowed_contact_info_field[] = $comment_field_identifier;
    -          }
    +      if ($comment_field &&
    +        in_array($entity_type . '--' . $entity_bundle . '--' . $field_name, $enabled_bundles, TRUE) &&
    +        (int) $comment_field->getSetting('anonymous') === CommentInterface::ANONYMOUS_MAYNOT_CONTACT &&
    +        User::getAnonymousUser()->hasPermission('subscribe to comments')) {
    +        // Provide a link if the field_ui module is installed.
    +        if ($this->moduleHandler->moduleExists('field_ui')) {
    +          $link = Link::fromTextAndUrl($comment_field_identifier, $comment_field->toUrl($entity_type . '-field-edit-form'));
    +          $no_allowed_contact_info_field[] = $link->toString();
    +        }
    +        else {
    +          $no_allowed_contact_info_field[] = $comment_field_identifier;
             }
           }
         }
  • Status changed to Needs work about 1 year ago
  • 🇺🇸United States cedewey Denver, CO
  • 🇮🇳India SandeepSingh199

    @cedewey Created a re-roll patch of entity_bundle.patch. Please take a look & let me know if you can successfully applied this patch.

  • Status changed to Needs review about 1 year ago
  • 🇺🇸United States cedewey Denver, CO
  • Status changed to Needs work about 1 year ago
  • 🇺🇸United States cedewey Denver, CO

    Thank you for rerolling this Sandeep. This feature looks promising. I like that there is still a default email field in case a site owner doesn't need different emails per entity type.

    It would be helpful to still have a default subject line and email body. I recommend it including the current default values.

Production build 0.71.5 2024