diff --git a/include/class.ticket.php b/include/class.ticket.php index f451de786c52c8b59ac520e8e4df7996d4fbb696..daa241d914ec7b70181d365ca2b5b7a87903b6fa 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -864,12 +864,15 @@ class Ticket { case 'open': // TODO: check current status if it allows for reopening if ($this->isClosed()) { - $sql.= ',closed=NULL, reopened=NOW() '; - + $sql .= ',closed=NULL, reopened=NOW() '; $ecb = function ($t) { $t->logEvent('reopened', 'closed'); }; } + + // If the ticket is not open then clear answered flag + if (!$this->isOpen()) + $sql .= ', isanswered = 0 '; break; default: return false; diff --git a/include/staff/templates/status-options.tmpl.php b/include/staff/templates/status-options.tmpl.php index 5fc39f32ad99c9f6c52b129291545a8f8d7f336d..ebc5db6cb1fe6692ee0e07835cf5936da24691de 100644 --- a/include/staff/templates/status-options.tmpl.php +++ b/include/staff/templates/status-options.tmpl.php @@ -1,24 +1,21 @@ <?php $actions= array( 'close' => array( - 'action' => __('Close'), 'icon' => 'icon-repeat', - 'states' => array('closed') + 'state' => 'closed' ), 'resolve' => array( - 'action' => __('Resolve'), 'icon' => 'icon-ok-circle', - 'states' => array('resolved') + 'state' => 'resolved' ), 'reopen' => array( - 'action' => __('Reopen'), 'icon' => 'icon-undo', - 'states' => array('open') + 'state' => 'open' ), ); foreach($actions as $k => $v) { - $criteria = array('states' => $v['states']); + $criteria = array('states' => array($v['state'])); if (!($statuses = TicketStatusList::getStatuses($criteria)->all())) continue; @@ -30,7 +27,8 @@ foreach($actions as $k => $v) { <a id="tickets-<?php echo $k; ?>" class="tickets-action" href="#tickets/status/<?php echo $k; ?>"><i - class="<?php echo $v['icon']; ?>"></i> <?php echo $v['action']; ?></a> + class="<?php echo $v['icon']; ?>"></i> <?php + echo TicketStateField::getVerb($v['state']); ?></a> <i class="icon-caret-down"></i> </span> <div id="action-dropdown-<?php echo $k; ?>" @@ -54,7 +52,8 @@ foreach($actions as $k => $v) { ?> <a id="tickets-<?php echo $k; ?>" class="action-button tickets-action" href="#tickets/status/<?php echo $k; ?>"><i - class="<?php echo $v['icon']; ?>"></i> <?php echo $v['action']; ?></a> + class="<?php echo $v['icon']; ?>"></i> <?php + echo TicketStateField::getVerb($v['state']); ?></a> <?php } } diff --git a/scp/tickets.php b/scp/tickets.php index 17235eb62f1368744bc5a5164bb42cde496e600f..7de8a89fb49bc165f769a4e1a4575565c5e6edbb 100644 --- a/scp/tickets.php +++ b/scp/tickets.php @@ -63,24 +63,29 @@ if($_POST && !$errors): $errors['err']=__('Email is in banlist. Must be removed to reply.'); } - $wasOpen =($ticket->isOpen()); - //If no error...do the do. $vars = $_POST; if(!$errors && $_FILES['attachments']) $vars['files'] = AttachmentFile::format($_FILES['attachments']); if(!$errors && ($response=$ticket->postReply($vars, $errors, $_POST['emailreply']))) { - $msg=__('Reply posted successfully'); - $ticket->reload(); - - if($ticket->isClosed() && $wasOpen) - $ticket=null; - else - // Still open -- cleanup response draft for this user - Draft::deleteForNamespace( - 'ticket.response.' . $ticket->getId(), - $thisstaff->getId()); + $msg = sprintf(__('%s: Reply posted successfully'), + sprintf(__('Ticket #%s'), + sprintf('<a href="tickets.php?id=%d"><b>%s</b></a>', + $ticket->getId(), $ticket->getNumber())) + ); + + // Remove staff's locks + TicketLock::removeStaffLocks($thisstaff->getId(), + $ticket->getId()); + + // Cleanup response draft for this user + Draft::deleteForNamespace( + 'ticket.response.' . $ticket->getId(), + $thisstaff->getId()); + + // Go back to the ticket listing page on reply + $ticket = null; } elseif(!$errors['err']) { $errors['err']=__('Unable to post the reply. Correct the errors below and try again!');