Skip to content

Commit

Permalink
Better template
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Mar 16, 2018
1 parent 2bbf738 commit e323084
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
15 changes: 12 additions & 3 deletions htdocs/core/class/html.formmail.class.php
Expand Up @@ -996,7 +996,7 @@ function get_form($addfileaction='addfile',$removefileaction='removefile')
* @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
Expand All @@ -1005,6 +1005,12 @@ public function getEMailTemplate($db, $type_template, $user, $outputlangs, $id=0
{
$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')";
Expand Down Expand Up @@ -1034,8 +1040,11 @@ public function getEMailTemplate($db, $type_template, $user, $outputlangs, $id=0
$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"); }
Expand Down
3 changes: 2 additions & 1 deletion htdocs/modulebuilder/template/class/myobject.class.php
Expand Up @@ -461,10 +461,11 @@ public function initAsSpecimen()

/**
* 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;
Expand Down

0 comments on commit e323084

Please sign in to comment.