Commit 79ec7e43 authored by Gisle Hannemyr's avatar Gisle Hannemyr Committed by Gisle Hannemyr
Browse files

Issue #3300511 by gisle: First stab at fixing tests

parent 7d91a51c
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -51,6 +51,10 @@ want to send out notifications.
   registration, you must grant the anonymous user the right to
   "Access Notify".

   To allow authenticated users manage what content types they
   subscribe to, you must give the authenticated user the right to
   "Access Notify".

4. Configure general notification settings.  See the next section for
   details.

+3 −0
Original line number Diff line number Diff line
@@ -35,3 +35,6 @@ notify.settings:
    notify_def_comment:
      type: string
      label: 'Notify new comments'
    notify_nodetypes:
      type: ignore
      label: 'Node types to permit'
+7 −0
Original line number Diff line number Diff line
@@ -109,8 +109,15 @@ function notify_user_insert(User $account) {
      'comment' => $config->get('notify_def_comment'),
    ])
    ->execute();
  // Subscribe user to node type if subscription is permitted
  // Get permitted node types.
  $nodetypes = $config->get('notify_nodetypes');
  /*
  $nodetypes = [
    'article' => TRUE,
  ];
  */

  if ($nodetypes != NULL) {
    foreach ($nodetypes as $ntype => $value) {
      if ($value) {
+1 −1
Original line number Diff line number Diff line
@@ -124,7 +124,7 @@ class DefaultForm extends ConfigFormBase {
      '#type' => 'details',
      '#title' => $this->t('Notification subscriptions by node type'),
      '#open' => TRUE,
      '#description' => $this->t('Tick the node types to make available for subscription. New users are automatically subscribed, but can unsubscribe in their user profile.'),
      '#description' => $this->t('Tick the node types to make available for subscription. New users are automatically subscribed, but can unsubscribe in their user profile if they have the permission "Access Notify".'),
    ];
    $nodetypes = [];
    $node_types = \Drupal::entityTypeManager()->getStorage('node_type')->loadMultiple();
+6 −33
Original line number Diff line number Diff line
@@ -121,35 +121,6 @@ class Notify implements NotifyInterface {
        ->execute();
    }

    foreach ($values as $key => $value) {
      if (preg_match("/^" . static::NODE_TYPE . "/", $key)) {
        $key = substr($key, 17);

        $id = $this->database->select('notify_subscriptions', 'n')
          ->fields('n', ['id', 'uid', 'type'])
          ->condition('uid', $uid)
          ->condition('type', $key)
          ->execute()->fetchObject();
        if ($id) {
          $id = $id->id;
          if (!$value) {
            $this->database->delete('notify_subscriptions')
              ->condition('id', $id)
              ->execute();
          }
        }
        else {
          if ($value) {
            $this->database->insert('notify_subscriptions')
              ->fields([
                'uid' => $uid,
                'type' => $key,
              ])
              ->execute();
          }
        }
      }
    }
  }

  /**
@@ -594,9 +565,9 @@ class Notify implements NotifyInterface {
              ->fields('n', ['uid', 'type'])
              ->condition('uid', $userrow['uid'])
              ->condition('type', $node->getType())
              ->execute()->fetchObject();
              ->execute()->fetchAssoc();

            if (TRUE) {
            if ($field) {
              $ml_level = $this->config->get('notify_multilingual');
              if (!$userobj->hasPermission('administer notify')) {
                if ($ml_level && $node->tnid) {
@@ -650,8 +621,8 @@ class Notify implements NotifyInterface {
              // Creates a link to be embedded in plain text mail:
              $link = $host . '/' . Url::fromUri('internal:/node/' . $node->id())->toString();
              $node_body .= ' - see ' . $link . '<br>';
            }
          }
            } // if ($field)
          } // foreach ($nodes as $node)

          // Prepend e-mail header as long as user could access at least one node.
          if ($node_count > 0) {
@@ -660,6 +631,8 @@ class Notify implements NotifyInterface {
            ], ['langcode' => $upl]) . "<br />" . '</p>' . $node_body;
          }
        }
	//dpm($field, 'field before comments');
	// Need to filter on content type and pernission, see issue #3221814.
        // Consider new comments if user has permissions and comments are ready.
        if ($userrow['comment'] && $userobj->hasPermission('access comments') && count($comments)) {
          $comment_count = 0;
Loading