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

Merge remote-tracking branch 'upstream/develop' into develop-next

Conflicts:
	include/class.mailparse.php
parents 62da338a 4a67fa3b
Branches
Tags
No related merge requests found
......@@ -199,9 +199,18 @@ class Bootstrap {
return iconv($from, $to, $str); }
}
else {
function mb_strpos($a, $b) { return strpos($a, $b); }
function mb_strlen($str) { return strlen($str); }
function mb_substr($a, $b, $c=null) { return substr($a, $b, $c); }
function mb_strpos($a, $b) {
$c = preg_replace('/^(\X*)'.preg_quote($b).'.*$/us', '$1', $a);
return ($c===$a) ? false : mb_strlen($c);
}
function mb_strlen($str) {
$a = array();
return preg_match_all('/\X/u', $str, $a);
}
function mb_substr($a, $b, $c=null) {
return preg_replace(
"/^\X{{$b}}(\X".($c ? "{{$c}}" : "*").").*/us",'$1',$a);
}
function mb_convert_encoding($str, $to, $from='utf-8') {
if (strcasecmp($to, $from) == 0)
return $str;
......
......@@ -37,17 +37,7 @@ class OverviewReportAjaxAPI extends AjaxController {
function getData() {
global $thisstaff;
if(($start = $this->get('start', 'last month'))) {
$stop = $this->get('stop', 'now');
if (substr($stop, 0, 1) == '+')
$stop = $start . $stop;
} else {
$start = 'last month';
$stop = 'now';
}
$start = 'FROM_UNIXTIME('.strtotime($start).')';
$stop = 'FROM_UNIXTIME('.strtotime($stop).')';
list($start, $stop) = $this->_getDateRange();
$groups = array(
"dept" => array(
......@@ -172,26 +162,38 @@ class OverviewReportAjaxAPI extends AjaxController {
'text/csv', $csv);
}
function getPlotData() {
function _getDateRange() {
global $cfg;
if(($start = $this->get('start', 'last month'))) {
$stop = $this->get('stop', 'now');
if (substr($stop, 0, 1) == '+')
$stop = $start . $stop;
$stop = $this->get('period', 'now');
} else {
$start = 'last month';
$stop = 'now';
$stop = $this->get('period', 'now');
}
$start = strtotime($start);
$stop = strtotime($stop);
if ($start != 'last month')
$start = DateTime::createFromFormat($cfg->getDateFormat(),
$start)->format('U');
else
$start = strtotime($start);
if (substr($stop, 0, 1) == '+')
$stop = strftime('%Y-%m-%d ', $start) . $stop;
$start = 'FROM_UNIXTIME('.$start.')';
$stop = 'FROM_UNIXTIME('.strtotime($stop).')';
return array($start, $stop);
}
function getPlotData() {
list($start, $stop) = $this->_getDateRange();
# Fetch all types of events over the timeframe
$res = db_query('SELECT DISTINCT(state) FROM '.TICKET_EVENT_TABLE
.' WHERE timestamp BETWEEN FROM_UNIXTIME('.db_input($start)
.') AND FROM_UNIXTIME('.db_input($stop)
.') ORDER BY 1');
.' WHERE timestamp BETWEEN '.$start.' AND '.$stop
.' ORDER BY 1');
$events = array();
while ($row = db_fetch_row($res)) $events[] = $row[0];
......@@ -200,9 +202,8 @@ class OverviewReportAjaxAPI extends AjaxController {
$res = db_query('SELECT state, DATE_FORMAT(timestamp, \'%Y-%m-%d\'), '
.'COUNT(ticket_id)'
.' FROM '.TICKET_EVENT_TABLE
.' WHERE timestamp BETWEEN FROM_UNIXTIME('.db_input($start)
.') AND FROM_UNIXTIME('.db_input($stop)
.') AND NOT annulled'
.' WHERE timestamp BETWEEN '.$start.' AND '.$stop
.' AND NOT annulled'
.' GROUP BY state, DATE_FORMAT(timestamp, \'%Y-%m-%d\')'
.' ORDER BY 2, 1');
# Initialize array of plot values
......
......@@ -178,7 +178,7 @@ class OsticketConfig extends Config {
return true;
}
function lastModified() {
function lastModified($key=false) {
return max(array_map(array('parent', 'lastModified'),
array_keys($this->config)));
}
......
......@@ -42,9 +42,6 @@ class Format {
array('default','x-user-defined','iso','us-ascii')))
$charset = 'ISO-8859-1';
if ($charset && strcasecmp($charset, $encoding) === 0)
return $text;
$original = $text;
if(function_exists('iconv') && $charset)
$text = iconv($charset, $encoding.'//IGNORE', $text);
......
......@@ -66,7 +66,20 @@ class Mail_Parse {
$outer = $this->struct;
$ctype = $outer->ctype_primary.'/'.$outer->ctype_secondary;
if (strcasecmp($ctype, 'message/rfc822') === 0) {
// Capture Delivered-To header from the outer mail
$dt = $this->struct->headers['delivered-to'];
// Capture Message-Id from outer mail
$mid = $this->struct->headers['message-id'];
$this->struct = $outer->parts[0];
// Add (clobber) delivered to header from the outer mail
if ($dt)
$this->struct->headers['delivered-to'] = $dt;
// Ensure the nested mail has a Message-Id
if (!isset($this->struct->headers['message-id']))
$this->struct->headers['message-id'] = $mid;
// Use headers of the wrapped message
$headers = array();
foreach ($this->struct->headers as $h=>$v)
......@@ -186,7 +199,9 @@ class Mail_Parse {
}
function getMessageId(){
return $this->struct->headers['message-id'];
if (!($mid = $this->struct->headers['message-id']))
$mid = sprintf('<%s@local>', md5($this->getHeader()));
return $mid;
}
function getSubject(){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment