From 3c95faf5c6afd0001351d799c3caffffe7202a7b Mon Sep 17 00:00:00 2001 From: Maximilien Rozniecki Date: Wed, 24 May 2023 10:13:59 +0200 Subject: [PATCH 1/6] New access to msg linked files via public interface --- htdocs/ticket/class/actions_ticket.class.php | 57 ++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php index c566bf54329..53ffbb1024e 100644 --- a/htdocs/ticket/class/actions_ticket.class.php +++ b/htdocs/ticket/class/actions_ticket.class.php @@ -323,6 +323,63 @@ class ActionsTicket print ''; print ''; print $arraymsgs['message']; + + //attachment + + $documents = array(); + + $sql = 'SELECT ecm.rowid as id, ecm.src_object_type, ecm.src_object_id'; + $sql .= ', ecm.filepath, ecm.filename, ecm.share'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'ecm_files ecm'; + $sql .= ' WHERE ecm.filepath = \'agenda/'.$arraymsgs['id'].'\''; + //$sql.= ' ecm.src_object_type = \''.$object->element.'\' AND ecm.src_object_id = '.$object->id; // Actually upload file doesn't add type + $sql .= ' ORDER BY ecm.position ASC'; + + $resql = $this->db->query($sql); + if ($resql) { + if ($this->db->num_rows($resql)) { + while ($obj = $this->db->fetch_object($resql)) { + $documents[$obj->id] = $obj; + } + } + } + if (!empty($documents)) { + $isshared = 0; + $footer = '
'; + foreach ($documents as $doc) { + if (!empty($doc->share)) { + $isshared = 1; + $footer .= 'id.'" '; + $footer .= ' data-path="'.$doc->filepath.'"'; + $footer .= ' data-filename="'.dol_escape_htmltag($doc->filename).'" '; + $footer .= '>'; + + $filePath = DOL_DATA_ROOT.'/'.$doc->filepath.'/'.$doc->filename; + $mime = dol_mimetype($filePath); + $thumb = $arraymsgs['id'].'/thumbs/'.substr($doc->filename, 0, strrpos($doc->filename, '.')).'_mini'.substr($doc->filename, strrpos($doc->filename, '.')); + $doclink = dol_buildpath('document.php', 1)."?hashp=$doc->share"; + + $mimeAttr = ' mime="'.$mime.'" '; + $class = ''; + if (in_array($mime, array('image/png', 'image/jpeg', 'application/pdf'))) { + $class .= ' documentpreview'; + } + + $footer .= ''; + $footer .= img_mime($filePath).' '.$doc->filename; + $footer .= ''; + + $footer .= ''; + } + } + $footer .= '
'; + if ($isshared == 1) { + print '
'; + print '
'; + print $footer; + } + } print ''; print ''; } From f99fc416982759e7b94f025eb17aa7c5d7f685af Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 24 May 2023 13:57:33 +0000 Subject: [PATCH 2/6] Fixing style errors. --- htdocs/ticket/class/actions_ticket.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php index 53ffbb1024e..33f6fa2de61 100644 --- a/htdocs/ticket/class/actions_ticket.class.php +++ b/htdocs/ticket/class/actions_ticket.class.php @@ -327,14 +327,14 @@ class ActionsTicket //attachment $documents = array(); - + $sql = 'SELECT ecm.rowid as id, ecm.src_object_type, ecm.src_object_id'; $sql .= ', ecm.filepath, ecm.filename, ecm.share'; $sql .= ' FROM '.MAIN_DB_PREFIX.'ecm_files ecm'; $sql .= ' WHERE ecm.filepath = \'agenda/'.$arraymsgs['id'].'\''; //$sql.= ' ecm.src_object_type = \''.$object->element.'\' AND ecm.src_object_id = '.$object->id; // Actually upload file doesn't add type $sql .= ' ORDER BY ecm.position ASC'; - + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { From d2d116b6df7957f9446cb2f051bcacb2e3af6fea Mon Sep 17 00:00:00 2001 From: Maximilien Rozniecki Date: Wed, 24 May 2023 16:45:35 +0200 Subject: [PATCH 3/6] Fix travis --- htdocs/ticket/class/actions_ticket.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php index 33f6fa2de61..9547794236e 100644 --- a/htdocs/ticket/class/actions_ticket.class.php +++ b/htdocs/ticket/class/actions_ticket.class.php @@ -332,7 +332,6 @@ class ActionsTicket $sql .= ', ecm.filepath, ecm.filename, ecm.share'; $sql .= ' FROM '.MAIN_DB_PREFIX.'ecm_files ecm'; $sql .= ' WHERE ecm.filepath = \'agenda/'.$arraymsgs['id'].'\''; - //$sql.= ' ecm.src_object_type = \''.$object->element.'\' AND ecm.src_object_id = '.$object->id; // Actually upload file doesn't add type $sql .= ' ORDER BY ecm.position ASC'; $resql = $this->db->query($sql); From 381ddbe799cbc1cd76bb0a6ba2da0a0df83013f7 Mon Sep 17 00:00:00 2001 From: Maximilien Rozniecki Date: Wed, 24 May 2023 17:04:55 +0200 Subject: [PATCH 4/6] Fix travis --- htdocs/ticket/class/actions_ticket.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php index 9547794236e..809f2c3128c 100644 --- a/htdocs/ticket/class/actions_ticket.class.php +++ b/htdocs/ticket/class/actions_ticket.class.php @@ -331,7 +331,7 @@ class ActionsTicket $sql = 'SELECT ecm.rowid as id, ecm.src_object_type, ecm.src_object_id'; $sql .= ', ecm.filepath, ecm.filename, ecm.share'; $sql .= ' FROM '.MAIN_DB_PREFIX.'ecm_files ecm'; - $sql .= ' WHERE ecm.filepath = \'agenda/'.$arraymsgs['id'].'\''; + $sql .= " WHERE ecm.filepath = 'agenda/".$arraymsgs['id']."'"; $sql .= ' ORDER BY ecm.position ASC'; $resql = $this->db->query($sql); From 508aea80891a15cdd29221d53a8157c78a12c0dc Mon Sep 17 00:00:00 2001 From: Maximilien Rozniecki Date: Wed, 24 May 2023 17:14:58 +0200 Subject: [PATCH 5/6] Fix travis --- htdocs/ticket/class/actions_ticket.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php index 809f2c3128c..1ade13d61e6 100644 --- a/htdocs/ticket/class/actions_ticket.class.php +++ b/htdocs/ticket/class/actions_ticket.class.php @@ -374,8 +374,8 @@ class ActionsTicket } $footer .= ''; if ($isshared == 1) { - print '
'; - print '
'; + print '
'; + print '
'; print $footer; } } From 0f448389d18aec72ddf5db17d6c2ff975c7a94e4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Oct 2023 20:40:24 +0200 Subject: [PATCH 6/6] Update actions_ticket.class.php --- htdocs/ticket/class/actions_ticket.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php index 1ade13d61e6..4d157caceca 100644 --- a/htdocs/ticket/class/actions_ticket.class.php +++ b/htdocs/ticket/class/actions_ticket.class.php @@ -357,7 +357,7 @@ class ActionsTicket $filePath = DOL_DATA_ROOT.'/'.$doc->filepath.'/'.$doc->filename; $mime = dol_mimetype($filePath); $thumb = $arraymsgs['id'].'/thumbs/'.substr($doc->filename, 0, strrpos($doc->filename, '.')).'_mini'.substr($doc->filename, strrpos($doc->filename, '.')); - $doclink = dol_buildpath('document.php', 1)."?hashp=$doc->share"; + $doclink = DOL_URL_ROOT.'/document.php?hashp='.urlencode($doc->share); $mimeAttr = ' mime="'.$mime.'" '; $class = '';