From c636e0cda542dbfb56d4cbe4e4bc9dcdc930d84d Mon Sep 17 00:00:00 2001 From: Peter Rotich <peter@enhancesoft.com> Date: Wed, 18 Dec 2013 19:12:00 +0000 Subject: [PATCH] Limit recipients count to active collaborators --- include/ajax.tickets.php | 2 +- include/class.ticket.php | 9 +++++++++ include/staff/ticket-view.inc.php | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/ajax.tickets.php b/include/ajax.tickets.php index d45c32e84..9c9a8b7d4 100644 --- a/include/ajax.tickets.php +++ b/include/ajax.tickets.php @@ -579,7 +579,7 @@ class TicketsAjaxAPI extends AjaxController { $errors = $info = array(); if ($ticket->updateCollaborators($_POST, $errors)) - Http::response(201, sprintf('Recipients (%d)', $ticket->getNumCollaborators())); + Http::response(201, sprintf('Recipients (%d)', $ticket->getNumActiveCollaborators())); if($errors && $errors['err']) $info +=array('error' => $errors['err']); diff --git a/include/class.ticket.php b/include/class.ticket.php index cbc319c67..bb07895ae 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -565,6 +565,14 @@ class Ticket { return $this->ht['collaborators']; } + function getNumActiveCollaborators() { + + if (!isset($this->ht['active_collaborators'])) + $this->ht['active_collaborators'] = count($this->getActiveCollaborators()); + + return $this->ht['active_collaborators']; + } + function getActiveCollaborators() { return $this->getCollaborators(array('isactive'=>1)); } @@ -630,6 +638,7 @@ class Ticket { db_query($sql); + unset($this->ht['active_collaborators']); $this->collaborators = null; return true; diff --git a/include/staff/ticket-view.inc.php b/include/staff/ticket-view.inc.php index dc0f71ce1..b255b225d 100644 --- a/include/staff/ticket-view.inc.php +++ b/include/staff/ticket-view.inc.php @@ -454,7 +454,7 @@ $tcount+= $ticket->getNumNotes(); } $recipients = 'Add Recipients'; if ($ticket->getNumCollaborators()) - $recipients = sprintf('Recipients (%d)', $ticket->getNumCollaborators()); + $recipients = sprintf('Recipients (%d)', $ticket->getNumActiveCollaborators()); echo sprintf('<span><a class="collaborators" href="#tickets/%d/collaborators/manage"><span id="recipients">%s</span></a></span>', -- GitLab