Commit 9711dae4 authored by NGUYEN Bao's avatar NGUYEN Bao
Browse files

Issue #3290504 by Project Update Bot: Automated Drupal 10 compatibility fixes

parent f09d6c82
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -637,6 +637,7 @@ display:
          assign_field: field_assignors
          total_field: field_task_point
          send_email: 1
          send_notification: 0
          dialog_width: 80%
      row:
        type: fields
+1 −1
Original line number Diff line number Diff line
@@ -2,6 +2,6 @@ name: 'Views kanban demo'
description: 'Provides Task content type and task demo for view kanban'
type: module
package: 'Views'
core_version_requirement: '^8.9 || ^9'
core_version_requirement: '^8.9 || ^9 || ^10'
dependencies:
  - views_kanban
+48 −39
Original line number Diff line number Diff line
@@ -82,9 +82,14 @@ class KanbanController extends ControllerBase {
    }

    $entity->save();

    // Send email to assignor.
    if (!empty($style_plugin->options["send_email"])) {
    $url = Url::fromRoute(implode('.', [
      'view',
      $view_id,
      $view->current_display,
    ]));
    // Send email, notification to assignor.
    if (!empty($style_plugin->options["send_email"]) ||
      !empty($style_plugin->options["send_notification"])) {
      $user = User::load(\Drupal::currentUser()->id());
      $email = $user->getEmail();
      $name = $user->getDisplayName();
@@ -92,7 +97,7 @@ class KanbanController extends ControllerBase {
        return $v[0];
      },
        explode(' ', $name)));
      $assignValues[$entity->getOwnerID()] = [$entity->getOwnerID()];
      $assignValues[$uid = $entity->getOwnerID()] = $uid;
      if (!empty($style_plugin->options["assign_field"])) {
        $assignors = $entity->get($style_plugin->options["assign_field"])
          ->getValue();
@@ -102,15 +107,13 @@ class KanbanController extends ControllerBase {
      }
      $mailManager = \Drupal::service('plugin.manager.mail');
      $key = $view_id . '-' . $view->current_display;
      $link = Url::fromRoute(implode('.', [
        'view',
        $view_id,
        $view->current_display,
      ]))->setOption('absolute', TRUE)
      $link = $url->setOption('absolute', TRUE)
        ->setOption('query', ['kanbanTicket' => $entity_id])
        ->toString();
      foreach ($assignValues as $uid) {
        $assignor = User::load($entity->getOwnerID());
      foreach ($assignValues as $uid => $userID) {
        //Send Email.
        if (!empty($style_plugin->options["send_email"])) {
          $assignor = User::load($uid);
          $to = $assignor->getEmail();

          // Set up email template.
@@ -125,7 +128,7 @@ class KanbanController extends ControllerBase {
            '#btn_text' => $this->t('View'),
            '#link' => $link,
          ];
        $message = [
          $messageSend = [
            'id' => $key,
            'headers' => [
              'Content-type' => 'text/html; charset=UTF-8; format=flowed; delsp=yes',
@@ -139,7 +142,13 @@ class KanbanController extends ControllerBase {
            'body' => \Drupal::service('renderer')->render($body_data),
          ];
          $mailManager->getInstance(['module' => 'views_kanban', 'key' => $key])
          ->mail($message);
            ->mail($messageSend);
        }
        // Send notification.
        if(!empty($style_plugin->options["send_notification"])) {
          \Drupal::service('pwa_firebase.send')
            ->sendMessageToUser($uid, $view->getTitle(), $message, $url->toString());
        }
      }
    }
    $data = [
+2 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@

namespace Drupal\views_kanban\Event;

use Symfony\Component\EventDispatcher\Event;
use Symfony\Contracts\EventDispatcher\Event;
use Drupal\Core\Entity\EntityInterface;

/**
@@ -36,6 +36,7 @@ class KanbanNodeInsertEvent extends Event {
   *   Return Entity.
   */
  public function getEntity() {
    // @Todo send mail, notification to assignor.
    return $this->entity;
  }

+8 −0
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ class Kanban extends StylePluginBase {
    $options['history_field'] = ['default' => ''];
    $options['total_field'] = ['default' => ''];
    $options['send_email'] = ['default' => FALSE];
    $options['send_notification'] = ['default' => true];
    $options['dialog_width'] = ['default' => '80%'];
    $options['default'] = ['default' => ''];
    $options['order'] = ['default' => 'asc'];
@@ -165,6 +166,13 @@ class Kanban extends StylePluginBase {
      '#title' => $this->t('Send an email after the change of status'),
      '#default_value' => !empty($this->options['send_email']) ? $this->options['send_email'] : '',
    ];
    if (\Drupal::moduleHandler()->moduleExists('pwa_firebase')) {
      $form['send_notification'] = [
        '#type' => 'checkbox',
        '#title' => $this->t('Send notification to assign user'),
        '#default_value' => !empty($this->options['send_notification']) ? $this->options['send_notification'] : '',
      ];
    }
    $form['dialog_width'] = [
      '#type' => 'textfield',
      '#title' => $this->t('Dialog width'),
Loading