From 7195af1bdf4ca21f4db04c2539d09bc8c4dabf5c Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 11 Dec 2024 11:05:15 +0100 Subject: [PATCH 1/4] new: if default template for ticket existe we use it avec if there is email template 'all' --- htdocs/core/class/html.formticket.class.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 348fe8a81e0..59a0f22feb6 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -1497,7 +1497,11 @@ class FormTicket $model_id = (int) $this->param["models_id"]; } - $arraydefaultmessage = $formmail->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id); // If $model_id is empty, preselect the first one + $arraydefaultmessage = $formmail->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id, 1, '', 1); // If $model_id is empty, preselect the first one + if (isset($arraydefaultmessage->id) && empty($model_id)) { + $model_id = $arraydefaultmessage->id; + $this->param['models_id']=$model_id; + } } // Define list of attached files @@ -1608,13 +1612,6 @@ class FormTicket print ''; } - // Get message template - $model_id = 0; - if (array_key_exists('models_id', $this->param)) { - $model_id = $this->param["models_id"]; - $arraydefaultmessage = $formmail->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id); - } - $result = $formmail->fetchAllEMailTemplate(!empty($this->param["models"]) ? $this->param["models"] : "", $user, $outputlangs); if ($result < 0) { setEventMessages($this->error, $this->errors, 'errors'); From 5097572c5d8c4fb900cdf5dbeaef036a02d3a491 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 16 Dec 2024 19:07:03 +0100 Subject: [PATCH 2/4] chore: review --- htdocs/core/class/html.formticket.class.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 59a0f22feb6..80370cd324e 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -1497,7 +1497,8 @@ class FormTicket $model_id = (int) $this->param["models_id"]; } - $arraydefaultmessage = $formmail->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id, 1, '', 1); // If $model_id is empty, preselect the first one + // If $model_id is empty, preselect the first one + $arraydefaultmessage = $formmail->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id, 1, '', 1); if (isset($arraydefaultmessage->id) && empty($model_id)) { $model_id = $arraydefaultmessage->id; $this->param['models_id']=$model_id; @@ -1612,6 +1613,12 @@ class FormTicket print ''; } + // Get message template + $model_id = 0; + if (array_key_exists('models_id', $this->param)) { + $model_id = $this->param["models_id"]; + $arraydefaultmessage = $formmail->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id, 1, '', 1); + } $result = $formmail->fetchAllEMailTemplate(!empty($this->param["models"]) ? $this->param["models"] : "", $user, $outputlangs); if ($result < 0) { setEventMessages($this->error, $this->errors, 'errors'); From 1635a430d73913f116ea4e4824dd0190ba8e6695 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 16 Dec 2024 19:37:40 +0100 Subject: [PATCH 3/4] chore: phan rename param to avoid PhanPluginSuspiciousParamOrder: Suspicious order for arguments named tooltip and name - These are being passed to parameters #2 (string htmltext) and #8 (string tooltiptrigger) --- htdocs/core/class/html.form.class.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 61763c5af9a..5fd3f2450a7 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -743,11 +743,11 @@ class Form * @param string $extracss Add a CSS style to td, div or span tag * @param int $noencodehtmltext Do not encode into html entity the htmltext * @param int $notabs 0=Include table and tr tags, 1=Do not include table and tr tags, 2=use div, 3=use span - * @param string $tooltiptrigger ''=Tooltip on hover and hidden on smartphone, 'abconsmartphone'=Tooltip on hover and on click on smartphone, 'abc'=Tooltip on click (abc is a unique key, clickable link is on image or on link if param $type='none' or on both if $type='xxxclickable') + * @param string $triggerfortooltip ''=Tooltip on hover and hidden on smartphone, 'abconsmartphone'=Tooltip on hover and on click on smartphone, 'abc'=Tooltip on click (abc is a unique key, clickable link is on image or on link if param $type='none' or on both if $type='xxxclickable') * @param int $forcenowrap Force no wrap between text and picto (works with notabs=2 only) * @return string HTML code of text, picto, tooltip */ - public function textwithpicto($text, $htmltext, $direction = 1, $type = 'help', $extracss = 'valignmiddle', $noencodehtmltext = 0, $notabs = 3, $tooltiptrigger = '', $forcenowrap = 0) + public function textwithpicto($text, $htmltext, $direction = 1, $type = 'help', $extracss = 'valignmiddle', $noencodehtmltext = 0, $notabs = 3, $triggerfortooltip = '', $forcenowrap = 0) { global $conf, $langs; @@ -758,13 +758,13 @@ class Form $type = 'help'; } // Clean parameters - $tooltiptrigger = preg_replace('/[^a-z0-9]/i', '', $tooltiptrigger); + $triggerfortooltip = preg_replace('/[^a-z0-9]/i', '', $triggerfortooltip); - if (preg_match('/onsmartphone$/', $tooltiptrigger) && empty($conf->dol_no_mouse_hover)) { - $tooltiptrigger = preg_replace('/^.*onsmartphone$/', '', $tooltiptrigger); + if (preg_match('/onsmartphone$/', $triggerfortooltip) && empty($conf->dol_no_mouse_hover)) { + $triggerfortooltip = preg_replace('/^.*onsmartphone$/', '', $triggerfortooltip); } $alt = ''; - if ($tooltiptrigger) { + if ($triggerfortooltip) { $alt = $langs->transnoentitiesnoconv("ClickToShowHelp"); } @@ -779,13 +779,13 @@ class Form } // If info or help with smartphone, show only text (tooltip hover can't works) - if (!empty($conf->dol_no_mouse_hover) && empty($tooltiptrigger)) { + if (!empty($conf->dol_no_mouse_hover) && empty($triggerfortooltip)) { if ($type == 'info' || $type == 'infoclickable' || $type == 'help' || $type == 'helpclickable') { return $text; } } // If info or help with smartphone, show only text (tooltip on click does not works with dialog on smaprtphone) - //if (!empty($conf->dol_no_mouse_hover) && !empty($tooltiptrigger)) + //if (!empty($conf->dol_no_mouse_hover) && !empty($triggerfortooltip)) //{ //if ($type == 'info' || $type == 'help') return ''.$text.''; //} @@ -794,9 +794,9 @@ class Form if ($type == 'info') { $img = img_help(0, $alt); } elseif ($type == 'help') { - $img = img_help(($tooltiptrigger != '' ? 2 : 1), $alt); + $img = img_help(($triggerfortooltip != '' ? 2 : 1), $alt); } elseif ($type == 'helpclickable') { - $img = img_help(($tooltiptrigger != '' ? 2 : 1), $alt); + $img = img_help(($triggerfortooltip != '' ? 2 : 1), $alt); } elseif ($type == 'superadmin') { // @phan-suppress-next-line PhanPluginSuspiciousParamPosition $img = img_picto($alt, 'redstar'); @@ -810,7 +810,7 @@ class Form $img = img_picto($alt, $type); // $type can be an image path } - return $this->textwithtooltip($text, $htmltext, ((($tooltiptrigger && !$img) || strpos($type, 'clickable')) ? 3 : 2), $direction, $img, $extracss, $notabs, '', $noencodehtmltext, $tooltiptrigger, $forcenowrap); + return $this->textwithtooltip($text, $htmltext, ((($triggerfortooltip && !$img) || strpos($type, 'clickable')) ? 3 : 2), $direction, $img, $extracss, $notabs, '', $noencodehtmltext, $triggerfortooltip, $forcenowrap); } /** From d7184adb3ba8a3a40a0e6a7aa183b093dcb45f6d Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 16 Dec 2024 19:40:35 +0100 Subject: [PATCH 4/4] chore: revert phan warning fix --- htdocs/core/class/html.form.class.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 8b31f6cc957..a291083bf62 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -743,11 +743,11 @@ class Form * @param string $extracss Add a CSS style to td, div or span tag * @param int $noencodehtmltext Do not encode into html entity the htmltext * @param int $notabs 0=Include table and tr tags, 1=Do not include table and tr tags, 2=use div, 3=use span - * @param string $triggerfortooltip ''=Tooltip on hover and hidden on smartphone, 'abconsmartphone'=Tooltip on hover and on click on smartphone, 'abc'=Tooltip on click (abc is a unique key, clickable link is on image or on link if param $type='none' or on both if $type='xxxclickable') + * @param string $tooltiptrigger ''=Tooltip on hover and hidden on smartphone, 'abconsmartphone'=Tooltip on hover and on click on smartphone, 'abc'=Tooltip on click (abc is a unique key, clickable link is on image or on link if param $type='none' or on both if $type='xxxclickable') * @param int $forcenowrap Force no wrap between text and picto (works with notabs=2 only) * @return string HTML code of text, picto, tooltip */ - public function textwithpicto($text, $htmltext, $direction = 1, $type = 'help', $extracss = 'valignmiddle', $noencodehtmltext = 0, $notabs = 3, $triggerfortooltip = '', $forcenowrap = 0) + public function textwithpicto($text, $htmltext, $direction = 1, $type = 'help', $extracss = 'valignmiddle', $noencodehtmltext = 0, $notabs = 3, $tooltiptrigger = '', $forcenowrap = 0) { global $conf, $langs; @@ -758,13 +758,13 @@ class Form $type = 'help'; } // Clean parameters - $triggerfortooltip = preg_replace('/[^a-z0-9]/i', '', $triggerfortooltip); + $tooltiptrigger = preg_replace('/[^a-z0-9]/i', '', $tooltiptrigger); - if (preg_match('/onsmartphone$/', $triggerfortooltip) && empty($conf->dol_no_mouse_hover)) { - $triggerfortooltip = preg_replace('/^.*onsmartphone$/', '', $triggerfortooltip); + if (preg_match('/onsmartphone$/', $tooltiptrigger) && empty($conf->dol_no_mouse_hover)) { + $tooltiptrigger = preg_replace('/^.*onsmartphone$/', '', $tooltiptrigger); } $alt = ''; - if ($triggerfortooltip) { + if ($tooltiptrigger) { $alt = $langs->transnoentitiesnoconv("ClickToShowHelp"); } @@ -779,13 +779,13 @@ class Form } // If info or help with smartphone, show only text (tooltip hover can't works) - if (!empty($conf->dol_no_mouse_hover) && empty($triggerfortooltip)) { + if (!empty($conf->dol_no_mouse_hover) && empty($tooltiptrigger)) { if ($type == 'info' || $type == 'infoclickable' || $type == 'help' || $type == 'helpclickable') { return $text; } } // If info or help with smartphone, show only text (tooltip on click does not works with dialog on smaprtphone) - //if (!empty($conf->dol_no_mouse_hover) && !empty($triggerfortooltip)) + //if (!empty($conf->dol_no_mouse_hover) && !empty($tooltiptrigger)) //{ //if ($type == 'info' || $type == 'help') return ''.$text.''; //} @@ -794,9 +794,9 @@ class Form if ($type == 'info') { $img = img_help(0, $alt); } elseif ($type == 'help') { - $img = img_help(($triggerfortooltip != '' ? 2 : 1), $alt); + $img = img_help(($tooltiptrigger != '' ? 2 : 1), $alt); } elseif ($type == 'helpclickable') { - $img = img_help(($triggerfortooltip != '' ? 2 : 1), $alt); + $img = img_help(($tooltiptrigger != '' ? 2 : 1), $alt); } elseif ($type == 'superadmin') { // @phan-suppress-next-line PhanPluginSuspiciousParamPosition $img = img_picto($alt, 'redstar'); @@ -810,7 +810,7 @@ class Form $img = img_picto($alt, $type); // $type can be an image path } - return $this->textwithtooltip($text, $htmltext, ((($triggerfortooltip && !$img) || strpos($type, 'clickable')) ? 3 : 2), $direction, $img, $extracss, $notabs, '', $noencodehtmltext, $triggerfortooltip, $forcenowrap); + return $this->textwithtooltip($text, $htmltext, ((($tooltiptrigger && !$img) || strpos($type, 'clickable')) ? 3 : 2), $direction, $img, $extracss, $notabs, '', $noencodehtmltext, $tooltiptrigger, $forcenowrap); } /**