diff --git a/admin/banned_emails.php b/admin/banned_emails.php index 2151160d..9599d650 100644 --- a/admin/banned_emails.php +++ b/admin/banned_emails.php @@ -89,6 +89,15 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); ' . $hesklang['sm_title'] . ' '; } + + // Show a link to email tpl management if user has permission to do so + if (hesk_checkPermission('can_man_email_tpl', 0)) { + echo ' +
  • + '.$hesklang['email_templates'].' +
  • + '; + } ?>
    diff --git a/admin/banned_ips.php b/admin/banned_ips.php index e4599c36..1edc5672 100644 --- a/admin/banned_ips.php +++ b/admin/banned_ips.php @@ -92,6 +92,15 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); ' . $hesklang['sm_title'] . ' '; } + + // Show a link to email tpl management if user has permission to do so + if (hesk_checkPermission('can_man_email_tpl', 0)) { + echo ' +
  • + '.$hesklang['email_templates'].' +
  • + '; + } ?>
    diff --git a/admin/manage_email_templates.php b/admin/manage_email_templates.php new file mode 100644 index 00000000..4ba41202 --- /dev/null +++ b/admin/manage_email_templates.php @@ -0,0 +1,302 @@ + + tinyMCE.init({ + mode : "textareas", + editor_selector : "htmlEditor", + elements : "content", + theme : "advanced", + convert_urls : false, + gecko_spellcheck: true, + + theme_advanced_buttons1 : "cut,copy,paste,|,undo,redo,|,formatselect,fontselect,fontsizeselect,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull", + theme_advanced_buttons2 : "sub,sup,|,charmap,|,bullist,numlist,|,outdent,indent,insertdate,inserttime,preview,|,forecolor,backcolor,|,hr,removeformat,visualaid,|,link,unlink,anchor,image,cleanup,code", + theme_advanced_buttons3 : "", + + theme_advanced_toolbar_location : "top", + theme_advanced_toolbar_align : "left", + theme_advanced_statusbar_location : "bottom", + theme_advanced_resizing : true + }); + '; +} + +/* Print main manage users page */ +require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); +?> + +
    + +
    + +
    +
    +
    +
    +

    + +

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

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

    +
    '; + } else { + echo ''; + } + ?> + +
    +
    +
    +
    + +
    +
    + $value) { + $languages[$key] = $hesk_settings['languages'][$key]['folder']; + } + + // Get all files, but don't worry about index.htm, items beginning with '.', or the html folder + // We'll also assume the template file exists in all language folders and in the html folder + reset($languages); + $firstKey = key($languages); + $firstDirectory = HESK_PATH . 'language/'.$languages[$firstKey].'/emails'; + $directoryListing = preg_grep('/^([^.])/', scandir($firstDirectory)); + $emailTemplates = array_diff($directoryListing, array('html', 'index.htm')); + + ?> + + + + + $languageCode): ?> + + + + + + + + + $languageCode): ?> + + + + + +
    + +
    +
    +
    +
    +
    + +'; + $markup .= ''; + $markup .= ''; + return $markup; + } else { + $markup = ''; + $markup .= ''; + $markup .= ''; + return $markup; + } +} + +function save() { + global $hesklang; + + $filePath = HESK_PATH . 'language/'.$_POST['language'].'/emails/'.$_POST['template']; + if ($_POST['html'] == '1') { + $filePath = HESK_PATH . 'language/'.$_POST['language'].'/emails/html/'.$_POST['template']; + } + + $success = file_put_contents($filePath, $_POST['text']); + if ($success === false) { + hesk_process_messages($hesklang[''], 'manage_email_templates.php'); + } else { + $message = sprintf($hesklang['email_template_saved'], $_POST['template']); + hesk_process_messages($message,'manage_email_templates.php','SUCCESS'); + } +} + +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/admin/manage_users.php b/admin/manage_users.php index 6245a89b..c03e84af 100644 --- a/admin/manage_users.php +++ b/admin/manage_users.php @@ -77,6 +77,7 @@ $hesk_settings['features'] = array( 'can_ban_ips', /* User can ban IP addresses */ 'can_unban_ips', /* User can delete IP bans. Also enables "can_ban_ips" */ 'can_service_msg', /* User can manage service messages shown in customer interface */ +'can_man_email_tpl', /* User can manage email templates */ ); /* Set default values */ diff --git a/admin/service_messages.php b/admin/service_messages.php index df4f374a..30d5155e 100644 --- a/admin/service_messages.php +++ b/admin/service_messages.php @@ -92,6 +92,16 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); + + '.$hesklang['email_templates'].' + + '; + } + ?>