Skip to content
Snippets Groups Projects
Commit acc58c4b authored by Jared Hancock's avatar Jared Hancock
Browse files

Allow selection of original poster's signature

Also add resend only option (for the case when "Edit and Resend" is not
allowed).
parent 5a85c123
No related branches found
No related tags found
No related merge requests found
...@@ -119,6 +119,11 @@ class ContentAjaxAPI extends AjaxController { ...@@ -119,6 +119,11 @@ class ContentAjaxAPI extends AjaxController {
switch ($type) { switch ($type) {
case 'none': case 'none':
break; break;
case 'agent':
if (!($staff = Staff::lookup($id)))
Http::response(404, 'No such staff member');
echo Format::viewableImages($staff->getSignature());
break;
case 'mine': case 'mine':
echo Format::viewableImages($thisstaff->getSignature()); echo Format::viewableImages($thisstaff->getSignature());
break; break;
......
...@@ -61,7 +61,7 @@ class TEA_EditThreadEntry extends ThreadEntryAction { ...@@ -61,7 +61,7 @@ class TEA_EditThreadEntry extends ThreadEntryAction {
function isVisible() { function isVisible() {
// Can't edit system posts // Can't edit system posts
return ($this->entry->staff_id || $this->entry->user_id) return ($this->entry->staff_id || $this->entry->user_id)
&& $this->entry->type != 'R'; && $this->entry->type != 'R' && $this->isEnabled();
} }
function isEnabled() { function isEnabled() {
...@@ -112,6 +112,8 @@ JS ...@@ -112,6 +112,8 @@ JS
protected function trigger__get() { protected function trigger__get() {
global $cfg, $thisstaff; global $cfg, $thisstaff;
$poster = $this->entry->getStaff();
include STAFFINC_DIR . 'templates/thread-entry-edit.tmpl.php'; include STAFFINC_DIR . 'templates/thread-entry-edit.tmpl.php';
} }
...@@ -227,14 +229,15 @@ class TEA_OrigThreadEntry extends ThreadEntryAction { ...@@ -227,14 +229,15 @@ class TEA_OrigThreadEntry extends ThreadEntryAction {
} }
ThreadEntry::registerAction(/* trans */ 'Manage', 'TEA_OrigThreadEntry'); ThreadEntry::registerAction(/* trans */ 'Manage', 'TEA_OrigThreadEntry');
class TEA_ResendThreadEntry extends TEA_EditThreadEntry { class TEA_EditAndResendThreadEntry extends TEA_EditThreadEntry {
static $id = 'resend'; static $id = 'edit_resend';
static $name = /* trans */ 'Edit and Resend'; static $name = /* trans */ 'Edit and Resend';
static $icon = 'reply-all'; static $icon = 'reply-all';
function isVisible() { function isVisible() {
// Can only resend replies // 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() { protected function trigger__post() {
...@@ -260,9 +263,12 @@ class TEA_ResendThreadEntry extends TEA_EditThreadEntry { ...@@ -260,9 +263,12 @@ class TEA_ResendThreadEntry extends TEA_EditThreadEntry {
$ticket = $response->getThread()->getObject(); $ticket = $response->getThread()->getObject();
$dept = $ticket->getDept(); $dept = $ticket->getDept();
$poster = $response->getStaff();
if ($thisstaff && $vars['signature'] == 'mine') if ($thisstaff && $vars['signature'] == 'mine')
$signature = $thisstaff->getSignature(); $signature = $thisstaff->getSignature();
elseif ($poster && $vars['signature'] == 'theirs')
$signature = $poster->getSignature();
elseif ($vars['signature'] == 'dept' && $dept && $dept->isPublic()) elseif ($vars['signature'] == 'dept' && $dept && $dept->isPublic())
$signature = $dept->getSignature(); $signature = $dept->getSignature();
else else
...@@ -291,4 +297,37 @@ class TEA_ResendThreadEntry extends TEA_EditThreadEntry { ...@@ -291,4 +297,37 @@ class TEA_ResendThreadEntry extends TEA_EditThreadEntry {
$ticket->notifyCollaborators($response, array('signature' => $signature)); $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'); ThreadEntry::registerAction(/* trans */ 'Manage', 'TEA_ResendThreadEntry');
...@@ -9,20 +9,23 @@ ...@@ -9,20 +9,23 @@
echo Format::htmlchars($this->entry->title); ?>"/> echo Format::htmlchars($this->entry->title); ?>"/>
<hr style="height:0"/> <hr style="height:0"/>
<textarea style="display: block; width: 100%; height: auto; min-height: 150px;" <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 = ''; $signature = '';
if (($T = $this->entry->getThread()->getObject()) instanceof Ticket) if (($T = $this->entry->getThread()->getObject()) instanceof Ticket)
$dept = $T->getDept(); $dept = $T->getDept();
switch ($thisstaff->getDefaultSignatureType()) { switch ($poster->getDefaultSignatureType()) {
case 'dept': case 'dept':
if ($dept && $dept->canAppendSignature()) if ($dept && $dept->canAppendSignature())
$signature = $dept->getSignature(); $signature = $dept->getSignature();
break; break;
case 'mine': case 'mine':
$signature = $thisstaff->getSignature(); $signature = $poster->getSignature();
$signature_type = 'theirs';
break; break;
} ?> } ?>
data-dept-id="<?php echo $dept->getId(); ?>" data-dept-id="<?php echo $dept->getId(); ?>"
data-poster-id="<?php echo $this->entry->staff_id; ?>"
data-signature-field="signature" data-signature-field="signature"
data-signature="<?php echo Format::viewableImages($signature); ?>" data-signature="<?php echo Format::viewableImages($signature); ?>"
<?php } ?> <?php } ?>
...@@ -37,6 +40,14 @@ ...@@ -37,6 +40,14 @@
<div style="margin:10px 0;"><strong><?php echo __('Signature'); ?>:</strong> <div style="margin:10px 0;"><strong><?php echo __('Signature'); ?>:</strong>
<label><input type="radio" name="signature" value="none" checked="checked"> <?php echo __('None');?></label> <label><input type="radio" name="signature" value="none" checked="checked"> <?php echo __('None');?></label>
<?php <?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()) {?> if ($thisstaff->getSignature()) {?>
<label><input type="radio" name="signature" value="mine" <label><input type="radio" name="signature" value="mine"
<?php echo ($info['signature']=='mine')?'checked="checked"':''; ?>> <?php echo __('My Signature');?></label> <?php echo ($info['signature']=='mine')?'checked="checked"':''; ?>> <?php echo __('My Signature');?></label>
......
<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>
...@@ -200,6 +200,9 @@ RedactorPlugins.signature = function() { ...@@ -200,6 +200,9 @@ RedactorPlugins.signature = function() {
else else
return inner.empty().parent().hide(); return inner.empty().parent().hide();
} }
else if (selected == 'theirs' && $el.data('posterId')) {
url += 'agent/' + $el.data('posterId');
}
else if (type == 'none') else if (type == 'none')
return inner.empty().parent().hide(); return inner.empty().parent().hide();
else else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment