From 478202b63558e9e01daecc48d43f07ff6b7ea1b7 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Tue, 6 May 2014 10:44:05 -0500
Subject: [PATCH] alerts: Send new note alert to assigned team members

Previously, the new internal note alert was only sent to the assigned staff
member, if any were assigned.
---
 include/class.ticket.php | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/include/class.ticket.php b/include/class.ticket.php
index c7dc74953..0b1ab273d 100644
--- a/include/class.ticket.php
+++ b/include/class.ticket.php
@@ -1843,8 +1843,12 @@ class Ticket {
                 $recipients[]=$this->getLastRespondent();
 
             //Assigned staff if any...could be the last respondent
-            if($cfg->alertAssignedONNewNote() && $this->isAssigned() && $this->getStaffId())
-                $recipients[]=$this->getStaff();
+            if($cfg->alertAssignedONNewNote() && $this->isAssigned()) {
+                if ($staff = $this->getStaff())
+                    $recipients[] = $staff;
+                if ($team = $this->getTeam())
+                    $recipients = array_merge($recipients, $team->getMembers());
+            }
 
             //Dept manager
             if($cfg->alertDeptManagerONNewNote() && $dept && $dept->getManagerId())
@@ -1858,12 +1862,12 @@ class Ticket {
             foreach( $recipients as $k=>$staff) {
                 if(!is_object($staff)
                         || !$staff->isAvailable() //Don't bother vacationing staff.
-                        || in_array($staff->getEmail(), $sentlist) //No duplicates.
+                        || isset($sentlist[$staff->getEmail()]) //No duplicates.
                         || $note->getStaffId() == $staff->getId())  //No need to alert the poster!
                     continue;
                 $alert = $this->replaceVars($msg, array('recipient' => $staff));
                 $email->sendAlert($staff->getEmail(), $alert['subj'], $alert['body'], null, $options);
-                $sentlist[] = $staff->getEmail();
+                $sentlist[$staff->getEmail()] = 1;
             }
         }
 
-- 
GitLab