From 52e2e71b00c8d630c9bbb7bd45823e7c7679e567 Mon Sep 17 00:00:00 2001 From: FLIO Date: Wed, 21 Dec 2022 11:57:07 +0100 Subject: [PATCH 1/3] Fix(scrutinizer) --- htdocs/public/project/new.php | 68 +++++++++++++++++------------------ 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/htdocs/public/project/new.php b/htdocs/public/project/new.php index 7603c046006..62951407fd1 100644 --- a/htdocs/public/project/new.php +++ b/htdocs/public/project/new.php @@ -338,50 +338,50 @@ if (empty($reshook) && $action == 'add') { require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $object = $proj; - if ($object->email) { - $subject = ''; - $msg = ''; + // if ($object->email) { + // $subject = ''; + // $msg = ''; - // Send subscription email - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - // Set output language - $outputlangs = new Translate('', $conf); - $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); - // Load traductions files required by page - $outputlangs->loadLangs(array("main", "members", "projects")); - // Get email content from template - $arraydefaultmessage = null; - $labeltouse = $conf->global->PROJECT_EMAIL_TEMPLATE_AUTOLEAD; + // // Send subscription email + // include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + // $formmail = new FormMail($db); + // // Set output language + // $outputlangs = new Translate('', $conf); + // $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); + // // Load traductions files required by page + // $outputlangs->loadLangs(array("main", "members", "projects")); + // // Get email content from template + // $arraydefaultmessage = null; + // $labeltouse = $conf->global->PROJECT_EMAIL_TEMPLATE_AUTOLEAD; - if (!empty($labeltouse)) { - $arraydefaultmessage = $formmail->getEMailTemplate($db, 'project', $user, $outputlangs, 0, 1, $labeltouse); - } + // if (!empty($labeltouse)) { + // $arraydefaultmessage = $formmail->getEMailTemplate($db, 'project', $user, $outputlangs, 0, 1, $labeltouse); + // } - if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { - $subject = $arraydefaultmessage->topic; - $msg = $arraydefaultmessage->content; - } - if (empty($labeltosue)) { - $labeltouse = '['.$mysoc->name.'] '.$langs->trans("YourMessage"); - $msg = $langs->trans("YourMessageHasBeenReceived"); - } + // if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { + // $subject = $arraydefaultmessage->topic; + // $msg = $arraydefaultmessage->content; + // } + // if (empty($labeltosue)) { + // $labeltouse = '['.$mysoc->name.'] '.$langs->trans("YourMessage"); + // $msg = $langs->trans("YourMessageHasBeenReceived"); + // } - $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); - complete_substitutions_array($substitutionarray, $outputlangs, $object); - $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); - $texttosend = make_substitutions($msg, $substitutionarray, $outputlangs); + // $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + // complete_substitutions_array($substitutionarray, $outputlangs, $object); + // $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); + // $texttosend = make_substitutions($msg, $substitutionarray, $outputlangs); - if ($subjecttosend && $texttosend) { - $moreinheader = 'X-Dolibarr-Info: send_an_email by public/lead/new.php'."\r\n"; + // if ($subjecttosend && $texttosend) { + // $moreinheader = 'X-Dolibarr-Info: send_an_email by public/lead/new.php'."\r\n"; - $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); - } + // $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); + // } /*if ($result < 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); }*/ - } + // } if (!empty($backtopage)) { $urlback = $backtopage; From 4c5bcd02b7e805952e8c5f1ce079432ab9142b14 Mon Sep 17 00:00:00 2001 From: FLIO Date: Wed, 1 Feb 2023 23:31:39 +0100 Subject: [PATCH 2/3] fix (scrutinizer) remove comments and create function send an email TODO --- htdocs/projet/class/project.class.php | 24 +++++++++ htdocs/public/project/new.php | 71 +++++++++++++-------------- 2 files changed, 59 insertions(+), 36 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 79ea13dcd40..b5af4af49d9 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -2313,4 +2313,28 @@ class Project extends CommonObject $this->lines = $taskstatic->getTasksArray(0, $user, $this->id, 0, 0, '', '-1', '', 0, 0, array(), 0, array(), 0, $loadRoleMode); } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Function sending an email to the current member with the text supplied in parameter. + * + * @param string $text Content of message (not html entities encoded) + * @param string $subject Subject of message + * @param array $filename_list Array of attached files + * @param array $mimetype_list Array of mime types of attached files + * @param array $mimefilename_list Array of public names of attached files + * @param string $addr_cc Email cc + * @param string $addr_bcc Email bcc + * @param int $deliveryreceipt Ask a delivery receipt + * @param int $msgishtml 1=String IS already html, 0=String IS NOT html, -1=Unknown need autodetection + * @param string $errors_to erros to + * @param string $moreinheader Add more html headers + * @return int <0 if KO, >0 if OK + */ + public function send_an_email($text, $subject, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array(), $addr_cc = "", $addr_bcc = "", $deliveryreceipt = 0, $msgishtml = -1, $errors_to = '', $moreinheader = '') + { + // phpcs:enable + global $conf, $langs; + // TODO EMAIL + } } diff --git a/htdocs/public/project/new.php b/htdocs/public/project/new.php index dd5424c4f5f..a453e6e0b1e 100644 --- a/htdocs/public/project/new.php +++ b/htdocs/public/project/new.php @@ -334,51 +334,50 @@ if (empty($reshook) && $action == 'add') { if ($result > 0) { require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $object = $proj; + + if ($object->email) { + $subject = ''; + $msg = ''; - // if ($object->email) { - // $subject = ''; - // $msg = ''; + // Send subscription email + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + // Set output language + $outputlangs = new Translate('', $conf); + $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); + // Load traductions files required by page + $outputlangs->loadLangs(array("main", "members", "projects")); + // Get email content from template + $arraydefaultmessage = null; + $labeltouse = $conf->global->PROJECT_EMAIL_TEMPLATE_AUTOLEAD; - // // Send subscription email - // include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - // $formmail = new FormMail($db); - // // Set output language - // $outputlangs = new Translate('', $conf); - // $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); - // // Load traductions files required by page - // $outputlangs->loadLangs(array("main", "members", "projects")); - // // Get email content from template - // $arraydefaultmessage = null; - // $labeltouse = $conf->global->PROJECT_EMAIL_TEMPLATE_AUTOLEAD; + if (!empty($labeltouse)) { + $arraydefaultmessage = $formmail->getEMailTemplate($db, 'project', $user, $outputlangs, 0, 1, $labeltouse); + } - // if (!empty($labeltouse)) { - // $arraydefaultmessage = $formmail->getEMailTemplate($db, 'project', $user, $outputlangs, 0, 1, $labeltouse); - // } + if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { + $subject = $arraydefaultmessage->topic; + $msg = $arraydefaultmessage->content; + } + if (empty($labeltosue)) { + $labeltouse = '['.$mysoc->name.'] '.$langs->trans("YourMessage"); + $msg = $langs->trans("YourMessageHasBeenReceived"); + } - // if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { - // $subject = $arraydefaultmessage->topic; - // $msg = $arraydefaultmessage->content; - // } - // if (empty($labeltosue)) { - // $labeltouse = '['.$mysoc->name.'] '.$langs->trans("YourMessage"); - // $msg = $langs->trans("YourMessageHasBeenReceived"); - // } + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); + $texttosend = make_substitutions($msg, $substitutionarray, $outputlangs); + if ($subjecttosend && $texttosend) { + $moreinheader = 'X-Dolibarr-Info: send_an_email by public/lead/new.php'."\r\n"; - // $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); - // complete_substitutions_array($substitutionarray, $outputlangs, $object); - // $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); - // $texttosend = make_substitutions($msg, $substitutionarray, $outputlangs); - - // if ($subjecttosend && $texttosend) { - // $moreinheader = 'X-Dolibarr-Info: send_an_email by public/lead/new.php'."\r\n"; - - // $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); - // } + $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); + } /*if ($result < 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); }*/ - // } + } if (!empty($backtopage)) { $urlback = $backtopage; From cc0d9b27f2b3dabc65b3088ef8fc648357d9c9bc Mon Sep 17 00:00:00 2001 From: FLIO Date: Wed, 1 Feb 2023 23:31:53 +0100 Subject: [PATCH 3/3] fix (scrutinizer) remove comments and create function send an email TODO --- htdocs/public/project/new.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/project/new.php b/htdocs/public/project/new.php index a453e6e0b1e..726a318c99f 100644 --- a/htdocs/public/project/new.php +++ b/htdocs/public/project/new.php @@ -334,7 +334,7 @@ if (empty($reshook) && $action == 'add') { if ($result > 0) { require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $object = $proj; - + if ($object->email) { $subject = ''; $msg = '';