Browse Source

#126 / #106 Add Mailgun and HTML emails to settings page

merge-requests/2/head
Mike Koch 7 years ago
parent
commit
c2d38c8a0a
  1. 29
      admin/admin_settings.php
  2. 41
      admin/admin_settings_save.php
  3. 10
      language/en/text.php
  4. 8
      modsForHesk_settings.inc.php

29
admin/admin_settings.php

@ -1343,7 +1343,18 @@ if ( defined('HESK_DEMO') )
</div>
</div>
<div id="mailgun_settings" style="display:<?php echo $onload_mailgun; ?>">
<p>populate this!</p>
<div class="form-group">
<label for="mailgun_api_key" class="col-sm-3 control-label"><?php echo $hesklang['mailgun_api_key']; ?> <i class="fa fa-question-circle settingsquestionmark" data-toggle="popover" title="<?php echo $hesklang['mailgun_api_key']; ?>" data-content="<?php echo $hesklang['mailgun_api_key_help']; ?>"></i></label>
<div class="col-sm-9">
<input type="text" class="form-control" placeholder="<?php echo $hesklang['mailgun_api_key']; ?>" id="mailgun_api_key" name="mailgun_api_key" value="<?php echo $modsForHesk_settings['mailgun_api_key']; ?>">
</div>
</div>
<div class="form-group">
<label for="mailgun_domain" class="col-sm-3 control-label"><?php echo $hesklang['mailgun_domain']; ?> <i class="fa fa-question-circle settingsquestionmark" data-toggle="popover" title="<?php echo $hesklang['mailgun_domain']; ?>" data-content="<?php echo $hesklang['mailgun_domain_help']; ?>"></i></label>
<div class="col-sm-9">
<input type="text" class="form-control" placeholder="<?php echo $hesklang['mailgun_domain']; ?>" id="mailgun_domain" name="mailgun_domain" value="<?php echo $modsForHesk_settings['mailgun_domain']; ?>">
</div>
</div>
</div>
<div id="smtp_settings" style="display:<?php echo $onload_div; ?>">
<div class="form-group">
@ -1983,6 +1994,22 @@ if ( defined('HESK_DEMO') )
</div>
</div>
</div>
<div class="form-group">
<label for="html_emails" class="col-sm-4 col-xs-12 control-label">
<span class="label label-warning"><?php echo $hesklang['beta_text']; ?></span>
<?php echo $hesklang['html_emails']; ?>
<i class="fa fa-question-circle settingsquestionmark" data-toggle="htmlpopover"
title="<?php echo $hesklang['html_emails']; ?>"
data-content="<?php echo $hesklang['html_emails_help']; ?>"></i>
</label>
<div class="col-sm-8 col-xs-12">
<div class="checkbox">
<label>
<input id="html_emails" name="html_emails" type="checkbox" <?php if ($modsForHesk_settings['html_emails']) {echo 'checked';} ?>> <?php echo $hesklang['html_emails_text']; ?>
</label>
</div>
</div>
</div>
<div class="blankSpace"></div>
<h6 style="font-weight: bold"><?php echo $hesklang['tab_4']; ?></h6>
<div class="footerWithBorder blankSpace"></div>

41
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) )

10
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.<br><br>To use this feature, create a new folder called <b>html</b> in your
language\'s <b>emails</b> 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

8
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';
$modsForHesk_settings['use_mailgun'] = 1;
$modsForHesk_settings['mailgun_api_key'] = 'KEY';
$modsForHesk_settings['mailgun_domain'] = 'DOMAIN';
Loading…
Cancel
Save