Improve email messages.

pull/42/head
Lio Novelli 2024-03-10 22:48:32 +01:00
parent 3e527de407
commit 2f0aff3f95
1 changed files with 15 additions and 8 deletions

View File

@ -44,12 +44,12 @@ function yufu_admin_mail($key, &$message, $params) {
break; break;
case 'concept_approved': case 'concept_approved':
$message['from'] = \Drupal::config('system.site')->get('mail'); $message['from'] = \Drupal::config('system.site')->get('mail');
$message['subject'] = t('[YUFU] Your concept (changes) were approved: @title', ['@title' => $params['node_title']], $options); $message['subject'] = t('[YUFU] Concept changes approved: @title', ['@title' => $params['node_title']], $options);
$message['body'][] = $params['message']; $message['body'][] = $params['message'];
break; break;
case 'concept_rejected': case 'concept_rejected':
$message['from'] = \Drupal::config('system.site')->get('mail'); $message['from'] = \Drupal::config('system.site')->get('mail');
$message['subject'] = t('[YUFU] Your concept (changes) were rejected: @title', ['@title' => $params['node_title']], $options); $message['subject'] = t('[YUFU] Concept changes rejected: @title', ['@title' => $params['node_title']], $options);
$message['body'][] = $params['message']; $message['body'][] = $params['message'];
} }
} }
@ -127,10 +127,18 @@ function _yufu_admin_get_node_transition(NodeInterface $node) {
*/ */
function _yufu_admin_concept_drafted_mail(NodeInterface $node) { function _yufu_admin_concept_drafted_mail(NodeInterface $node) {
$to = _yufu_admin_get_all_editors_emails(); $to = _yufu_admin_get_all_editors_emails();
$params['message'] = t('New concept created: @title - @url', [ if ($node->isNew()) {
'@title' => $node->getTitle(), $params['message'] = t('New concept created: @title - @url', [
'@url' => !$node->isNew() ? $node?->toUrl()?->toString() : '', '@title' => $node->getTitle(),
]); '@url' => !$node->isNew() ? $node?->toUrl()?->toString() : '',
]);
}
else {
$params['message'] = t('New changes to concept proposed: @title - @url', [
'@title' => $node->getTitle(),
'@url' => !$node->isNew() ? $node?->toUrl()?->toString() : '',
]);
}
$params['node_title'] = $node->getTitle(); $params['node_title'] = $node->getTitle();
$params['to'] = implode(',', $to); $params['to'] = implode(',', $to);
return $params; return $params;
@ -220,8 +228,7 @@ function _yufu_admin_concept_approved_get_message(NodeInterface $node) {
// @TODO - to make this work properly, we should get a list of all authors of // @TODO - to make this work properly, we should get a list of all authors of
// unpublished revisions so far since the last published revision. // unpublished revisions so far since the last published revision.
if ($to = _yufu_admin_get_pioneer_email($node)) { if ($to = _yufu_admin_get_pioneer_email($node)) {
// @TODO Dodamo se avtorja v sporocilo? $params['message'] = t('Your proposal of changes to concept were approved: @title - @url', [
$params['message'] = t('New concept created: @title - @url', [
'@title' => $node->getTitle(), '@title' => $node->getTitle(),
'@url' => $node?->toUrl()?->toString() ?? '', '@url' => $node?->toUrl()?->toString() ?? '',
]); ]);