From 696cf62fa89c2c730521ddde2a707698637d0d79 Mon Sep 17 00:00:00 2001 From: Peter Rotich <peter@osticket.com> Date: Thu, 16 Jan 2014 20:00:01 +0000 Subject: [PATCH] Save the user_id of the EndUser posting the message --- include/class.thread.php | 14 ++++++++++++++ include/class.ticket.php | 8 +++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/include/class.thread.php b/include/class.thread.php index 66349c5fe..282e8b122 100644 --- a/include/class.thread.php +++ b/include/class.thread.php @@ -160,6 +160,7 @@ class Thread { function addResponse($vars, &$errors) { $vars['ticketId'] = $this->getTicketId(); + $vars['userId'] = 0; return Response::create($vars, $errors); } @@ -370,6 +371,18 @@ Class ThreadEntry { return $this->staff; } + function getUserId() { + return $this->ht['user_id']; + } + + function getUser() { + + if (!isset($this->user)) + $this->user = User::lookup($this->getUserId()); + + return $this->user; + } + function getEmailHeader() { return $this->ht['headers']; } @@ -802,6 +815,7 @@ Class ThreadEntry { .' ,title='.db_input(Format::sanitize($vars['title'], true)) .' ,body='.db_input($vars['body']) .' ,staff_id='.db_input($vars['staffId']) + .' ,user_id='.db_input($vars['userId']) .' ,poster='.db_input($poster) .' ,source='.db_input($vars['source']); diff --git a/include/class.ticket.php b/include/class.ticket.php index 2e98d8654..d559b1cc6 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -1489,9 +1489,10 @@ class Ticket { //Add email recipients as collaborators if ($vars['recipients']) { - //TODO: Disable collaborators added by other collaborator - // staff approval will be required. - $info = array('isactive' => 1); + //New collaborators added by other collaborators are disable -- + // requires staff approval. + $info = array( + 'isactive' => ($message->getUserId() == $this->getUserId())? 1: 0); $collabs = array(); foreach ($vars['recipients'] as $recipient) { if (($user=User::fromVars($recipient))) @@ -2270,6 +2271,7 @@ class Ticket { //post the message. unset($vars['cannedattachments']); //Ticket::open() might have it set as part of open & respond. $vars['title'] = $vars['subject']; //Use the initial subject as title of the post. + $vars['userId'] = $ticket->getUserId(); $message = $ticket->postMessage($vars , $origin, false); // Configure service-level-agreement for this ticket -- GitLab