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

Merge pull request #164 from greezybacon/issue/filters

Fixes for email filtering

Reviewed By: Peter Rotich 07/22/12
parents 817e6d09 a68d817c
No related branches found
No related tags found
No related merge requests found
......@@ -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']));
}
}
......
<?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='';
......
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