From da5d4f0f674dd47071de879e66ae2d9e6efaa305 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 13 Sep 2024 15:58:26 +0200 Subject: [PATCH] Debug v20 --- htdocs/comm/action/card.php | 19 ++++++++++++++----- .../action/class/actioncommreminder.class.php | 3 +-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 6384bb552ad..b54e23487fc 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -185,10 +185,10 @@ if (empty($reshook) && (GETPOST('removedassigned') || GETPOST('removedassigned') $_SESSION['assignedtouser'] = json_encode($tmpassigneduserids); $donotclearsession = 1; - if ($action == 'add' && $usercancreate) { + if ($action == 'add') { // Test on permission not required here $action = 'create'; } - if ($action == 'update' && $usercancreate) { + if ($action == 'update') { // Test on permission not required here $action = 'edit'; } @@ -993,6 +993,13 @@ if (empty($reshook) && $action == 'update' && $usercancreate) { // the notification must be created for every user assigned to the event foreach ($object->userassigned as $userassigned) { $actionCommReminder->fk_user = $userassigned['id']; + + // We update the event, so we recreate the notification event. + // First we delete all reminders for the user and the type of reminding (all offset dates). + $sqldelete = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_reminder"; + $sqldelete .= " WHERE fk_user = ".((int) $actionCommReminder->fk_user)." AND fk_actioncomm = ".((int) $object->id)." AND typeremind = '".$db->escape($remindertype)."'"; + $resqldelete = $db->query($sqldelete); + $res = $actionCommReminder->create($user); if ($res <= 0) { @@ -1007,13 +1014,14 @@ if (empty($reshook) && $action == 'update' && $usercancreate) { } } - unset($_SESSION['assignedtouser']); - unset($_SESSION['assignedtoresource']); - if (!$error) { + unset($_SESSION['assignedtouser']); + unset($_SESSION['assignedtoresource']); + $db->commit(); } else { $db->rollback(); + $action = 'edit'; } } else { setEventMessages($object->error, $object->errors, 'errors'); @@ -1968,6 +1976,7 @@ if ($id > 0) { $listofuserid = json_decode($_SESSION['assignedtouser'], true); } } + $listofcontactid = $object->socpeopleassigned; // Contact assigned $listofotherid = $object->otherassigned; // Other undefined email (not used yet) diff --git a/htdocs/comm/action/class/actioncommreminder.class.php b/htdocs/comm/action/class/actioncommreminder.class.php index 27a063dea7b..f430304d413 100644 --- a/htdocs/comm/action/class/actioncommreminder.class.php +++ b/htdocs/comm/action/class/actioncommreminder.class.php @@ -140,6 +140,7 @@ class ActionCommReminder extends CommonObject public $fk_email_template; // END MODULEBUILDER PROPERTIES + /** * Constructor * @@ -147,8 +148,6 @@ class ActionCommReminder extends CommonObject */ public function __construct(DoliDB $db) { - global $conf; - $this->db = $db; $this->ismultientitymanaged = 0;