From c2d38c8a0a9ed0625ecfee4043f3e8120791eff1 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Fri, 30 Jan 2015 00:25:57 -0500 Subject: [PATCH] #126 / #106 Add Mailgun and HTML emails to settings page --- admin/admin_settings.php | 29 ++++++++++++++++++++++++- admin/admin_settings_save.php | 41 +++++++++++++++++++++++++++-------- language/en/text.php | 10 +++++++++ modsForHesk_settings.inc.php | 8 +++---- 4 files changed, 74 insertions(+), 14 deletions(-) diff --git a/admin/admin_settings.php b/admin/admin_settings.php index 9930252c..3a352f31 100644 --- a/admin/admin_settings.php +++ b/admin/admin_settings.php @@ -1343,7 +1343,18 @@ if ( defined('HESK_DEMO') )
-

populate this!

+
+ +
+ +
+
+
+ +
+ +
+
@@ -1983,6 +1994,22 @@ if ( defined('HESK_DEMO') )
+
+ +
+
+ +
+
+
diff --git a/admin/admin_settings_save.php b/admin/admin_settings_save.php index 20520866..dcfb0965 100644 --- a/admin/admin_settings_save.php +++ b/admin/admin_settings_save.php @@ -260,7 +260,16 @@ $set['kb_related'] = intval( hesk_POST('s_kb_related') ); /* --> Email sending */ $smtp_OK = true; -$set['smtp'] = empty($_POST['s_smtp']) ? 0 : 1; +if (empty($_POST['s_smtp'])) { + $set['smtp'] = 0; + $set['use_mailgun'] = 0; +} elseif ($_POST['s_smtp'] === 1) { + $set['smtp'] = 1; + $set['use_mailgun'] = 0; +} else { + $set['smtp'] = 0; + $set['use_mailgun'] = 1; +} if ($set['smtp']) { // Test SMTP connection @@ -274,13 +283,18 @@ if ($set['smtp']) } else { - $set['smtp_host_name'] = hesk_input( hesk_POST('tmp_smtp_host_name', 'mail.domain.com') ); - $set['smtp_host_port'] = intval( hesk_POST('tmp_smtp_host_port', 25) ); - $set['smtp_timeout'] = intval( hesk_POST('tmp_smtp_timeout', 10) ); - $set['smtp_ssl'] = empty($_POST['tmp_smtp_ssl']) ? 0 : 1; - $set['smtp_tls'] = empty($_POST['tmp_smtp_tls']) ? 0 : 1; - $set['smtp_user'] = hesk_input( hesk_POST('tmp_smtp_user') ); - $set['smtp_password'] = hesk_input( hesk_POST('tmp_smtp_password') ); + $set['smtp_host_name'] = hesk_input( hesk_POST('tmp_smtp_host_name', 'mail.domain.com') ); + $set['smtp_host_port'] = intval( hesk_POST('tmp_smtp_host_port', 25) ); + $set['smtp_timeout'] = intval( hesk_POST('tmp_smtp_timeout', 10) ); + $set['smtp_ssl'] = empty($_POST['tmp_smtp_ssl']) ? 0 : 1; + $set['smtp_tls'] = empty($_POST['tmp_smtp_tls']) ? 0 : 1; + $set['smtp_user'] = hesk_input( hesk_POST('tmp_smtp_user') ); + $set['smtp_password'] = hesk_input( hesk_POST('tmp_smtp_password') ); +} + +if ($set['use_mailgun'] == 1) { + $set['mailgun_api_key'] = hesk_input(hesk_POST('mailgun_api_key')); + $set['mailgun_domain'] = hesk_input(hesk_POST('mailgun_domain')); } /* --> Email piping */ @@ -597,6 +611,7 @@ $set['rtl'] = empty($_POST['rtl']) ? 0 : 1; $set['show-icons'] = empty($_POST['show-icons']) ? 0 : 1; $set['custom-field-setting'] = empty($_POST['custom-field-setting']) ? 0 : 1; $set['customer-email-verification-required'] = empty($_POST['email-verification']) ? 0 : 1; +$set['html_emails'] = empty($_POST['html_emails']) ? 0 : 1; if ($set['customer-email-verification-required']) { @@ -639,7 +654,15 @@ $modsForHesk_settings[\'show_icons\'] = '.$set['show-icons'].'; $modsForHesk_settings[\'custom_field_setting\'] = '.$set['custom-field-setting'].'; //-- Set this to 1 to enable email verification for new customers -$modsForHesk_settings[\'customer_email_verification_required\'] = '.$set['customer-email-verification-required'].';'; +$modsForHesk_settings[\'customer_email_verification_required\'] = '.$set['customer-email-verification-required'].'; + +//-- Set this to 1 to enable HTML-formatted emails. +$modsForHesk_settings[\'html_emails\'] = '.$set['html_emails'].'; + +//-- Mailgun Settings +$modsForHesk_settings[\'use_mailgun\'] = '.$set['use_mailgun'].'; +$modsForHesk_settings[\'mailgun_api_key\'] = \''.$set['mailgun_api_key'].'\'; +$modsForHesk_settings[\'mailgun_domain\'] = \''.$set['mailgun_domain'].'\';'; // Write the file if ( ! file_put_contents(HESK_PATH . 'modsForHesk_settings.inc.php', $modsForHesk_file_content) ) diff --git a/language/en/text.php b/language/en/text.php index 7d8bbf7a..94ea32b6 100644 --- a/language/en/text.php +++ b/language/en/text.php @@ -35,6 +35,16 @@ $hesklang['cc'] = 'Cc:'; $hesklang['bcc'] = 'Bcc:'; $hesklang['mailgun'] = 'Mailgun'; $hesklang['mailgun_help'] = 'Send mail using the Mailgun API. For more information on Mailgun, visit https://www.mailgun.com'; +$hesklang['mailgun_api_key'] = 'Mailgun API Key'; +$hesklang['mailgun_api_key_help'] = 'Your API key for Mailgun.'; +$hesklang['mailgun_domain'] = 'Mailgun Domain'; +$hesklang['mailgun_domain_help'] = 'Your registered domain for Mailgun'; +$hesklang['html_emails'] = 'HTML Emails'; +$hesklang['html_emails_help'] = 'Send HTML-supported emails to staff and customers.

To use this feature, create a new folder called html in your + language\'s emails folder and create templates for each email file. Both the HTML and plaintext versions will be sent (recipient\'s email program will + properly display either the HTML or plaintext version, depending on their mail client\'s settings).'; +$hesklang['html_emails_text'] = 'Enable HTML-formatted emails'; +$hesklang['beta_text'] = 'BETA'; // ADDED OR MODIFIED IN Mods For HESK 1.7.0 diff --git a/modsForHesk_settings.inc.php b/modsForHesk_settings.inc.php index 0245a289..a81ecda5 100644 --- a/modsForHesk_settings.inc.php +++ b/modsForHesk_settings.inc.php @@ -26,9 +26,9 @@ $modsForHesk_settings['custom_field_setting'] = 0; $modsForHesk_settings['customer_email_verification_required'] = 0; //-- Set this to 1 to enable HTML-formatted emails. -$modsForHesk_settings['html_emails'] = 0; +$modsForHesk_settings['html_emails'] = 1; //-- Mailgun Settings -$modsForHesk_settings['use_mailgun'] = 0; -$modsForHesk_settings['mailgun_api_key'] = 'API Key'; -$modsForHesk_settings['mailgun_domain'] = 'mail.domain.com'; \ No newline at end of file +$modsForHesk_settings['use_mailgun'] = 1; +$modsForHesk_settings['mailgun_api_key'] = 'KEY'; +$modsForHesk_settings['mailgun_domain'] = 'DOMAIN'; \ No newline at end of file