function _support_get_message_body in Support Ticketing System 7
1 call to _support_get_message_body()
- support_client_fetch in ./
support.module - Fetch mail for a specific client.
File
- ./
support.module, line 1960 - support.module
Code
function _support_get_message_body($stream, $message, $mime_type, $structure = FALSE, $part = FALSE) {
$body = _support_get_message_body_part($stream, $message, $mime_type, $structure, $part);
// If reply includes complete unchanged copy of ticket notification, strip
// it.
$stripped = FALSE;
$array = explode("\n", $body);
$last_line = $last_length = 0;
foreach ($array as $line => $text) {
// Look for last occurrance of magic in previous ticket.
preg_match_all("/([0-9]*):([0-9a-f]*)\\]/", $text, $magic);
if (!empty($magic[0][0])) {
foreach ($magic[1] as $key => $length) {
$last_line = $line;
$last_length = $length;
}
}
}
// Strip old ticket if quoted with "> " as most mail clients do.
$start = $last_line - $last_length;
if ($last_length) {
for ($current = $last_line; substr($array[$current], 0, 2) == '> '; $current--) {
$stripped = TRUE;
unset($array[$current]);
}
// If stripped entire ticket, strip one more line as most mail clients
// include a line saying who the message was by. If we only stripped
// part of the message, someone probably edited inline so we just stop
// at first unquoted line.
if ($current <= $start) {
unset($array[$current]);
}
}
if ($stripped) {
// The ticket has been stripped of previous ticket text, rebuild it.
$body = '';
foreach ($array as $line) {
$body .= $line . "\n";
}
}
return $body;
}