diff --git a/include/class.filter.php b/include/class.filter.php index 4f000901f74d6d7c61730f3065b63760266dbb31..bc9b0847132aff00f794dd74abf6b2ec71379e35 100644 --- a/include/class.filter.php +++ b/include/class.filter.php @@ -71,6 +71,10 @@ class Filter { return $this->ht['execorder']; } + function getEmailId() { + return $this->ht['email_id']; + } + function isActive(){ return ($this->ht['isactive']); } @@ -216,11 +220,11 @@ class Filter { */ function matches($email) { $what = array( - "email" => $email['from'], + "email" => $email['email'], "subject" => $email['subject'], # XXX: Support reply-to too ? "name" => $email['name'], - "body" => $email['body'] + "body" => $email['message'] # XXX: Support headers ); $how = array( @@ -231,6 +235,10 @@ class Filter { "dn_contain"=> array("strpos", false) ); $match = false; + # Respect configured filter email-id + if ($email['emailId'] && $this->getEmailId() + && $this->getEmailId() != $email['emailId']) + return false; foreach ($this->getRules() as $rule) { list($func, $pos, $neg) = $how[$rule['h']]; # TODO: convert $what and $rule['v'] to mb_strtoupper and do @@ -281,6 +289,22 @@ class Filter { if ($this->getCannedResponse()) $ticket['cannedResponseId'] = $this->getCannedResponse(); } + /* static */ function getSupportedMatches() { + return array( + 'name'=> "Sender's Name", + 'email'=> "Sender's Email", + 'subject'=> 'Email Subject', + 'body'=> 'Email Body/Text' + ); + } + /* static */ function getSupportedMatchTypes() { + return array( + 'equal'=> 'Equal', + 'not_equal'=> 'Not Equal', + 'contains'=> 'Contains', + 'dn_contain'=> 'Does Not Contain' + ); + } function update($vars,&$errors){ @@ -567,7 +591,7 @@ class EmailFilter { * calls, etc). * * $email is an ARRAY, which has valid keys - * *from - email address of sender + * *email - email address of sender * name - name of sender * subject - subject line of the email * email-id - id of osTicket email recipient address @@ -586,8 +610,8 @@ class EmailFilter { $this->build($this->getAllActive()); } else { $this->build( - $this->quickList($email['from'], $email['name'], - $email['subject'])); + $this->quickList($email['email'], $email['name'], + $email['subject'], $email['emailId'])); } } diff --git a/include/staff/filter.inc.php b/include/staff/filter.inc.php index f57a09a42310d01b3297b38638453437084ca5de..6d0069641f84533937164097d9f9ecd89c8708a7 100644 --- a/include/staff/filter.inc.php +++ b/include/staff/filter.inc.php @@ -1,9 +1,8 @@ <?php if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied'); -$matches=array('name'=>"Sender's Name",'email'=>"Sender's Email",'subject'=>'Email Subject','body'=>'Email Body/Text','header'=>'Email Header'); -$match_types=array('equal'=>'Equal','not_equal'=>'Not Equal','contains'=>'Contains','dn_contain'=>'Does Not Contain'); - +$matches=Filter::getSupportedMatches(); +$match_types=Filter::getSupportedMatchTypes(); $info=array(); $qstr='';