|
@@ -1250,7 +1250,7 @@ class FormMail extends Form
|
|
|
* Return templates of email with type = $type_template or type = 'all'.
|
|
|
* This search into table c_email_templates. Used by the get_form function.
|
|
|
*
|
|
|
- * @param DoliDB $db Database handler
|
|
|
+ * @param DoliDB $dbs Database handler
|
|
|
* @param string $type_template Get message for model/type=$type_template, type='all' also included.
|
|
|
* @param User $user Get template public or limited to this user
|
|
|
* @param Translate $outputlangs Output lang object
|
|
@@ -1259,7 +1259,7 @@ class FormMail extends Form
|
|
|
* @param string $label Label of template
|
|
|
* @return ModelMail|integer One instance of ModelMail or -1 if error
|
|
|
*/
|
|
|
- public function getEMailTemplate($db, $type_template, $user, $outputlangs, $id = 0, $active = 1, $label = '')
|
|
|
+ public function getEMailTemplate($dbs, $type_template, $user, $outputlangs, $id = 0, $active = 1, $label = '')
|
|
|
{
|
|
|
global $conf, $langs;
|
|
|
|
|
@@ -1279,18 +1279,18 @@ class FormMail extends Form
|
|
|
}
|
|
|
|
|
|
$sql = "SELECT rowid, module, label, type_template, topic, joinfiles, content, content_lines, lang";
|
|
|
- $sql .= " FROM ".$db->prefix().'c_email_templates';
|
|
|
- $sql .= " WHERE (type_template='".$db->escape($type_template)."' OR type_template='all')";
|
|
|
+ $sql .= " FROM ".$dbs->prefix().'c_email_templates';
|
|
|
+ $sql .= " WHERE (type_template='".$dbs->escape($type_template)."' OR type_template='all')";
|
|
|
$sql .= " AND entity IN (".getEntity('c_email_templates').")";
|
|
|
$sql .= " AND (private = 0 OR fk_user = ".((int) $user->id).")"; // Get all public or private owned
|
|
|
if ($active >= 0) {
|
|
|
$sql .= " AND active = ".((int) $active);
|
|
|
}
|
|
|
if ($label) {
|
|
|
- $sql .= " AND label = '".$db->escape($label)."'";
|
|
|
+ $sql .= " AND label = '".$dbs->escape($label)."'";
|
|
|
}
|
|
|
if (!($id > 0) && $languagetosearch) {
|
|
|
- $sql .= " AND (lang = '".$db->escape($languagetosearch)."'".($languagetosearchmain ? " OR lang = '".$db->escape($languagetosearchmain)."'" : "")." OR lang IS NULL OR lang = '')";
|
|
|
+ $sql .= " AND (lang = '".$dbs->escape($languagetosearch)."'".($languagetosearchmain ? " OR lang = '".$dbs->escape($languagetosearchmain)."'" : "")." OR lang IS NULL OR lang = '')";
|
|
|
}
|
|
|
if ($id > 0) {
|
|
|
$sql .= " AND rowid=".(int) $id;
|
|
@@ -1299,22 +1299,22 @@ class FormMail extends Form
|
|
|
$sql .= " AND position=0";
|
|
|
}
|
|
|
if ($languagetosearch) {
|
|
|
- $sql .= $db->order("position,lang,label", "ASC,DESC,ASC"); // We want line with lang set first, then with lang null or ''
|
|
|
+ $sql .= $dbs->order("position,lang,label", "ASC,DESC,ASC"); // We want line with lang set first, then with lang null or ''
|
|
|
} else {
|
|
|
- $sql .= $db->order("position,lang,label", "ASC,ASC,ASC"); // If no language provided, we give priority to lang not defined
|
|
|
+ $sql .= $dbs->order("position,lang,label", "ASC,ASC,ASC"); // If no language provided, we give priority to lang not defined
|
|
|
}
|
|
|
- //$sql .= $db->plimit(1);
|
|
|
+ //$sql .= $dbs->plimit(1);
|
|
|
//print $sql;
|
|
|
|
|
|
- $resql = $db->query($sql);
|
|
|
+ $resql = $dbs->query($sql);
|
|
|
if (!$resql) {
|
|
|
- dol_print_error($db);
|
|
|
+ dol_print_error($dbs);
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
// Get first found
|
|
|
while (1) {
|
|
|
- $obj = $db->fetch_object($resql);
|
|
|
+ $obj = $dbs->fetch_object($resql);
|
|
|
|
|
|
if ($obj) {
|
|
|
// If template is for a module, check module is enabled; if not, take next template
|
|
@@ -1386,7 +1386,8 @@ class FormMail extends Form
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- $db->free($resql);
|
|
|
+ $dbs->free($resql);
|
|
|
+
|
|
|
return $ret;
|
|
|
}
|
|
|
|