From acc58c4b1fe3084b3a303e2e55e5b0f2f7aec455 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Tue, 24 Mar 2015 16:14:07 -0500 Subject: [PATCH] Allow selection of original poster's signature Also add resend only option (for the case when "Edit and Resend" is not allowed). --- include/ajax.content.php | 5 ++ include/class.thread_actions.php | 47 +++++++++++++++-- .../templates/thread-entry-edit.tmpl.php | 17 +++++-- .../templates/thread-entry-resend.tmpl.php | 50 +++++++++++++++++++ js/redactor-osticket.js | 3 ++ 5 files changed, 115 insertions(+), 7 deletions(-) create mode 100644 include/staff/templates/thread-entry-resend.tmpl.php diff --git a/include/ajax.content.php b/include/ajax.content.php index 9ea0d7d14..dc1bc9ab1 100644 --- a/include/ajax.content.php +++ b/include/ajax.content.php @@ -119,6 +119,11 @@ class ContentAjaxAPI extends AjaxController { switch ($type) { case 'none': break; + case 'agent': + if (!($staff = Staff::lookup($id))) + Http::response(404, 'No such staff member'); + echo Format::viewableImages($staff->getSignature()); + break; case 'mine': echo Format::viewableImages($thisstaff->getSignature()); break; diff --git a/include/class.thread_actions.php b/include/class.thread_actions.php index a228139fb..30ddc810c 100644 --- a/include/class.thread_actions.php +++ b/include/class.thread_actions.php @@ -61,7 +61,7 @@ class TEA_EditThreadEntry extends ThreadEntryAction { function isVisible() { // Can't edit system posts return ($this->entry->staff_id || $this->entry->user_id) - && $this->entry->type != 'R'; + && $this->entry->type != 'R' && $this->isEnabled(); } function isEnabled() { @@ -112,6 +112,8 @@ JS protected function trigger__get() { global $cfg, $thisstaff; + $poster = $this->entry->getStaff(); + include STAFFINC_DIR . 'templates/thread-entry-edit.tmpl.php'; } @@ -227,14 +229,15 @@ class TEA_OrigThreadEntry extends ThreadEntryAction { } ThreadEntry::registerAction(/* trans */ 'Manage', 'TEA_OrigThreadEntry'); -class TEA_ResendThreadEntry extends TEA_EditThreadEntry { - static $id = 'resend'; +class TEA_EditAndResendThreadEntry extends TEA_EditThreadEntry { + static $id = 'edit_resend'; static $name = /* trans */ 'Edit and Resend'; static $icon = 'reply-all'; function isVisible() { // Can only resend replies - return $this->entry->staff_id && $this->entry->type == 'R'; + return $this->entry->staff_id && $this->entry->type == 'R' + && $this->isEnabled(); } protected function trigger__post() { @@ -260,9 +263,12 @@ class TEA_ResendThreadEntry extends TEA_EditThreadEntry { $ticket = $response->getThread()->getObject(); $dept = $ticket->getDept(); + $poster = $response->getStaff(); if ($thisstaff && $vars['signature'] == 'mine') $signature = $thisstaff->getSignature(); + elseif ($poster && $vars['signature'] == 'theirs') + $signature = $poster->getSignature(); elseif ($vars['signature'] == 'dept' && $dept && $dept->isPublic()) $signature = $dept->getSignature(); else @@ -291,4 +297,37 @@ class TEA_ResendThreadEntry extends TEA_EditThreadEntry { $ticket->notifyCollaborators($response, array('signature' => $signature)); } } +ThreadEntry::registerAction(/* trans */ 'Manage', 'TEA_EditAndResendThreadEntry'); + +class TEA_ResendThreadEntry extends TEA_EditAndResendThreadEntry { + static $id = 'resend'; + static $name = /* trans */ 'Resend'; + static $icon = 'reply-all'; + + function isVisible() { + // Can only resend replies + return $this->entry->staff_id && $this->entry->type == 'R' + && !parent::isEnabled(); + } + function isEnabled() { + return true; + } + + protected function trigger__get() { + global $cfg, $thisstaff; + + $poster = $this->entry->getStaff(); + + include STAFFINC_DIR . 'templates/thread-entry-resend.tmpl.php'; + } + + protected function trigger__post() { + $resend = @$_POST['commit'] == 'resend'; + + if (@$_POST['commit'] == 'resend') + $this->resend($this->entry); + + Http::response('201', 'Okee dokey'); + } +} ThreadEntry::registerAction(/* trans */ 'Manage', 'TEA_ResendThreadEntry'); diff --git a/include/staff/templates/thread-entry-edit.tmpl.php b/include/staff/templates/thread-entry-edit.tmpl.php index 3283df770..60dfe5523 100644 --- a/include/staff/templates/thread-entry-edit.tmpl.php +++ b/include/staff/templates/thread-entry-edit.tmpl.php @@ -9,20 +9,23 @@ echo Format::htmlchars($this->entry->title); ?>"/> <hr style="height:0"/> <textarea style="display: block; width: 100%; height: auto; min-height: 150px;" -<?php if ($this->entry->type == 'R') { +<?php if ($poster && $this->entry->type == 'R') { + $signature_type = $poster->getDefaultSignatureType(); $signature = ''; if (($T = $this->entry->getThread()->getObject()) instanceof Ticket) $dept = $T->getDept(); - switch ($thisstaff->getDefaultSignatureType()) { + switch ($poster->getDefaultSignatureType()) { case 'dept': if ($dept && $dept->canAppendSignature()) $signature = $dept->getSignature(); break; case 'mine': - $signature = $thisstaff->getSignature(); + $signature = $poster->getSignature(); + $signature_type = 'theirs'; break; } ?> data-dept-id="<?php echo $dept->getId(); ?>" + data-poster-id="<?php echo $this->entry->staff_id; ?>" data-signature-field="signature" data-signature="<?php echo Format::viewableImages($signature); ?>" <?php } ?> @@ -37,6 +40,14 @@ <div style="margin:10px 0;"><strong><?php echo __('Signature'); ?>:</strong> <label><input type="radio" name="signature" value="none" checked="checked"> <?php echo __('None');?></label> <?php + if ($poster + && $poster->getId() != $thisstaff->getId() + && $poster->getSignature() + ) { ?> + <label><input type="radio" name="signature" value="theirs" + <?php echo ($info['signature']=='theirs')?'checked="checked"':''; ?>> <?php echo __('Their Signature');?></label> + <?php + } if ($thisstaff->getSignature()) {?> <label><input type="radio" name="signature" value="mine" <?php echo ($info['signature']=='mine')?'checked="checked"':''; ?>> <?php echo __('My Signature');?></label> diff --git a/include/staff/templates/thread-entry-resend.tmpl.php b/include/staff/templates/thread-entry-resend.tmpl.php new file mode 100644 index 000000000..8a3e283c6 --- /dev/null +++ b/include/staff/templates/thread-entry-resend.tmpl.php @@ -0,0 +1,50 @@ +<h3><?php echo __('Resend Entry'); ?></h3> +<b><a class="close" href="#"><i class="icon-remove-circle"></i></a></b> +<hr/> + +<form method="post" action="<?php echo $this->getAjaxUrl(true); ?>"> + +<div class="thread-body" style="background-color: transparent; max-height: 150px; width: 100%; overflow: scroll;"> + <?php echo $this->entry->getBody()->toHtml(); ?> +</div> + +<?php if ($this->entry->type == 'R') { ?> +<div style="margin:10px 0;"><strong><?php echo __('Signature'); ?>:</strong> + <label><input type="radio" name="signature" value="none" checked="checked"> <?php echo __('None');?></label> + <?php + if ($poster + && $poster->getId() != $thisstaff->getId() + && $poster->getSignature() + ) { ?> + <label><input type="radio" name="signature" value="theirs" + <?php echo ($info['signature']=='theirs')?'checked="checked"':''; ?>> <?php echo __('Their Signature');?></label> + <?php + } + if ($thisstaff->getSignature()) {?> + <label><input type="radio" name="signature" value="mine" + <?php echo ($info['signature']=='mine')?'checked="checked"':''; ?>> <?php echo __('My Signature');?></label> + <?php + } ?> + <?php + if ($dept && $dept->canAppendSignature()) { ?> + <label><input type="radio" name="signature" value="dept" + <?php echo ($info['signature']=='dept')?'checked="checked"':''; ?>> + <?php echo sprintf(__('Department Signature (%s)'), Format::htmlchars($dept->getName())); ?></label> + <?php + } ?> +</div> +<?php } # end of type == 'R' ?> + +<hr> +<p class="full-width"> + <span class="buttons pull-left"> + <input type="button" name="cancel" class="close" + value="<?php echo __('Cancel'); ?>"> + </span> + <span class="buttons pull-right"> + <input type="submit" name="save" + value="<?php echo __('Resend'); ?>"> + </span> +</p> + +</form> diff --git a/js/redactor-osticket.js b/js/redactor-osticket.js index 5184801e6..203c39894 100644 --- a/js/redactor-osticket.js +++ b/js/redactor-osticket.js @@ -200,6 +200,9 @@ RedactorPlugins.signature = function() { else return inner.empty().parent().hide(); } + else if (selected == 'theirs' && $el.data('posterId')) { + url += 'agent/' + $el.data('posterId'); + } else if (type == 'none') return inner.empty().parent().hide(); else -- GitLab