From 5b68f5f9264afc893adafd3f14a5b22f6fc5d451 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Tue, 7 Apr 2015 22:23:28 -0400 Subject: [PATCH] Can now edit and save email templates :grinning: --- admin/manage_email_templates.php | 197 ++++++++++++++++----- css/hesk_newStyle.php | 4 + language/en/emails/html/category_moved.txt | 11 +- language/en/text.php | 21 ++- 4 files changed, 177 insertions(+), 56 deletions(-) diff --git a/admin/manage_email_templates.php b/admin/manage_email_templates.php index e51b95b9..1a5baae2 100644 --- a/admin/manage_email_templates.php +++ b/admin/manage_email_templates.php @@ -16,6 +16,21 @@ hesk_isLoggedIn(); // TODO Check permissions for this feature define('WYSIWYG',1); + +// Are we performing an action? +$showEditPanel = false; +if (isset($_GET['action'])) { + if ($_GET['action'] == 'edit') { + $showEditPanel = true; + } +} + +// Are we saving? +if (isset($_POST['action'])) { + if ($_POST['action'] == 'save') { + save(); + } +} /* Print header */ require_once(HESK_PATH . 'inc/headerAdmin.inc.php'); @@ -78,6 +93,90 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
+ +
+
+
+
+

+ +

+
+
+ + + + + +
+ + + + + +
+ +

'.sprintf($hesklang['email_template_directory_not_writable'], $_GET['template']).'

+
'; + } else { + echo ''; + } + ?> + +
+
+
+
+
- $value): ?> - + $languageCode): ?> + @@ -113,15 +212,17 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); + $languageCode): ?> + @@ -130,13 +231,6 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
- - '; + $markup = ''; $markup .= ''; $markup .= ''; return $markup; } else { - $markup = ''; + $markup = ''; $markup .= ''; $markup .= ''; return $markup; } } -function getModalMarkup($template, $languageCode, $html = false) { +function save() { global $hesklang; - $templateId = str_replace('.', '-', $template); - $templateId = str_replace(' ', '-', $templateId); - $languageCodeId = str_replace('.', '-', $languageCode); - $languageCodeId = str_replace(' ', '-', $languageCodeId); - $id = 'modal-html-'.$languageCodeId.'-'.$templateId; - $class = ''; + $filePath = HESK_PATH . 'language/'.$_POST['language'].'/emails/'.$_POST['template']; + if ($_POST['html'] == '1') { + $filePath = HESK_PATH . 'language/'.$_POST['language'].'/emails/html/'.$_POST['template']; + } - if ($html) { - $title = sprintf($hesklang['editing_html_template'], $template); - $content = file_get_contents(HESK_PATH . 'language/'.$languageCode.'/emails/html/'.$template); - $class = 'htmlEditor'; + $success = file_put_contents($filePath, $_POST['text']); + if ($success === false) { + hesk_process_messages($hesklang[''], 'manage_email_templates.php'); } else { - $id = str_replace('html-', '', $id); - $title = sprintf($hesklang['editing_template'], $template); - $content = file_get_contents(HESK_PATH . 'language/'.$languageCode.'/emails/'.$template); + $message = sprintf($hesklang['email_template_saved'], $_POST['template']); + hesk_process_messages($message,'manage_email_templates.php','SUCCESS'); } - return ' - '; +} + +function getSpecialTagMap() { + global $hesk_settings, $modsForHesk_settings, $hesklang; + + $map = array(); + $map['%%NAME%%'] = $hesklang['customer_name']; + $map['%%EMAIL%%'] = $hesklang['customer_email']; + $map['%%SUBJECT%%'] = $hesklang['ticket_subject']; + $map['%%MESSAGE%%'] = $hesklang['ticket_message']; + $map['%%CREATED%%'] = $hesklang['ticket_created']; + $map['%%UPDATED%%'] = $hesklang['ticket_updated']; + $map['%%TRACK_ID%%'] = $hesklang['ticket_trackID']; + $map['%%TRACK_URL%%'] = $hesklang['ticket_url']; + $map['%%SITE_TITLE%%'] = $hesklang['wbst_title']; + $map['%%SITE_URL%%'] = $hesklang['wbst_url']; + $map['%%CATEGORY%%'] = $hesklang['ticket_category']; + $map['%%OWNER%%'] = $hesklang['ticket_owner']; + $map['%%PRIORITY%%'] = $hesklang['ticket_priority']; + $map['%%STATUS%%'] = $hesklang['ticket_status']; + + $i = 1; + foreach ($hesk_settings['custom_fields'] as $key => $value) { + if ($value['use']) { + $uppercaseKey = strtoupper($key); + $map['%%'.$uppercaseKey.'%%'] = sprintf($hesklang['custom_field_x'], $i++); + } + } + + return $map; } \ No newline at end of file diff --git a/css/hesk_newStyle.php b/css/hesk_newStyle.php index ce577fcc..adda1d59 100644 --- a/css/hesk_newStyle.php +++ b/css/hesk_newStyle.php @@ -390,3 +390,7 @@ button.dropdown-submit { max-width: 80px; cursor: pointer; } + +.plaintext-editor { + font-family: monospace; +} diff --git a/language/en/emails/html/category_moved.txt b/language/en/emails/html/category_moved.txt index a2d87b36..8f254ac9 100644 --- a/language/en/emails/html/category_moved.txt +++ b/language/en/emails/html/category_moved.txt @@ -1,10 +1,7 @@

Hello,

A new support ticket has been moved to your category. Ticket details:

-

Ticket subject: %%SUBJECT%%
-Tracking ID: %%TRACK_ID%%

-

You can manage this ticket here: -%%TRACK_URL%%

-
+

Ticket subject: %%SUBJECT%%
Tracking ID: %%TRACK_ID%%

+

You can manage this ticket here: %%TRACK_URL%%

+

 

Regards,

-%%SITE_TITLE%%
-%%SITE_URL%% \ No newline at end of file +

%%SITE_TITLE%%
%%SITE_URL%%

\ No newline at end of file diff --git a/language/en/text.php b/language/en/text.php index b202aa23..2eb3537b 100644 --- a/language/en/text.php +++ b/language/en/text.php @@ -26,8 +26,27 @@ $hesklang['email_templates'] = 'Email templates'; $hesklang['email_templates_intro'] = 'You can edit your plaintext and HTML email templates here.'; $hesklang['edit_plain_text_template'] = 'Edit plain text template'; $hesklang['edit_html_template'] = 'Edit HTML template'; -$hesklang['editing_template'] = 'Editing plain text template %s'; // %s: The name of the template file (XXXX.txt) +$hesklang['editing_plain_text_template'] = 'Editing plain text template %s'; // %s: The name of the template file (XXXX.txt) $hesklang['editing_html_template'] = 'Editing HTML template %s'; // %s: The name of the template file +$hesklang['show_special_tags'] = 'Show Special Tags'; +$hesklang['hide_special_tags'] = 'Hide Special Tags'; +$hesklang['special_tag'] = 'Special Tag'; +$hesklang['description'] = 'Description'; +$hesklang['customer_name'] = 'Customer name'; +$hesklang['customer_email'] = 'Customer email'; +$hesklang['ticket_subject'] = 'Ticket subject'; +$hesklang['ticket_message'] = 'Ticket/Reply message'; +$hesklang['ticket_created'] = 'Date and time of ticket submission'; +$hesklang['ticket_updated'] = 'Date and time of ticket last update'; +$hesklang['ticket_url'] = 'Ticket URL address'; +$hesklang['ticket_category'] = 'Ticket category'; +$hesklang['ticket_owner'] = 'Staff member assigned to the ticket'; +$hesklang['ticket_priority'] = 'Ticket priority'; +$hesklang['custom_field_x'] = 'Custom field %s'; // %s: Custom field #1-20 +$hesklang['email_template_saved'] = 'The email template %s has been saved.'; // %s: Template file name +$hesklang['error_saving_template'] = 'An error occurred when trying to save the email template!'; +$hesklang['email_template_directory_not_writable'] = 'The email template %s is not writable by HESK. Please CHMOD it to 0666.'; // %s: template file name + // ADDED OR MODIFIED IN Mods for HESK 2.1.1 $hesklang['new_article_default_type'] = 'Default Type for New Articles';