Fixanje posiljanja prek mailov. Izkljuci yufu admin

pull/59/head
Lio Novelli 2024-04-01 20:00:31 +02:00
parent dd0a8de6b2
commit 8767ef606b
4 changed files with 52 additions and 35 deletions

View File

@ -12,7 +12,7 @@ roles:
author: false author: false
site_mail: false site_mail: false
emails: '' emails: ''
subject: 'New draft [node:title]' subject: '[YUFU] New draft [node:title]'
body: body:
value: "New draft pedning moderation: [node:title] ([node:nid]) by [node:author:email].\r\n\r\n[node:url]\r\n\r\n[node:body]" value: "New draft pedning moderation: [node:title] ([node:nid]) by [node:author:email].\r\n\r\n[node:url]\r\n\r\n[node:body]"
format: plain_text format: plain_text

View File

@ -10,7 +10,7 @@ roles: { }
author: true author: true
site_mail: false site_mail: false
emails: '' emails: ''
subject: 'Yufu changes approved' subject: '[YUFU] Changes approved'
body: body:
value: 'Your proposed changes to [node:title] ([node:url]) were approved.' value: 'Your proposed changes to [node:title] ([node:url]) were approved.'
format: plain_text format: plain_text

View File

@ -57,39 +57,39 @@ function yufu_admin_mail($key, &$message, $params) {
/** /**
* Implements hook_ENTITY_TYPE_presave(). * Implements hook_ENTITY_TYPE_presave().
*/ */
function yufu_admin_node_presave(EntityInterface $entity) { // function yufu_admin_node_presave(EntityInterface $entity) {
if ($entity instanceOf NodeInterface && $entity->bundle() == 'concept') { // if ($entity instanceOf NodeInterface && $entity->bundle() == 'concept') {
// Get transition: concept_drafted, concept_approved, concept_rejected. // // Get transition: concept_drafted, concept_approved, concept_rejected.
if ($entity->isNew()) { // if ($entity->isNew()) {
$transition = 'concept_drafted'; // $transition = 'concept_drafted';
} // }
else { // else {
$transition = _yufu_admin_get_node_transition($entity); // $transition = _yufu_admin_get_node_transition($entity);
} // }
switch ($transition) { // switch ($transition) {
case 'stay_draft': // case 'stay_draft':
case 'concept_drafted': // case 'concept_drafted':
// Send email to editors. // // Send email to editors.
$params = _yufu_admin_concept_drafted_mail($entity); // $params = _yufu_admin_concept_drafted_mail($entity);
$result = _yufu_admin_send_email($transition, $params['to'], $params); // $result = _yufu_admin_send_email($transition, $params['to'], $params);
_yufu_admin_status_message($result['result'], $transition, $entity, $params['to']); // _yufu_admin_status_message($result['result'], $transition, $entity, $params['to']);
break; // break;
case 'concept_approved': // case 'concept_approved':
// Send email to revision creator (user). // // Send email to revision creator (user).
// @TODO Maybe notify other editors. // // @TODO Maybe notify other editors.
$params = _yufu_admin_concept_approved_get_message($entity); // $params = _yufu_admin_concept_approved_get_message($entity);
$result = _yufu_admin_send_email($transition, $params['to'], $params); // $result = _yufu_admin_send_email($transition, $params['to'], $params);
_yufu_admin_status_message($result['result'], $transition, $entity, $params['to']); // _yufu_admin_status_message($result['result'], $transition, $entity, $params['to']);
break; // break;
case 'concept_rejectd': // case 'concept_rejectd':
// Send email to revision creator (user). // // Send email to revision creator (user).
// This transition happens on revision delete. // // This transition happens on revision delete.
// Curently it is dead. // // Curently it is dead.
// @TODO https://git.kompot.si/yufu/manifest/issues/45 // // @TODO https://git.kompot.si/yufu/manifest/issues/45
break; // break;
} // }
} // }
} //}
/** /**
* Compare original node moderation state with current state. * Compare original node moderation state with current state.
@ -276,3 +276,15 @@ function _yufu_admin_get_all_pioneer_emails() {
// @TODO: Think it through if it is really needed. // @TODO: Think it through if it is really needed.
return []; return [];
} }
/**
* Invoke hook_content_moderation_notification_mail_data_alter().
*/
// function yufu_admin_content_moderation_notification_mail_data_alter(EntityInterface $entity, array &$data) {
// // Add an extra email address to the list.
// if ($entity instanceOf NodeInterface) {
// if ($email = _yufu_admin_get_pioneer_email($entity)) {
// $data['to'][] = $email;
// }
// }
// }

View File

@ -124,6 +124,11 @@ class AddConcept extends ResourceBase {
$concept->setRevisionUserId($uid); $concept->setRevisionUserId($uid);
$concept->set('title', $data['title']); $concept->set('title', $data['title']);
$concept->set('body', $data['text'] ?? $concept->body->value); $concept->set('body', $data['text'] ?? $concept->body->value);
if ($uid) {
$uids = $concept->get('uid')->getValue();
$uids[] = ['target_id' => $uid];
$concept->set('uid', $uids);
}
$concept->isDefaultRevision(FALSE); $concept->isDefaultRevision(FALSE);
$concept->setRevisionLogMessage('New revision by concept endpoint.'); $concept->setRevisionLogMessage('New revision by concept endpoint.');
$concept->set('moderation_state', 'draft'); $concept->set('moderation_state', 'draft');