Skip to content
Snippets Groups Projects
Commit c212d817 authored by Jared Hancock's avatar Jared Hancock
Browse files

Merge branch 'develop' into develop-next

Conflicts:
	include/class.usersession.php
parents 60560e86 398cbc7d
Branches
Tags
No related merge requests found
......@@ -144,9 +144,10 @@ class TicketApiController extends ApiController {
return $ticket;
}
function processEmail() {
function processEmail($data=false) {
$data = $this->getEmailRequest();
if (!$data)
$data = $this->getEmailRequest();
if (($thread = ThreadEntry::lookupByEmailHeaders($data))
&& $thread->postEmail($data)) {
......
......@@ -433,7 +433,7 @@ class ApiEmailDataParser extends EmailDataParser {
$data['source'] = 'Email';
if(!$data['message'])
$data['message'] = $data['subject']?$data['subject']:'-';
$data['message'] = '--';
if(!$data['subject'])
$data['subject'] = '[No Subject]';
......
......@@ -532,6 +532,23 @@ class MailFetcher {
if(!($mailinfo = $this->getHeaderInfo($mid)))
return false;
// TODO: If the content-type of the message is 'message/rfc822',
// then this is a message with the forwarded message as the
// attachment. Download the body and pass it along to the mail
// parsing engine.
$info = Mail_Parse::splitHeaders($mailinfo['header']);
if (strtolower($info['Content-Type']) == 'message/rfc822') {
if ($wrapped = $this->getPart($mid, 'message/rfc822')) {
require_once INCLUDE_DIR.'api.tickets.php';
// Simulate piping the contents into the system
$api = new TicketApiController();
$parser = new EmailDataParser();
if ($data = $parser->parse($wrapped))
return $api->processEmail($data);
}
// If any of this fails, create the ticket as usual
}
//Is the email address banned?
if($mailinfo['email'] && TicketFilter::isBanned($mailinfo['email'])) {
//We need to let admin know...
......
......@@ -56,7 +56,18 @@ class Mail_Parse {
$this->splitBodyHeader();
$this->struct=Mail_mimeDecode::decode($params);
return (PEAR::isError($this->struct) || !(count($this->struct->headers)>1))?FALSE:TRUE;
if (PEAR::isError($this->struct))
return false;
// Handle wrapped emails when forwarded
if ($this->struct && $this->struct->parts) {
$outer = $this->struct;
$ctype = $outer->ctype_primary.'/'.$outer->ctype_secondary;
if (strcasecmp($ctype, 'message/rfc822') === 0)
$this->struct = $outer->parts[0];
}
return (count($this->struct->headers) > 1);
}
function splitBodyHeader() {
......@@ -246,7 +257,10 @@ class Mail_Parse {
if($struct && !$struct->parts) {
$ctype = @strtolower($struct->ctype_primary.'/'.$struct->ctype_secondary);
if($ctype && strcasecmp($ctype,$ctypepart)==0) {
if ($struct->disposition
&& (strcasecmp($struct->disposition, 'inline') !== 0))
return '';
if ($ctype && strcasecmp($ctype,$ctypepart)==0) {
$content = $struct->body;
//Encode to desired encoding - ONLY if charset is known??
if (isset($struct->ctype_parameters['charset']))
......@@ -260,8 +274,7 @@ class Mail_Parse {
$data='';
if($struct && $struct->parts && $recurse) {
foreach($struct->parts as $i=>$part) {
if($part && !$part->disposition
&& ($text=$this->getPart($part,$ctypepart,$recurse - 1)))
if($part && ($text=$this->getPart($part,$ctypepart,$recurse - 1)))
$data.=$text;
}
}
......
......@@ -117,6 +117,7 @@ class ClientSession extends EndUser {
function __construct($user) {
parent::__construct($user);
// XXX: Change the key to user-id
$this->session= new UserSession($user->getUserName());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment