From 9af212a5427afa019f1d0b57dfbb5f0813fcbd08 Mon Sep 17 00:00:00 2001 From: cbeasley-sbb Date: Thu, 3 Oct 2024 13:33:02 -0500 Subject: [PATCH] Update ticket.class.php Bug-fix Issue #31206 (#31208) Fix Issue #31206 for the v.18 branch because unrelated tests failing on develop branch. --- htdocs/ticket/class/ticket.class.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index b14a71c6b070a..6d1ee87f93e8c 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -1575,6 +1575,8 @@ public function markAsRead($user, $notrigger = 0) $this->oldcopy = dol_clone($this); $this->db->begin(); + $oldStatus = $this->fk_statut; + $this->fk_statut = Ticket::STATUS_READ; $sql = "UPDATE ".MAIN_DB_PREFIX."ticket"; $sql .= " SET fk_statut = ".Ticket::STATUS_READ.", date_read = '".$this->db->idate(dol_now())."'"; @@ -1583,13 +1585,14 @@ public function markAsRead($user, $notrigger = 0) dol_syslog(get_class($this)."::markAsRead"); $resql = $this->db->query($sql); if ($resql) { - $this->actionmsg = $langs->trans('TicketLogMesgReadBy', $this->ref, $user->getFullName($langs)); - $this->actionmsg2 = $langs->trans('TicketLogMesgReadBy', $this->ref, $user->getFullName($langs)); + $this->context['actionmsg'] = $langs->trans('TicketLogMesgReadBy', $this->ref, $user->getFullName($langs)); + $this->context['actionmsg2'] = $langs->trans('TicketLogMesgReadBy', $this->ref, $user->getFullName($langs)); - if (!$error && !$notrigger) { + if (!$notrigger) { // Call trigger $result = $this->call_trigger('TICKET_MODIFY', $user); if ($result < 0) { + $this->fk_statut = $oldStatus; $error++; } // End call triggers @@ -1599,12 +1602,14 @@ public function markAsRead($user, $notrigger = 0) $this->db->commit(); return 1; } else { + $this->fk_statut = $oldStatus; $this->db->rollback(); - $this->error = join(',', $this->errors); + $this->error = implode(',', $this->errors); dol_syslog(get_class($this)."::markAsRead ".$this->error, LOG_ERR); return -1; } } else { + $this->fk_statut = $oldStatus; $this->db->rollback(); $this->error = $this->db->lasterror(); dol_syslog(get_class($this)."::markAsRead ".$this->error, LOG_ERR);