-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from UCBoulder/713
Service Alert titles
- Loading branch information
Showing
1 changed file
with
14 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,11 +17,17 @@ function sympa_mail($key, &$message, $params) { | |
switch ($key) { | ||
case 'subscriptions': | ||
$message['from'] = \Drupal::config('system.site')->get('mail'); | ||
$message['headers'] = [ | ||
'reply-To' => '[email protected]', | ||
]; | ||
$message['body'][] = $params['action'] . ' ' . $params['type'] . ' ' . $params['email'] . ' ' . $params['name']; | ||
break; | ||
|
||
case 'node-update': | ||
$message['from'] = \Drupal::config('system.site')->get('mail'); | ||
$message['headers'] = [ | ||
'reply-To' => '[email protected]', | ||
]; | ||
$message['subject'] = $params['title']; | ||
$message['body'][] = $params['body']; | ||
break; | ||
|
@@ -34,17 +40,7 @@ function sympa_mail($key, &$message, $params) { | |
function sympa_entity_presave(EntityInterface $entity) { | ||
$type = $entity->bundle(); | ||
if ((!$entity->isNew()) && ($entity->getEntityType()->id() == 'node') && ($type == 'news' || $type == 'service_alert')) { | ||
$get_fields = $entity->getFields(); | ||
$sympa_send = $get_fields['field_sympa_send']->getValue(); | ||
if ($sympa_send[0]['value'] == 1) { | ||
$sympa_body = $get_fields['body']->getValue(); | ||
$sympa_nid = $entity->id(); | ||
$sympa_title = Xss::filter($entity->gettitle()); | ||
sympa_build_email($type, $sympa_nid, $sympa_title, $sympa_body, 'sympa'); | ||
sympa_build_email($type, $sympa_nid, $sympa_title, $sympa_body, 'distribution_list'); | ||
// See if checked set to the default of 0 below. | ||
$entity->set('field_sympa_send', 0); | ||
} | ||
sympa_node_email_send($entity); | ||
} | ||
} | ||
|
||
|
@@ -54,18 +50,23 @@ function sympa_entity_presave(EntityInterface $entity) { | |
function sympa_node_insert(EntityInterface $entity) { | ||
$type = $entity->bundle(); | ||
if ($type == 'news' || $type == 'service_alert') { | ||
sympa_node_email_send($entity); | ||
} | ||
} | ||
|
||
function sympa_node_email_send($entity) { | ||
$type = $entity->bundle(); | ||
$get_fields = $entity->getFields(); | ||
$sympa_send = $get_fields['field_sympa_send']->getValue(); | ||
if ($sympa_send[0]['value'] == 1) { | ||
$sympa_body = $get_fields['body']->getValue(); | ||
$sympa_nid = $entity->id(); | ||
$sympa_title = Xss::filter($entity->gettitle()); | ||
$sympa_title = $entity->get('field_service_alert_status')->getValue()[0]['value'] . ": " . $entity->gettitle(); | ||
sympa_build_email($type, $sympa_nid, $sympa_title, $sympa_body, 'sympa'); | ||
sympa_build_email($type, $sympa_nid, $sympa_title, $sympa_body, 'distribution_list'); | ||
// See if checked set to the default of 0 below. | ||
$entity->set('field_sympa_send', 0); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
|