--- ./class.note.php 2006-11-19 23:09:13.095332098 +0200 +++ /usr/share/eventum/include/class.note.php 2006-12-07 03:04:11.803818460 +0200 @@ -564,7 +564,7 @@ } $res = Support::insertEmail($t, $structure, $sup_id); if ($res != -1) { - Support::extractAttachments($issue_id, $blocked_message); + Support::extractAttachments($issue_id, $structure); // notifications about new emails are always external $internal_only = false; // special case when emails are bounced back, so we don't want to notify the customer about those --- ./class.routing.php 2006-12-07 02:50:17.217637483 +0200 +++ /usr/share/eventum/include/class.routing.php 2006-12-07 03:00:03.699713356 +0200 @@ -202,7 +206,7 @@ list($t['full_email'], $t['headers']) = Mail_API::rewriteThreadingHeaders($t['issue_id'], $t['full_email'], $t['headers'], "email"); $res = Support::insertEmail($t, $structure, $sup_id); if ($res != -1) { - Support::extractAttachments($issue_id, $full_message); + Support::extractAttachments($issue_id, $structure); // notifications about new emails are always external $internal_only = false; @@ -355,7 +359,7 @@ $res = Note::insert(Auth::getUserID(), $issue_id, false, false); // need to handle attachments coming from notes as well if ($res != -1) { - Support::extractAttachments($issue_id, $full_message, true, $res); + Support::extractAttachments($issue_id, $structure, true, $res); } // FIXME! $res == -2 is not handled History::add($issue_id, Auth::getUserID(), History::getTypeID('note_routed'), ev_gettext('Note routed from %1$s', $structure->headers['from'])); --- ./class.support.php 2006-12-07 01:24:32.159548940 +0200 +++ /usr/share/eventum/include/class.support.php 2006-12-07 03:02:46.018250041 +0200 @@ -656,7 +670,7 @@ if ($res != -1) { // only extract the attachments from the email if we are associating the email to an issue if (!empty($t['issue_id'])) { - Support::extractAttachments($t['issue_id'], $t['full_email']); + Support::extractAttachments($t['issue_id'], $structure); // notifications about new emails are always external $internal_only = false; @@ -1337,15 +1351,18 @@ * * @access public * @param integer $issue_id The issue ID - * @param string $full_email The full contents of the email + * @param mixed $input The full body of the message or decoded email. * @param boolean $internal_only Whether these files are supposed to be internal only or not * @param integer $associated_note_id The note ID that these attachments should be associated with * @return void */ - function extractAttachments($issue_id, $full_email, $internal_only = false, $associated_note_id = false) + function extractAttachments($issue_id, $input, $internal_only = false, $associated_note_id = false) { + if (!is_object($input)) { + $input = Mime_Helper::decode($input, false, false); + } + // figure out who should be the 'owner' of this attachment - $structure = Mime_Helper::decode($full_email, false, false); $sender_email = strtolower(Mail_API::getEmailAddress($structure->headers['from'])); $usr_id = User::getUserIDByEmail($sender_email); $unknown_user = false; @@ -1366,7 +1383,7 @@ } } // now for the real thing - $attachments = Mime_Helper::getAttachments($full_email); + $attachments = Mime_Helper::getAttachments($input); if (count($attachments) > 0) { if (empty($associated_note_id)) { $history_log = ev_gettext("Attachment originated from an email"); --- ./class.support.php 2006-12-07 01:24:32.159548940 +0200 +++ /usr/share/eventum/include/class.support.php 2006-12-07 03:02:46.018250041 +0200 @@ -1353,7 +1353,7 @@ } // figure out who should be the 'owner' of this attachment - $sender_email = strtolower(Mail_API::getEmailAddress($structure->headers['from'])); + $sender_email = strtolower(Mail_API::getEmailAddress($input->headers['from'])); $usr_id = User::getUserIDByEmail($sender_email); $unknown_user = false; if (empty($usr_id)) { @@ -1369,7 +1369,7 @@ // if we couldn't find a real customer by that email, set the usr_id to be the system user id, // and store the actual email address in the unknown_user field. $usr_id = APP_SYSTEM_USER_ID; - $unknown_user = $structure->headers['from']; + $unknown_user = $input->headers['from']; } } // now for the real thing