From 1755d5b3c0b147c1447433e0bd07c3b73994762f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Lukas?= Date: Tue, 26 Dec 2023 23:27:35 +0100 Subject: [PATCH 1/4] New Feature #27221 When there is an attachment in a reply to a ticket this attachment should be stored in the ticket. Currently the attachment is lost (not stored) --- .../class/emailcollector.class.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 7af77ad64b3..5d0c2a121e2 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -2652,6 +2652,23 @@ class EmailCollector extends CommonObject $errorforactions++; $this->errors = $actioncomm->errors; } else { + if (($fk_element_type == 'ticket') && (!empty ($attachments))) + { + // There is an attachment for the ticket -> store attachment + $ticket = New Ticket ($this->db); + $ticket->fetch ($fk_element_id); + $destdir = $conf->ticket->dir_output.'/'.$ticket->ref; + if (!dol_is_dir($destdir)) { + dol_mkdir($destdir); + } + if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { + foreach ($attachments as $attachment) { + $attachment->save($destdir.'/'); + } + } else { + $this->getmsg($connection, $imapemail, $destdir); + } + } $operationslog .= '
Event created -> id='.dol_escape_htmltag($actioncomm->id); } } From bd90017d368dc8df896209b520838729229bdea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Lukas?= Date: Tue, 26 Dec 2023 23:35:44 +0100 Subject: [PATCH 2/4] Update emailcollector.class.php Fix phpcs problems --- htdocs/emailcollector/class/emailcollector.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 5d0c2a121e2..9889bca2bb7 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -2652,8 +2652,7 @@ class EmailCollector extends CommonObject $errorforactions++; $this->errors = $actioncomm->errors; } else { - if (($fk_element_type == 'ticket') && (!empty ($attachments))) - { + if (($fk_element_type == 'ticket') && (!empty ($attachments))) { // There is an attachment for the ticket -> store attachment $ticket = New Ticket ($this->db); $ticket->fetch ($fk_element_id); From 93ea0f63baf8f5c59237d3b42e90478b6b7cad93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Lukas?= Date: Tue, 26 Dec 2023 23:40:52 +0100 Subject: [PATCH 3/4] Update emailcollector.class.php Fix phpcs problems --- htdocs/emailcollector/class/emailcollector.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 9889bca2bb7..aefea302b23 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -2654,8 +2654,8 @@ class EmailCollector extends CommonObject } else { if (($fk_element_type == 'ticket') && (!empty ($attachments))) { // There is an attachment for the ticket -> store attachment - $ticket = New Ticket ($this->db); - $ticket->fetch ($fk_element_id); + $ticket = New Ticket($this->db); + $ticket->fetch($fk_element_id); $destdir = $conf->ticket->dir_output.'/'.$ticket->ref; if (!dol_is_dir($destdir)) { dol_mkdir($destdir); From 07ca03c9a500b8c51c1997309639c34ef10fd96f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Lukas?= Date: Tue, 26 Dec 2023 23:43:17 +0100 Subject: [PATCH 4/4] Update emailcollector.class.php Hopefully last phpcs fix --- htdocs/emailcollector/class/emailcollector.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index aefea302b23..334e64c9462 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -2652,7 +2652,7 @@ class EmailCollector extends CommonObject $errorforactions++; $this->errors = $actioncomm->errors; } else { - if (($fk_element_type == 'ticket') && (!empty ($attachments))) { + if (($fk_element_type == 'ticket') && (!empty($attachments))) { // There is an attachment for the ticket -> store attachment $ticket = New Ticket($this->db); $ticket->fetch($fk_element_id);