diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index f562d36e2a1..5ff93994e73 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -996,7 +996,7 @@ class FormMail extends Form * @param string $type_template Get message for type=$type_template, type='all' also included. * @param string $user Use template public or limited to this user * @param Translate $outputlangs Output lang object - * @param int $id Id of template to find, or -1 for first found with lower position, or 0 for first found whatever is position + * @param int $id Id of template to find, or -1 for first found with position 0, or 0 for first found whatever is position or -2 for exact match with label (no aswer if not found) * @param int $active 1=Only active template, 0=Only disabled, -1=All * @param string $label Label of template * @return ModelMail @@ -1005,6 +1005,12 @@ class FormMail extends Form { $ret = new ModelMail(); + if ($id == -2 && empty($label)) + { + $this->error = 'LabelIsMandatoryWhenIdIs-2'; + return -1; + } + $sql = "SELECT label, topic, joinfiles, content, content_lines, lang"; $sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; $sql.= " WHERE (type_template='".$db->escape($type_template)."' OR type_template='all')"; @@ -1034,8 +1040,11 @@ class FormMail extends Form $ret->content_lines = $obj->content_lines; $ret->joinfiles = $obj->joinfiles; } - else // If there is no template at all - { + elseif($id == -2) { + // Not found with the provided label + return -1; + } + else { // If there is no template at all $defaultmessage=''; if ($type_template=='facture_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendInvoice"); } elseif ($type_template=='facture_relance') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendInvoiceReminder"); } diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 267a869fb46..d0259c2f9cb 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -461,10 +461,11 @@ class MyObject extends CommonObject /** * Action executed by scheduler - * CAN BE A CRON TASK + * CAN BE A CRON TASK. In such a case, paramerts come from the schedule job setup field 'Parameters' * * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) */ + //public function doScheduledJob($param1, $param2, ...) public function doScheduledJob() { global $conf, $langs;