Go to the documentation of this file.
8 require_once(
'../inc/header.inc.php');
12 require_once(CH_DIRECTORY_PATH_INC .
'profiles.inc.php');
13 require_once(CH_DIRECTORY_PATH_INC .
'design.inc.php');
14 require_once(CH_DIRECTORY_PATH_INC .
'admin_design.inc.php');
15 require_once(CH_DIRECTORY_PATH_INC .
'utils.inc.php');
27 if (isset($_POST[
'save']) && isset($_POST[
'cat'])) {
29 } elseif (isset($_POST[
'action']) && $_POST[
'action'] ==
'get_translations') {
30 $aTranslation =
$GLOBALS[
'MySQL']->getRow(
"SELECT `Subject` AS `subject`, `Body` AS `body` FROM `sys_email_templates` WHERE `Name`= ? AND `LangID`= ? LIMIT ?",
31 [$_POST[
'templ_name'], $_POST[
'lang_id'], 1]);
32 if (
empty($aTranslation)) {
33 $aTranslation =
$GLOBALS[
'MySQL']->getRow(
"SELECT `Subject` AS `subject`, `Body` AS `body` FROM `sys_email_templates` WHERE `Name`= ? AND `LangID`= ? LIMIT ?",
34 [$_POST[
'templ_name'], 0, 1]);
37 echo json_encode(array(
'subject' => $aTranslation[
'subject'],
'body' => $aTranslation[
'body']));
44 'css_name' => array(
'forms_adv.css',
'settings.css'),
45 'js_name' => array(
'email_templates.js'),
46 'header' =>
_t(
'_adm_page_cpt_email_templates'),
57 'adm-etempl-btn-list' => array(
58 'href' =>
'javascript:void(0)',
59 'onclick' =>
'javascript:onChangeType(this)',
60 'title' =>
_t(
'_adm_txt_email_list'),
63 'adm-etempl-btn-settings' => array(
64 'href' =>
'javascript:void(0)',
65 'onclick' =>
'javascript:onChangeType(this)',
66 'title' =>
_t(
'_adm_txt_email_settings'),
67 'active' => isset(
$aResults[
'settings']) ? 1 : 0
71 $sResult =
$GLOBALS[
'oAdmTemplate']->parseHtmlByName(
'email_templates.html', array(
82 if ($mixedResult !==
true && !
empty($mixedResult)) {
87 return $GLOBALS[
'oAdmTemplate']->parseHtmlByName(
'email_templates_settings.html', array(
88 'display' => $bActive ?
'block' :
'none',
93 function _getList($mixedResult, $bActive =
false)
96 'form_attrs' => array(
97 'id' =>
'adm-email-templates',
98 'action' =>
$GLOBALS[
'site'][
'url_admin'] .
'email_templates.php',
100 'enctype' =>
'multipart/form-data',
104 'table' =>
'sys_email_templates',
108 'submit_name' =>
'adm-emial-templates-save'
114 $aLanguages =
$GLOBALS[
'MySQL']->getAll(
"SELECT `ID` AS `id`, `Title` AS `title` FROM `sys_localization_languages`");
116 $aLanguageChooser = array(array(
'key' => 0,
'value' =>
'default'));
117 foreach ($aLanguages
as $aLanguage) {
118 $aLanguageChooser[] = array(
'key' => $aLanguage[
'id'],
'value' => $aLanguage[
'title']);
121 $sLanguageCpt =
_t(
'_adm_txt_email_language');
122 $sSubjectCpt =
_t(
'_adm_txt_email_subject');
123 $sBodyCpt =
_t(
'_adm_txt_email_body');
125 $aEmails =
$GLOBALS[
'MySQL']->getAll(
"SELECT `ID` AS `id`, `Name` AS `name`, `Subject` AS `subject`, `Body` AS `body`, `Desc` AS `description` FROM `sys_email_templates` WHERE `LangID`='0' ORDER BY `ID`");
126 foreach ($aEmails
as $aEmail) {
128 $aEmail[
'name'] .
'_Beg' => array(
129 'type' =>
'block_header',
130 'caption' => $aEmail[
'description'],
131 'collapsable' =>
true,
134 $aEmail[
'name'] .
'_Language' => array(
136 'name' => $aEmail[
'name'] .
'_Language',
137 'caption' => $sLanguageCpt,
139 'values' => $aLanguageChooser,
144 'onchange' =>
"javascript:getTranslations(this)"
147 $aEmail[
'name'] .
'_Subject' => array(
149 'name' => $aEmail[
'name'] .
'_Subject',
150 'caption' => $sSubjectCpt,
151 'value' => $aEmail[
'subject'],
156 $aEmail[
'name'] .
'_Body' => array(
157 'type' =>
'textarea',
158 'name' => $aEmail[
'name'] .
'_Body',
159 'caption' => $sBodyCpt,
160 'value' => $aEmail[
'body'],
165 $aEmail[
'name'] .
'_End' => array(
166 'type' =>
'block_end'
171 $aForm[
'inputs'][
'adm-emial-templates-save'] = array(
173 'name' =>
'adm-emial-templates-save',
174 'value' =>
_t(
'_adm_btn_email_save'),
181 if (
$oForm->isSubmittedAndValid()) {
183 foreach ($aEmails
as $aEmail) {
184 $iEmailId = (int)
$GLOBALS[
'MySQL']->getOne(
"SELECT `ID` FROM `sys_email_templates` WHERE `Name`='" .
process_db_input($aEmail[
'name']) .
"' AND `LangID`='" . (int)$_POST[$aEmail[
'name'] .
'_Language'] .
"' LIMIT 1");
185 if ($iEmailId != 0) {
186 $iResult += (int)
$GLOBALS[
'MySQL']->query(
"UPDATE `sys_email_templates` SET `Subject`='" .
process_db_input($_POST[$aEmail[
'name'] .
'_Subject']) .
"', `Body`='" .
process_db_input($_POST[$aEmail[
'name'] .
'_Body']) .
"' WHERE `ID`='" . $iEmailId .
"'");
188 $iResult += (int)
$GLOBALS[
'MySQL']->query(
"INSERT INTO `sys_email_templates` SET `Name`='" .
process_db_input($aEmail[
'name']) .
"', `Subject`='" .
process_db_input($_POST[$aEmail[
'name'] .
'_Subject']) .
"', `Body`='" .
process_db_input($_POST[$aEmail[
'name'] .
'_Body']) .
"', `LangID`='" . (int)$_POST[$aEmail[
'name'] .
'_Language'] .
"'");
193 $sResult .=
MsgBox(
_t($iResult > 0 ?
"_adm_txt_email_success_save" :
"_adm_txt_email_nothing_changed"), 3);
197 return $GLOBALS[
'oAdmTemplate']->parseHtmlByName(
'email_templates_list.html', array(
198 'display' => $bActive ?
'block' :
'none',
199 'content' => stripslashes(
$sResult),
process_db_input($sText, $iStripTags=0)
MsgBox($sText, $iTimer=0)
ch_import($sClassName, $aModule=array())
DesignBoxAdmin($sTitle, $sContent, $mixedTopItems='', $sBottomItems='', $iIndex=1)
_getList($mixedResult, $bActive=false)
PageCodeAdmin($oTemplate=null)
_t($key, $arg0="", $arg1="", $arg2="")
member_auth($member=0, $error_handle=true, $bAjx=false)
_getSettings($mixedResult, $bActive=false)
if(isset($_POST['save']) &&isset($_POST['cat'])) elseif(isset($_POST['action']) && $_POST['action']=='get_translations') $iNameIndex
Attr AllowedRel this is empty