Commit fdd01b33 authored by mku's avatar mku

ZP-464 #comment BB 10 does not show email body when mail has attachments #time 30m

git-svn-id: https://z-push.org/svn/z-push/trunk@1760 b7dd7b3b-3a3c-0410-9da9-bee62a6cc5b5
parent 0f894448
......@@ -128,10 +128,8 @@ class MAPIProvider {
foreach($rows as $row) {
if(isset($row[PR_ATTACH_NUM])) {
if (isset($row[PR_ATTACH_SIZE]) && $row[PR_ATTACH_SIZE] < MAX_EMBEDDED_SIZE) {
$mapiattach = mapi_message_openattach($mapimessage, $row[PR_ATTACH_NUM]);
$message->picture = base64_encode(mapi_attach_openbin($mapiattach, PR_ATTACH_DATA_BIN));
}
$mapiattach = mapi_message_openattach($mapimessage, $row[PR_ATTACH_NUM]);
$message->picture = base64_encode(mapi_attach_openbin($mapiattach, PR_ATTACH_DATA_BIN));
}
}
}
......@@ -1378,47 +1376,45 @@ class MAPIProvider {
if (isset($contact->picture)) {
$picbinary = base64_decode($contact->picture);
$picsize = strlen($picbinary);
if ($picsize < MAX_EMBEDDED_SIZE) {
$props[$contactprops["haspic"]] = false;
// TODO contact picture handling
// check if contact has already got a picture. delete it first in that case
// delete it also if it was removed on a mobile
$picprops = mapi_getprops($mapimessage, array($contactprops["haspic"]));
if (isset($picprops[$contactprops["haspic"]]) && $picprops[$contactprops["haspic"]]) {
ZLog::Write(LOGLEVEL_DEBUG, "Contact already has a picture. Delete it");
$attachtable = mapi_message_getattachmenttable($mapimessage);
mapi_table_restrict($attachtable, MAPIUtils::GetContactPicRestriction());
$rows = mapi_table_queryallrows($attachtable, array(PR_ATTACH_NUM));
if (isset($rows) && is_array($rows)) {
foreach ($rows as $row) {
mapi_message_deleteattach($mapimessage, $row[PR_ATTACH_NUM]);
}
$props[$contactprops["haspic"]] = false;
// TODO contact picture handling
// check if contact has already got a picture. delete it first in that case
// delete it also if it was removed on a mobile
$picprops = mapi_getprops($mapimessage, array($contactprops["haspic"]));
if (isset($picprops[$contactprops["haspic"]]) && $picprops[$contactprops["haspic"]]) {
ZLog::Write(LOGLEVEL_DEBUG, "Contact already has a picture. Delete it");
$attachtable = mapi_message_getattachmenttable($mapimessage);
mapi_table_restrict($attachtable, MAPIUtils::GetContactPicRestriction());
$rows = mapi_table_queryallrows($attachtable, array(PR_ATTACH_NUM));
if (isset($rows) && is_array($rows)) {
foreach ($rows as $row) {
mapi_message_deleteattach($mapimessage, $row[PR_ATTACH_NUM]);
}
}
}
// only set picture if there's data in the request
if ($picbinary !== false && $picsize > 0) {
$props[$contactprops["haspic"]] = true;
$pic = mapi_message_createattach($mapimessage);
// Set properties of the attachment
$picprops = array(
PR_ATTACH_LONG_FILENAME_A => "ContactPicture.jpg",
PR_DISPLAY_NAME => "ContactPicture.jpg",
0x7FFF000B => true,
PR_ATTACHMENT_HIDDEN => false,
PR_ATTACHMENT_FLAGS => 1,
PR_ATTACH_METHOD => ATTACH_BY_VALUE,
PR_ATTACH_EXTENSION_A => ".jpg",
PR_ATTACH_NUM => 1,
PR_ATTACH_SIZE => $picsize,
PR_ATTACH_DATA_BIN => $picbinary,
);
mapi_setprops($pic, $picprops);
mapi_savechanges($pic);
}
// only set picture if there's data in the request
if ($picbinary !== false && $picsize > 0) {
$props[$contactprops["haspic"]] = true;
$pic = mapi_message_createattach($mapimessage);
// Set properties of the attachment
$picprops = array(
PR_ATTACH_LONG_FILENAME_A => "ContactPicture.jpg",
PR_DISPLAY_NAME => "ContactPicture.jpg",
0x7FFF000B => true,
PR_ATTACHMENT_HIDDEN => false,
PR_ATTACHMENT_FLAGS => 1,
PR_ATTACH_METHOD => ATTACH_BY_VALUE,
PR_ATTACH_EXTENSION_A => ".jpg",
PR_ATTACH_NUM => 1,
PR_ATTACH_SIZE => $picsize,
PR_ATTACH_DATA_BIN => $picbinary,
);
mapi_setprops($pic, $picprops);
mapi_savechanges($pic);
}
}
......@@ -2332,27 +2328,22 @@ class MAPIProvider {
}
if (isset($stream) && isset($streamsize)) {
if ($streamsize < MAX_EMBEDDED_SIZE) {
if (Request::GetProtocolVersion() >= 12.0) {
if (!isset($message->asbody))
$message->asbody = new SyncBaseBody();
//TODO data should be wrapped in a MapiStreamWrapper
$message->asbody->data = mapi_stream_read($stream, MAX_EMBEDDED_SIZE);
$message->asbody->estimatedDataSize = $streamsize;
$message->asbody->truncated = 0;
}
else {
$message->mimetruncated = 0;
//TODO mimedata should be a wrapped in a MapiStreamWrapper
$message->mimedata = mapi_stream_read($stream, MAX_EMBEDDED_SIZE);
$message->mimesize = $streamsize;
}
unset($message->body, $message->bodytruncated);
return true;
if (Request::GetProtocolVersion() >= 12.0) {
if (!isset($message->asbody))
$message->asbody = new SyncBaseBody();
//TODO data should be wrapped in a MapiStreamWrapper
$message->asbody->data = mapi_stream_read($stream, $streamsize);
$message->asbody->estimatedDataSize = $streamsize;
$message->asbody->truncated = 0;
}
else {
ZLog::Write(LOGLEVEL_WARN, sprintf("Your request (%d bytes) exceeds the value for inline attachments (%d bytes). You can change the value of MAX_EMBEDDED_SIZE in config.php", $mstreamstat['cb'], MAX_EMBEDDED_SIZE));
$message->mimetruncated = 0;
//TODO mimedata should be a wrapped in a MapiStreamWrapper
$message->mimedata = mapi_stream_read($stream, $streamsize);
$message->mimesize = $streamsize;
}
unset($message->body, $message->bodytruncated);
return true;
}
else {
ZLog::Write(LOGLEVEL_ERROR, sprintf("Error opening attachment for imtoinet"));
......
......@@ -53,9 +53,6 @@
// Try to set unlimited timeout
define('SCRIPT_TIMEOUT', 0);
// Max size of attachments to display inline. Default is 2 MB
define('MAX_EMBEDDED_SIZE', 2097152);
// When accessing through a proxy, the "X-Forwarded-For" header contains the original remote IP
define('USE_X_FORWARDED_FOR_HEADER', false);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment