From d34f487c6521fd2cc90bebd3189fd6461d783ed1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Nov 2019 21:30:00 +0100 Subject: [PATCH] Decode subject by emailcollector --- .../emailcollector/class/emailcollector.class.php | 6 ++++++ htdocs/holiday/class/holiday.class.php | 13 +++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index e71d44cd573..2f6818a7340 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -1122,11 +1122,17 @@ class EmailCollector extends CommonObject $this->db->begin(); + // GET Email meta datas $overview = imap_fetch_overview($connection, $imapemail, 0); dol_syslog("** Process email - msgid=".$overview[0]->message_id." date=".dol_print_date($overview[0]->udate, 'dayrfc', 'gmt')." subject=".$overview[0]->subject); + // Decode $overview[0]->subject + if (function_exists('mb_decode_mimeheader')) { + $overview[0]->subject = mb_decode_mimeheader($overview[0]->subject); + } + // Parse IMAP email structure global $htmlmsg, $plainmsg, $charset, $attachments; $this->getmsg($connection, $imapemail); diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index ec5a22e8afc..e1ba230fe38 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -356,7 +356,7 @@ class Holiday extends CommonObject * * @param int $id Id object * @param string $ref Ref object - * @return int <0 if KO, >0 if OK + * @return int <0 if KO, 0 if not found, >0 if OK */ public function fetch($id, $ref = '') { @@ -421,12 +421,17 @@ class Holiday extends CommonObject $this->fk_user_create = $obj->fk_user_create; $this->fk_type = $obj->fk_type; $this->entity = $obj->entity; + + $this->fetch_optionals(); + + $result = 1; + } + else { + $result = 0; } $this->db->free($resql); - $this->fetch_optionals(); - - return 1; + return $result; } else {