addBreadCrumb(['link' => ADMIN.'email.php'.fusion_get_aidlink(), 'title' => $locale['MAIL_000']]); if (isset($_POST['save_template'])) { $data = [ 'template_id' => form_sanitizer($_POST['template_id'], '', 'template_id'), 'template_key' => form_sanitizer($_POST['template_key'], '', 'template_key'), 'template_format' => form_sanitizer($_POST['template_format'], '', 'template_format'), 'template_subject' => form_sanitizer($_POST['template_subject'], '', 'template_subject'), 'template_content' => form_sanitizer($_POST['template_content'], '', 'template_content'), 'template_active' => form_sanitizer($_POST['template_active'], '', 'template_active'), 'template_sender_name' => form_sanitizer($_POST['template_sender_name'], '', 'template_sender_name'), 'template_sender_email' => form_sanitizer($_POST['template_sender_email'], '', 'template_sender_email'), ]; if (\defender::safe()) { dbquery_insert(DB_EMAIL_TEMPLATES, $data, "update"); addNotice('success', $locale['MAIL_001']); redirect(FUSION_SELF.fusion_get_aidlink()."&template_id=".$data['template_id']); } } else if (isset($_POST['test_template'])) { $data = [ 'template_id' => form_sanitizer($_POST['template_id'], '', 'template_id'), 'template_key' => form_sanitizer($_POST['template_key'], '', 'template_key'), 'template_format' => form_sanitizer($_POST['template_format'], '', 'template_format'), 'template_subject' => form_sanitizer($_POST['template_subject'], '', 'template_subject'), 'template_content' => form_sanitizer($_POST['template_content'], '', 'template_content'), 'template_active' => form_sanitizer($_POST['template_active'], '', 'template_active'), 'template_sender_name' => form_sanitizer($_POST['template_sender_name'], '', 'template_sender_name'), 'template_sender_email' => form_sanitizer($_POST['template_sender_email'], '', 'template_sender_email'), ]; if (\defender::safe()) { require_once INCLUDES."sendmail_include.php"; dbquery_insert(DB_EMAIL_TEMPLATES, $data, 'update'); sendemail_template($data['template_key'], $locale['MAIL_002'], $locale['MAIL_003'], $locale['MAIL_004'], $locale['MAIL_005'], $locale['MAIL_006'], fusion_get_userdata('user_email'), $data['template_sender_name'], $data['template_sender_email']); addNotice('success', sprintf($locale['MAIL_007'], fusion_get_userdata('user_email'))); redirect(FUSION_SELF.fusion_get_aidlink()."&template_id=".$data['template_id']); } } $result = dbquery("SELECT template_id, template_key, template_name, template_language FROM ".DB_EMAIL_TEMPLATES." ".(multilang_table("ET") ? "WHERE template_language='".LANGUAGE."'" : "")." ORDER BY template_id ASC"); $template = []; if (dbrows($result) != 0) { while ($data = dbarray($result)) { $template[$data['template_id']] = $data['template_name']; } } $tab_title = []; foreach ($template as $id => $tname) { $tab_title['title'][$id] = $tname; $tab_title['id'][$id] = $id; $tab_title['icon'][$id] = ''; } $tab_values = array_values($tab_title['id']); $_GET['section'] = isset($_GET['section']) && isnum($_GET['section']) && in_array($_GET['section'], $tab_values) ? $_GET['section'] : $tab_values[0]; opentable($locale['MAIL_000']); echo opentab($tab_title, $_GET['section'], "email-templates-tab", TRUE); echo opentabbody($tab_title['title'][$_GET['section']], $tab_title['id'][$_GET['section']], $_GET['section'], TRUE); $result = dbquery("SELECT * FROM ".DB_EMAIL_TEMPLATES." WHERE template_id=:templateid LIMIT 1", [':templateid' => $_GET['section']]); $html_text = ""; $html_helper = ""; $text_helper = ""; if (dbrows($result)) { $data = dbarray($result); if ($data['template_active']) { if ($data['template_format'] == "html") { $text_helper = "class='display-none'"; $html_text = $locale['MAIL_008']; } else { $html_helper = "class='display-none'"; $html_text = $locale['MAIL_009']; } } else { if ($data['template_format'] == "html") { $html_helper = "class='display-none'"; $html_text = $locale['MAIL_008']; } else { $html_text = $locale['MAIL_009']; } } } echo openform('emailtemplateform', 'post', FUSION_SELF.fusion_get_aidlink(), ['class' => 'm-t-20']); echo form_hidden('template_id', '', $data['template_id']); echo form_hidden('template_key', '', $data['template_key']); echo "
\n"; echo "
\n"; echo form_select('template_active', $locale['MAIL_010'], $data['template_active'], [ 'options' => [$locale['disable'], $locale['enable']], 'placeholder' => $locale['choose'], 'inline' => TRUE ]); echo "
\n"; echo "
\n"; echo "
".sprintf($locale['MAIL_011'], $html_text)."
\n"; echo "
".$locale['MAIL_012']."
\n"; echo "
\n"; echo "
\n"; echo "
\n"; echo "
\n"; echo form_select('template_format', $locale['MAIL_013'], $data['template_format'], [ 'options' => [ 'html' => $locale['MAIL_008'], 'plain' => $locale['MAIL_009'] ], 'inline' => TRUE ]); echo "
\n"; echo "
\n"; echo "
".$locale['MAIL_014']."
\n"; echo "
\n"; echo "
\n"; echo "
\n"; echo "
\n"; echo form_text('template_sender_name', $data['template_key'] == "CONTACT" ? $locale['MAIL_015'] : $locale['MAIL_016'], $data['template_sender_name'], [ 'required' => TRUE, 'error_text' => $locale['MAIL_017'], 'inline' => TRUE, 'class' => 'm-b-0', 'ext_tip' => ($data['template_key'] == "CONTACT" ? '' : $locale['MAIL_018']) ]); echo form_text('template_sender_email', $data['template_key'] == "CONTACT" ? $locale['MAIL_019'] : $locale['MAIL_020'], $data['template_sender_email'], [ 'required' => TRUE, 'error_text' => $locale['MAIL_021'], 'inline' => TRUE, 'class' => 'm-b-0' ]); echo "
\n"; echo "
\n"; openside(""); echo form_button('save_template', $locale['save'], $locale['save'], ['class' => 'btn-primary']); echo form_button('test_template', $locale['MAIL_023'], $locale['MAIL_023'], ['class' => 'btn-default']); echo form_button('reset', $locale['MAIL_024'], $locale['MAIL_024'], ['class' => 'btn-default']); closeside(); echo "
\n"; echo "
\n"; openside(""); echo form_text('template_subject', $locale['MAIL_025'], $data['template_subject'], [ 'required' => TRUE, 'error_text' => $locale['MAIL_026'], 'autosize' => TRUE ]); echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; echo "
\n"; echo "".$locale['MAIL_031'].""; echo "
\n"; echo "
\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n\n"; echo "\n"; echo "\n"; echo "\n\n"; echo "\n"; echo "\n"; echo "\n\n"; echo "\n"; echo "\n"; echo "\n\n"; echo "\n"; echo "\n"; echo "\n\n"; echo "\n"; echo "\n"; echo "\n\n"; echo "\n"; echo "\n"; echo "\n\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n
".$locale['MAIL_032']."".$locale['MAIL_033']."
[SITENAME]".fusion_get_settings('sitename')."
[SITEURL]".fusion_get_settings('siteurl')."
[SUBJECT]".$locale['MAIL_034']."
[MESSAGE]".$locale['MAIL_035']."
[USER]".$locale['MAIL_036']."
[SENDER]".$locale['MAIL_037']."
[RECEIVER]".$locale['MAIL_038']."
[THREAD_URL]".$locale['MAIL_039']."
\n
"; echo "
\n"; closeside(); openside(""); if ($data['template_format'] == "plain") { add_to_head(""); } echo form_textarea('template_content', $locale['MAIL_040'], $data['template_content'], [ 'required' => TRUE, 'error_text' => $locale['MAIL_041'], 'autosize' => TRUE, 'preview' => $data['template_format'] == 'html' ? TRUE : FALSE, 'html' => $data['template_format'] == 'html' ? TRUE : FALSE, 'inputform' => 'emailtemplateform' ]); echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; echo "
\n"; echo "\n"; $folder = BASEDIR."images/"; $image_files = makefilelist($folder, ".|..|index.php", TRUE); $opts = []; foreach ($image_files as $image) { $opts[$image] = $image; } echo form_select('insertimage', '', '', [ 'options' => $opts, 'placeholder' => $locale['MAIL_044'], 'allowclear' => TRUE ]); echo "
\n"; closeside(); echo form_button('save_template', $locale['save'], $locale['save'], ['class' => 'btn-primary']); echo form_button('test_template', $locale['MAIL_023'], $locale['MAIL_023'], ['class' => 'btn-default']); echo form_button('reset', $locale['MAIL_024'], $locale['MAIL_024'], ['class' => 'btn-default']); echo closeform(); echo closetabbody(); echo closetab(); closetable(); $loc = $locale['MAIL_044']; add_to_jquery(" $('#template_active').bind('change', function() { var value = $(this).select2().val(); if (value == 1) { $('#active_info').show(); $('#inactive_info').hide(); } else { $('#active_info').hide(); $('#inactive_info').show(); } }); $('#template_format').bind('change', function() { var value = $(this).select2().val(); if (value == 'plain') { $('#html_info').show(); $('#html_buttons').hide(); } else { $('#html_info').hide(); $('#html_buttons').show(); } }); $('#insertimage').on('change', function(e) { insertText('template_content', '\"\"', 'emailtemplateform'); this.selectedIndex=0; $(this).select2({ formatSelection: color, escapeMarkup: function(m) { return m; }, formatResult: color, placeholder:'$loc', allowClear:true}).val(''); }); "); require_once THEMES.'templates/footer.php';