diff --git a/include/ajax.content.php b/include/ajax.content.php index fb5b49540ac4cf4726d7bc310e6e95f47407da4a..25c66e3c389ebd12ff1eae3a62f3eba44402ae4f 100644 --- a/include/ajax.content.php +++ b/include/ajax.content.php @@ -209,13 +209,17 @@ class ContentAjaxAPI extends AjaxController { Http::response(400, '`root` is required parameter'); switch ($_GET['root']) { - case 'thank-you': case 'cannedresponse': $roots = array('ticket'); break; default: - // Get the template for this template + if ($info = Page::getContext($_GET['root'])) { + $roots = $info; + break; + } + + // Get the context for an email template $tpl_info = EmailTemplateGroup::getTemplateDescription($_GET['root']); if (!$tpl_info) Http::response(422, 'No such context'); @@ -223,21 +227,29 @@ class ContentAjaxAPI extends AjaxController { } $contextTypes = array( - 'assignee' => array('class' => 'Staff', 'desc' => 'Newly assigned agent'), - 'assigner' => array('class' => 'Staff', 'desc' => 'Agent performing the assignment'), - 'comments' => 'Agent supplied comments', + 'activity' => __('Type of recent activity'), + 'assignee' => array('class' => 'Staff', 'desc' => __('Assigned agent/team')), + 'assigner' => array('class' => 'Staff', 'desc' => __('Agent performing the assignment')), + 'comments' => __('Assign/transfer comments'), + 'link' => __('Access link'), 'message' => array('class' => 'MessageThreadEntry', 'desc' => 'Message from the EndUser'), - 'note' => array('class' => 'NoteThreadEntry', 'desc' => 'Internal note'), + 'note' => array('class' => 'NoteThreadEntry', 'desc' => __('Internal note')), 'poster' => array('class' => 'User', 'desc' => 'EndUser or Agent originating the message'), + // XXX: This could be EndUser -or- Staff object 'recipient' => array('class' => 'TicketUser', 'desc' => 'Message recipient'), - 'response' => array('class' => 'ResponseThreadEntry', 'desc' => 'Agent reply'), + 'response' => array('class' => 'ResponseThreadEntry', 'desc' => __('Outgoing response')), 'signature' => 'Selected staff or department signature', 'staff' => array('class' => 'Staff', 'desc' => 'Agent originating the activity'), 'ticket' => array('class' => 'Ticket', 'desc' => 'The ticket'), + 'user' => array('class' => 'User', 'desc' => __('Message recipient')), ); $context = array(); - foreach ($roots as $C) { - $context[$C] = $contextTypes[$C]; + foreach ($roots as $C=>$desc) { + // $desc may be either the root or the description array + if (is_array($desc)) + $context[$C] = $desc; + else + $context[$desc] = $contextTypes[$desc]; } $global = osTicket::getVarScope(); $items = VariableReplacer::compileScope($context + $global); diff --git a/include/class.page.php b/include/class.page.php index 1aaa8ce3d8c8e0f934bd95e15f402e58fd74763b..a49a7b263d12632ee662aba4c1288c2bcf4616b9 100644 --- a/include/class.page.php +++ b/include/class.page.php @@ -341,5 +341,34 @@ class Page extends VerySimpleModel { } return true; } + + static function getContext($type) { + $context = array( + 'thank-you' => array('ticket'), + 'registration-staff' => array( + // 'token' => __('Special authentication token'), + 'staff' => array('class' => 'Staff', 'desc' => __('Message recipient')), + 'recipient' => array('class' => 'Staff', 'desc' => __('Message recipient')), + 'link', + ), + 'pwreset-staff' => array( + 'staff' => array('class' => 'Staff', 'desc' => __('Message recipient')), + 'recipient' => array('class' => 'Staff', 'desc' => __('Message recipient')), + 'link', + ), + 'registration-client' => array( + // 'token' => __('Special authentication token'), + 'recipient' => array('class' => 'User', 'desc' => __('Message recipient')), + 'link', 'user', + ), + 'pwreset-client' => array( + 'recipient' => array('class' => 'User', 'desc' => __('Message recipient')), + 'link', 'user', + ), + 'access-link' => array('ticket', 'recipient'), + ); + + return $context[$type]; + } } ?> diff --git a/include/staff/templates/content-manage.tmpl.php b/include/staff/templates/content-manage.tmpl.php index 28a016cb71163b256e32a819b8446b832766a60f..3fa4e8fcbd8c1554649c576d84f3ba74e74e4eca 100644 --- a/include/staff/templates/content-manage.tmpl.php +++ b/include/staff/templates/content-manage.tmpl.php @@ -30,9 +30,10 @@ if (count($langs) > 1) { ?> echo Format::htmlchars($info['title']); ?>" /> <div style="margin-top: 5px"> <div class="error"><?php echo $errors['body']; ?></div> - <textarea class="richtext no-bar" name="body"><?php - echo Format::htmlchars(Format::viewableImages($info['body'])); -?></textarea> + <textarea class="richtext no-bar" name="body" + data-root-context="<?php echo $content->getType(); + ?>"><?php echo Format::htmlchars(Format::viewableImages($info['body'])); + ?></textarea> </div> </div> @@ -48,6 +49,7 @@ if (count($langs) > 1) { ?> placeholder="<?php echo __('Title'); ?>" /> <div style="margin-top: 5px"> <textarea class="richtext no-bar" data-direction=<?php echo $nfo['direction']; ?> + data-root-context="<?php echo $content->getType(); ?>" placeholder="<?php echo __('Message content'); ?>" name="trans[<?php echo $tag; ?>][body]"><?php echo Format::htmlchars(Format::viewableImages($trans['body']));