add EmailAccounts.add; added wrapper function ApiCommand.getMailTemplate() to reduce code-duplication

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2018-03-12 13:44:44 +01:00
parent 2e597ef7d9
commit 6fc8cce8f5
6 changed files with 74 additions and 284 deletions

View File

@@ -189,36 +189,11 @@ class Ftps extends ApiCommand implements ResourceEntity
'USR_PASS' => $password,
'USR_PATH' => makeCorrectDir(str_replace($customer['documentroot'], "/", $path))
);
$def_language = $customer['def_language'];
$result_stmt = Database::prepare("
SELECT `value` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid
AND `language` = :lang
AND `templategroup`='mails'
AND `varname`='new_ftpaccount_by_customer_subject'
");
Database::pexecute($result_stmt, array(
"adminid" => $customer['adminid'],
"lang" => $def_language
));
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
$mail_subject = html_entity_decode(replace_variables((($result['value'] != '') ? $result['value'] : $this->lng['mails']['new_ftpaccount_by_customer']['subject']), $replace_arr));
$def_language = $customer['def_language'];
$result_stmt = Database::prepare("
SELECT `value` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid
AND `language` = :lang
AND `templategroup`='mails'
AND `varname`='new_ftpaccount_by_customer_mailbody'");
Database::pexecute($result_stmt, array(
"adminid" => $customer['adminid'],
"lang" => $def_language
));
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
$mail_body = html_entity_decode(replace_variables((($result['value'] != '') ? $result['value'] : $this->lng['mails']['new_ftpaccount_by_customer']['mailbody']), $replace_arr));
// get template for mail subject
$mail_subject = $this->getMailTemplate($customer, 'mails', 'new_ftpaccount_by_customer_subject', $replace_arr, $this->lng['mails']['new_ftpaccount_by_customer']['subject']);
// get template for mail body
$mail_body = $this->getMailTemplate($customer, 'mails', 'new_ftpaccount_by_customer_mailbody', $replace_arr, $this->lng['mails']['new_ftpaccount_by_customer']['mailbody']);
$_mailerror = false;
try {
$this->mailer()->Subject = $mail_subject;