Skip to content
Snippets Groups Projects
Commit 02dca1cd authored by Peter Rotich's avatar Peter Rotich
Browse files

Merge branch 'issue/autoresp' into issue/v1.10-fixes

parents 7a23bb03 783c0991
No related branches found
No related tags found
No related merge requests found
...@@ -604,6 +604,8 @@ implements TemplateVariable { ...@@ -604,6 +604,8 @@ implements TemplateVariable {
var $_headers; var $_headers;
var $_thread; var $_thread;
var $_actions; var $_actions;
var $is_autoreply;
var $is_bounce;
static protected $perms = array( static protected $perms = array(
self::PERM_EDIT => array( self::PERM_EDIT => array(
......
...@@ -1542,6 +1542,9 @@ implements RestrictedAccess, Threadable { ...@@ -1542,6 +1542,9 @@ implements RestrictedAccess, Threadable {
$this->setStaffId(0); // Clear assignment $this->setStaffId(0); // Clear assignment
} }
if (!$autorespond)
return;
// Figure out the user // Figure out the user
if ($this->getOwnerId() == $message->getUserId()) if ($this->getOwnerId() == $message->getUserId())
$user = new TicketOwner( $user = new TicketOwner(
...@@ -1553,11 +1556,11 @@ implements RestrictedAccess, Threadable { ...@@ -1553,11 +1556,11 @@ implements RestrictedAccess, Threadable {
/********** double check auto-response ************/ /********** double check auto-response ************/
if (!$user) if (!$user)
$autorespond=false; $autorespond = false;
elseif ($autorespond && (Email::getIdByEmail($user->getEmail()))) elseif ((Email::getIdByEmail($user->getEmail())))
$autorespond=false; $autorespond = false;
elseif ($autorespond && ($dept=$this->getDept())) elseif (($dept=$this->getDept()))
$autorespond=$dept->autoRespONNewMessage(); $autorespond = $dept->autoRespONNewMessage();
if (!$autorespond if (!$autorespond
|| !$cfg->autoRespONNewMessage() || !$cfg->autoRespONNewMessage()
...@@ -2293,28 +2296,18 @@ implements RestrictedAccess, Threadable { ...@@ -2293,28 +2296,18 @@ implements RestrictedAccess, Threadable {
} }
// Do not auto-respond to bounces and other auto-replies // Do not auto-respond to bounces and other auto-replies
if ($alerts) $autorespond = isset($vars['mailflags'])
$alerts = isset($vars['mailflags'])
? !$vars['mailflags']['bounce'] && !$vars['mailflags']['auto-reply'] ? !$vars['mailflags']['bounce'] && !$vars['mailflags']['auto-reply']
: true; : true;
if ($alerts && $message->isBounceOrAutoReply()) if ($autorespond && $message->isBounceOrAutoReply())
$alerts = false; $autorespond = false;
if ($alerts && $this->getThread()->getLastEmailMessage(array(
'user_id' => $message->user_id,
'id__lt' => $message->id,
'created__gt' => SqlFunction::NOW()->minus(SqlInterval::MINUTE(5)),
))) {
// One message already from this user in the last five minutes
$alerts = false;
}
$this->onMessage($message, $alerts); //must be called b4 sending alerts to staff. $this->onMessage($message, $autorespond); //must be called b4 sending alerts to staff.
if ($alerts && $cfg && $cfg->notifyCollabsONNewMessage()) if ($autorespond && $cfg && $cfg->notifyCollabsONNewMessage())
$this->notifyCollaborators($message, array('signature' => '')); $this->notifyCollaborators($message, array('signature' => ''));
if (!$alerts) if (!($alerts && $autorespond))
return $message; //Our work is done... return $message; //Our work is done...
$dept = $this->getDept(); $dept = $this->getDept();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment