EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
Support custom reminder types in saver (#3708)
Anton Slyzhko6e4ac733499f
diff --git a/application/Espo/Core/FieldProcessing/Reminder/Saver.php b/application/Espo/Core/FieldProcessing/Reminder/Saver.phpindex dcd93eb167..586a6788c4 100644--- a/application/Espo/Core/FieldProcessing/Reminder/Saver.php+++ b/application/Espo/Core/FieldProcessing/Reminder/Saver.php@@ -457,52 +457,41 @@ class Saver implements SaverInterfacereturn;}- $hasPopup = array_filter($list, fn ($it) => $it['type'] === Reminder::TYPE_POPUP) !== [];- $hasEmail = array_filter($list, fn ($it) => $it['type'] === Reminder::TYPE_EMAIL) !== [];+ /** @var array<string, bool> $hasTypeMap */+ $hasTypeMap = [];- $hasPopupCreated = false;- $hasEmailCreated = false;+ /** @var array<string, bool> $createdTypeMap */+ $createdTypeMap = [];foreach ($list as $item) {+ $type = $item['type'];+ $hasTypeMap[$type] = true;+$isCreated = $this->createReminder(entity: $entity,userId: $userId,start: $start,item: $item,);-+if (!$isCreated) {continue;}-- if ($item['type'] === Reminder::TYPE_POPUP) {- $hasPopupCreated = true;- }-- if ($item['type'] === Reminder::TYPE_EMAIL) {- $hasEmailCreated = true;- }- }-- if ($hasPopup && !$hasPopupCreated) {- $this->createReminder(- entity: $entity,- userId: $userId,- start: $start,- item: [- 'type' => Reminder::TYPE_POPUP,- 'seconds' => null,- ],- );++ $createdTypeMap[$type] = true;}-- if ($hasEmail && !$hasEmailCreated) {++ foreach (array_keys($hasTypeMap) as $type) {+ if ($createdTypeMap[$type] ?? false) {+ continue;+ }+$this->createReminder(entity: $entity,userId: $userId,start: $start,item: [- 'type' => Reminder::TYPE_EMAIL,+ 'type' => $type,'seconds' => null,],);