Commit 00162e72 authored by Manfred Kutas's avatar Manfred Kutas

ZP-1295 Merge MAPI classes from webapp.

Released under the Affero GNU General Public License (AGPL) version 3.
parent 1512331a
...@@ -431,10 +431,10 @@ class ImportChangesICS implements IImportChanges { ...@@ -431,10 +431,10 @@ class ImportChangesICS implements IImportChanges {
if(mapi_importcontentschanges_importmessagechange($this->importer, $props, $flags, $mapimessage)) { if(mapi_importcontentschanges_importmessagechange($this->importer, $props, $flags, $mapimessage)) {
$this->mapiprovider->SetMessage($mapimessage, $message); $this->mapiprovider->SetMessage($mapimessage, $message);
mapi_message_savechanges($mapimessage); mapi_savechanges($mapimessage);
if (mapi_last_hresult()) if (mapi_last_hresult())
throw new StatusException(sprintf("ImportChangesICS->ImportMessageChange('%s','%s'): Error, mapi_message_savechanges() failed: 0x%X", $id, get_class($message), mapi_last_hresult()), SYNC_STATUS_SYNCCANNOTBECOMPLETED); throw new StatusException(sprintf("ImportChangesICS->ImportMessageChange('%s','%s'): Error, mapi_savechanges() failed: 0x%X", $id, get_class($message), mapi_last_hresult()), SYNC_STATUS_SYNCCANNOTBECOMPLETED);
$sourcekeyprops = mapi_getprops($mapimessage, array (PR_SOURCE_KEY)); $sourcekeyprops = mapi_getprops($mapimessage, array (PR_SOURCE_KEY));
......
...@@ -703,7 +703,7 @@ class BackendKopano implements IBackend, ISearchProvider { ...@@ -703,7 +703,7 @@ class BackendKopano implements IBackend, ISearchProvider {
} }
mapi_setprops($mapimessage, $mapiprops); mapi_setprops($mapimessage, $mapiprops);
mapi_message_savechanges($mapimessage); mapi_savechanges($mapimessage);
mapi_message_submitmessage($mapimessage); mapi_message_submitmessage($mapimessage);
$hr = mapi_last_hresult(); $hr = mapi_last_hresult();
......
...@@ -341,7 +341,6 @@ ...@@ -341,7 +341,6 @@
$ret["startocc"] = $data["startmin"]; $ret["startocc"] = $data["startmin"];
$ret["endocc"] = $data["endmin"]; $ret["endocc"] = $data["endmin"];
$readerversion = $data["readerversion"];
$writerversion = $data["writerversion"]; $writerversion = $data["writerversion"];
$data = unpack("vnumber", $rdata); $data = unpack("vnumber", $rdata);
......
...@@ -401,7 +401,7 @@ class Meetingrequest { ...@@ -401,7 +401,7 @@ class Meetingrequest {
$recurr->createException($exception_props, $basedate, false, $recips); $recurr->createException($exception_props, $basedate, false, $recips);
} }
mapi_message_savechanges($calendarItem); mapi_savechanges($calendarItem);
$attach = $recurr->getExceptionAttachment($basedate); $attach = $recurr->getExceptionAttachment($basedate);
if ($attach) { if ($attach) {
...@@ -493,13 +493,13 @@ If it is the first time this attendee has proposed a new date/time, increment th ...@@ -493,13 +493,13 @@ If it is the first time this attendee has proposed a new date/time, increment th
$props[$this->proptags['counter_proposal']] = false; $props[$this->proptags['counter_proposal']] = false;
} }
mapi_message_setprops($calendarItem, $props); mapi_setprops($calendarItem, $props);
} }
mapi_message_savechanges($calendarItem); mapi_savechanges($calendarItem);
if (isset($attach)) { if (isset($attach)) {
mapi_message_savechanges($attach); mapi_savechanges($attach);
mapi_message_savechanges($recurringItem); mapi_savechanges($recurringItem);
} }
} }
...@@ -580,7 +580,7 @@ If it is the first time this attendee has proposed a new date/time, increment th ...@@ -580,7 +580,7 @@ If it is the first time this attendee has proposed a new date/time, increment th
} }
} else { } else {
// set the properties of the cancellation object // set the properties of the cancellation object
mapi_message_setprops($calendarItem, $messageProps); mapi_setprops($calendarItem, $messageProps);
} }
mapi_savechanges($calendarItem); mapi_savechanges($calendarItem);
...@@ -657,6 +657,17 @@ If it is the first time this attendee has proposed a new date/time, increment th ...@@ -657,6 +657,17 @@ If it is the first time this attendee has proposed a new date/time, increment th
// if meeting request is already processed then don't do anything // if meeting request is already processed then don't do anything
return false; return false;
} }
// if correspondent calendar item is already processed then don't do anything
$calendarItem = $this->getCorrespondentCalendarItem();
$calendarItemProps = mapi_getprops($calendarItem, array(PR_PROCESSED));
if(isset($calendarItemProps) && $calendarItemProps[PR_PROCESSED] == true) {
// mark meeting-request mail as processed as well
mapi_setprops($this->message, Array(PR_PROCESSED => true));
mapi_savechanges($this->message);
return false;
}
} }
// Retrieve basedate from globalID, if it is not recieved as argument // Retrieve basedate from globalID, if it is not recieved as argument
...@@ -934,7 +945,7 @@ If it is the first time this attendee has proposed a new date/time, increment th ...@@ -934,7 +945,7 @@ If it is the first time this attendee has proposed a new date/time, increment th
mapi_message_modifyrecipients($calmsg, MODRECIP_ADD, $recips); mapi_message_modifyrecipients($calmsg, MODRECIP_ADD, $recips);
} }
mapi_message_savechanges($calmsg); mapi_savechanges($calmsg);
// Move the message to the wastebasket // Move the message to the wastebasket
$wastebasket = $this->openDefaultWastebasket($this->openDefaultStore()); $wastebasket = $this->openDefaultWastebasket($this->openDefaultStore());
...@@ -1009,7 +1020,7 @@ If it is the first time this attendee has proposed a new date/time, increment th ...@@ -1009,7 +1020,7 @@ If it is the first time this attendee has proposed a new date/time, increment th
} else { } else {
mapi_message_modifyrecipients($new, MODRECIP_ADD, $recips); mapi_message_modifyrecipients($new, MODRECIP_ADD, $recips);
} }
mapi_message_savechanges($new); mapi_savechanges($new);
$props = mapi_getprops($new, array(PR_ENTRYID)); $props = mapi_getprops($new, array(PR_ENTRYID));
$entryid = $props[PR_ENTRYID]; $entryid = $props[PR_ENTRYID];
...@@ -1293,7 +1304,7 @@ If it is the first time this attendee has proposed a new date/time, increment th ...@@ -1293,7 +1304,7 @@ If it is the first time this attendee has proposed a new date/time, increment th
$this->sendMeetingRequest(true, _('Canceled: '), $basedate); $this->sendMeetingRequest(true, _('Canceled: '), $basedate);
// save changes in the message // save changes in the message
mapi_message_savechanges($this->message); mapi_savechanges($this->message);
} else { } else {
// cancellation of normal meeting request // cancellation of normal meeting request
// Send the cancellation // Send the cancellation
...@@ -1301,7 +1312,7 @@ If it is the first time this attendee has proposed a new date/time, increment th ...@@ -1301,7 +1312,7 @@ If it is the first time this attendee has proposed a new date/time, increment th
$this->sendMeetingRequest(true, _('Canceled: ')); $this->sendMeetingRequest(true, _('Canceled: '));
// save changes in the message // save changes in the message
mapi_message_savechanges($this->message); mapi_savechanges($this->message);
} }
// if basedate is specified then we have already created exception of it so nothing should be done now // if basedate is specified then we have already created exception of it so nothing should be done now
...@@ -2002,7 +2013,7 @@ If it is the first time this attendee has proposed a new date/time, increment th ...@@ -2002,7 +2013,7 @@ If it is the first time this attendee has proposed a new date/time, increment th
mapi_setprops($message, $props); mapi_setprops($message, $props);
mapi_message_modifyrecipients($message, MODRECIP_ADD, Array($recip)); mapi_message_modifyrecipients($message, MODRECIP_ADD, Array($recip));
mapi_message_savechanges($message); mapi_savechanges($message);
mapi_message_submitmessage($message); mapi_message_submitmessage($message);
} }
...@@ -2689,7 +2700,7 @@ If it is the first time this attendee has proposed a new date/time, increment th ...@@ -2689,7 +2700,7 @@ If it is the first time this attendee has proposed a new date/time, increment th
// Publish updated free/busy information // Publish updated free/busy information
if(!$this->errorSetResource){ if(!$this->errorSetResource){
for($i = 0, $len = count($resourceRecipData); $i < $len; $i++){ for($i = 0, $len = count($resourceRecipData); $i < $len; $i++){
$storeProps = mapi_msgstore_getprops($resourceRecipData[$i]['store'], array(PR_MAILBOX_OWNER_ENTRYID)); $storeProps = mapi_getprops($resourceRecipData[$i]['store'], array(PR_MAILBOX_OWNER_ENTRYID));
if (isset($storeProps[PR_MAILBOX_OWNER_ENTRYID])){ if (isset($storeProps[PR_MAILBOX_OWNER_ENTRYID])){
$start = time() - 7 * 24 * 60 * 60; $start = time() - 7 * 24 * 60 * 60;
$range = strtotime("+6 month"); $range = strtotime("+6 month");
...@@ -3033,7 +3044,7 @@ If it is the first time this attendee has proposed a new date/time, increment th ...@@ -3033,7 +3044,7 @@ If it is the first time this attendee has proposed a new date/time, increment th
} }
mapi_setprops($new, $newmessageprops); mapi_setprops($new, $newmessageprops);
mapi_message_savechanges($new); mapi_savechanges($new);
// Submit message to non-resource recipients // Submit message to non-resource recipients
mapi_message_submitmessage($new); mapi_message_submitmessage($new);
...@@ -3084,7 +3095,7 @@ If it is the first time this attendee has proposed a new date/time, increment th ...@@ -3084,7 +3095,7 @@ If it is the first time this attendee has proposed a new date/time, increment th
} }
mapi_setprops($new, $newmessageprops); mapi_setprops($new, $newmessageprops);
mapi_message_savechanges($new); mapi_savechanges($new);
// Submit message to non-resource recipients // Submit message to non-resource recipients
mapi_message_submitmessage($new); mapi_message_submitmessage($new);
......
...@@ -701,7 +701,7 @@ ...@@ -701,7 +701,7 @@
$props[PR_DISPLAY_NAME] = "Exception"; $props[PR_DISPLAY_NAME] = "Exception";
$props[PR_EXCEPTION_STARTTIME] = $this->fromGMT($this->tz, $exception_props[$this->proptags["startdate"]]); $props[PR_EXCEPTION_STARTTIME] = $this->fromGMT($this->tz, $exception_props[$this->proptags["startdate"]]);
$props[PR_EXCEPTION_ENDTIME] = $this->fromGMT($this->tz, $exception_props[$this->proptags["duedate"]]); $props[PR_EXCEPTION_ENDTIME] = $this->fromGMT($this->tz, $exception_props[$this->proptags["duedate"]]);
mapi_message_setprops($attachment, $props); mapi_setprops($attachment, $props);
$imessage = mapi_attach_openobj($attachment, MAPI_CREATE | MAPI_MODIFY); $imessage = mapi_attach_openobj($attachment, MAPI_CREATE | MAPI_MODIFY);
...@@ -731,12 +731,12 @@ ...@@ -731,12 +731,12 @@
} }
} }
mapi_message_setprops($imessage, $props); mapi_setprops($imessage, $props);
$this->setExceptionRecipients($imessage, $exception_recips, true); $this->setExceptionRecipients($imessage, $exception_recips, true);
mapi_message_savechanges($imessage); mapi_savechanges($imessage);
mapi_message_savechanges($attachment); mapi_savechanges($attachment);
} }
/** /**
...@@ -1071,7 +1071,7 @@ ...@@ -1071,7 +1071,7 @@
// Remove all deleted recipients // Remove all deleted recipients
if (isset($exception_recips['remove'])) { if (isset($exception_recips['remove'])) {
foreach ($exception_recips['remove'] as &$recip) { foreach ($exception_recips['remove'] as &$recip) {
if (!isset($recipient[PR_RECIPIENT_FLAGS]) || $recip[PR_RECIPIENT_FLAGS] != (recipReserved | recipExceptionalDeleted | recipSendable)) { if (!isset($recip[PR_RECIPIENT_FLAGS]) || $recip[PR_RECIPIENT_FLAGS] != (recipReserved | recipExceptionalDeleted | recipSendable)) {
$recip[PR_RECIPIENT_FLAGS] = recipSendable | recipExceptionalDeleted; $recip[PR_RECIPIENT_FLAGS] = recipSendable | recipExceptionalDeleted;
} else { } else {
$recip[PR_RECIPIENT_FLAGS] = recipReserved | recipExceptionalDeleted | recipSendable; $recip[PR_RECIPIENT_FLAGS] = recipReserved | recipExceptionalDeleted | recipSendable;
......
...@@ -84,6 +84,11 @@ ...@@ -84,6 +84,11 @@
define('tmrSent', 1); // Task has been sent to multiple assignee define('tmrSent', 1); // Task has been sent to multiple assignee
define('tmrReceived', 2); // Task Request received has multiple assignee define('tmrReceived', 2); // Task Request received has multiple assignee
//Task icon index.
define('ICON_TASK_ASSIGNEE', 0x00000502);
define('ICON_TASK_DECLINE', 0x00000506);
define('ICON_TASK_ASSIGNER', 0x00000503);
class TaskRequest { class TaskRequest {
// All recipient properties // All recipient properties
...@@ -398,9 +403,21 @@ ...@@ -398,9 +403,21 @@
mapi_message_deleteattach($task, $taskAttach[PR_ATTACH_NUM]); mapi_message_deleteattach($task, $taskAttach[PR_ATTACH_NUM]);
} }
$ignoreProps = array(
$this->props['taskstate'],
$this->props['taskhistory'],
$this->props['taskmode'],
$this->props['taskfcreator']
);
// Ignore PR_ICON_INDEX when task request response
// is not received item.
if ($isReceivedItem === false) {
$ignoreProps[] = PR_ICON_INDEX;
}
// We copy all properties except taskstate, taskhistory, taskmode and taskfcreator properties // We copy all properties except taskstate, taskhistory, taskmode and taskfcreator properties
// from $sub message to $task even also we copy all attachments from $sub to $task message. // from $sub message to $task even also we copy all attachments from $sub to $task message.
mapi_copyto($sub, array(), array($this->props['taskstate'], $this->props['taskhistory'], $this->props['taskmode'], $this->props['taskfcreator']), $task); mapi_copyto($sub, array(), $ignoreProps, $task);
$senderProps = mapi_getprops($this->message, array( $senderProps = mapi_getprops($this->message, array(
PR_SENDER_NAME, PR_SENDER_NAME,
PR_SENDER_EMAIL_ADDRESS, PR_SENDER_EMAIL_ADDRESS,
...@@ -494,7 +511,7 @@ ...@@ -494,7 +511,7 @@
$this->props['ownership'] => olDelegatedTask, /* Task has been assigned */ $this->props['ownership'] => olDelegatedTask, /* Task has been assigned */
$this->props['taskhistory'] => thAssigned, /* Task has been assigned */ $this->props['taskhistory'] => thAssigned, /* Task has been assigned */
PR_CONVERSATION_TOPIC => $messageprops[PR_SUBJECT], PR_CONVERSATION_TOPIC => $messageprops[PR_SUBJECT],
PR_ICON_INDEX => 1283 /* Task request icon*/ PR_ICON_INDEX => ICON_TASK_ASSIGNER /* Task request icon*/
)); ));
$this->setLastUser(); $this->setLastUser();
$this->setOwnerForAssignor(); $this->setOwnerForAssignor();
...@@ -503,8 +520,8 @@ ...@@ -503,8 +520,8 @@
// Create outgoing task request message // Create outgoing task request message
$outgoing = $this->createOutgoingMessage(); $outgoing = $this->createOutgoingMessage();
// No need to copy PR_SENT_* information in to outgoing message. // No need to copy PR_ICON_INDEX and PR_SENT_* information in to outgoing message.
$ignoreProps = array(PR_SENT_REPRESENTING_NAME, PR_SENT_REPRESENTING_EMAIL_ADDRESS, PR_SENT_REPRESENTING_ADDRTYPE, PR_SENT_REPRESENTING_ENTRYID, PR_SENT_REPRESENTING_SEARCH_KEY); $ignoreProps = array(PR_ICON_INDEX, PR_SENT_REPRESENTING_NAME, PR_SENT_REPRESENTING_EMAIL_ADDRESS, PR_SENT_REPRESENTING_ADDRTYPE, PR_SENT_REPRESENTING_ENTRYID, PR_SENT_REPRESENTING_SEARCH_KEY);
mapi_copyto($this->message, array(), $ignoreProps, $outgoing); mapi_copyto($this->message, array(), $ignoreProps, $outgoing);
// Make it a task request, and put it in sent items after it is sent // Make it a task request, and put it in sent items after it is sent
...@@ -514,8 +531,7 @@ ...@@ -514,8 +531,7 @@
$this->props['taskmode'] => tdmtTaskReq, /* for the recipient it's a request */ $this->props['taskmode'] => tdmtTaskReq, /* for the recipient it's a request */
$this->props['updatecount'] => 1, /* version 2 is in the attachment */ $this->props['updatecount'] => 1, /* version 2 is in the attachment */
PR_SUBJECT_PREFIX => $prefix, PR_SUBJECT_PREFIX => $prefix,
PR_SUBJECT => $prefix . $messageprops[PR_SUBJECT], PR_SUBJECT => $prefix . $messageprops[PR_SUBJECT]
PR_ICON_INDEX => 0xFFFFFFFF, /* show assigned icon */
)); ));
$attach = mapi_message_createattach($outgoing); $attach = mapi_message_createattach($outgoing);
...@@ -599,7 +615,7 @@ ...@@ -599,7 +615,7 @@
$taskProps[$this->props["taskfcreator"]] = false; $taskProps[$this->props["taskfcreator"]] = false;
$taskProps[$this->props["ownership"]] = $isReceivedItem ? olOwnTask : olDelegatedTask; $taskProps[$this->props["ownership"]] = $isReceivedItem ? olOwnTask : olDelegatedTask;
$taskProps[$this->props["task_acceptance_state"]] = olTaskNotDelegated; $taskProps[$this->props["task_acceptance_state"]] = olTaskNotDelegated;
$taskProps[PR_ICON_INDEX] = 1282; $taskProps[PR_ICON_INDEX] = ICON_TASK_ASSIGNEE;
mapi_setprops($task, $taskProps); mapi_setprops($task, $taskProps);
$this->setAssignorInRecipients($task); $this->setAssignorInRecipients($task);
...@@ -851,7 +867,7 @@ ...@@ -851,7 +867,7 @@
$message = !$this->isTaskRequest() ? $this->message : $this->getAssociatedTask(false); $message = !$this->isTaskRequest() ? $this->message : $this->getAssociatedTask(false);
$ignoreProps = array(PR_SENT_REPRESENTING_NAME, PR_SENT_REPRESENTING_EMAIL_ADDRESS, PR_SENT_REPRESENTING_ADDRTYPE, PR_SENT_REPRESENTING_ENTRYID, PR_SENT_REPRESENTING_SEARCH_KEY); $ignoreProps = array(PR_ICON_INDEX, PR_SENT_REPRESENTING_NAME, PR_SENT_REPRESENTING_EMAIL_ADDRESS, PR_SENT_REPRESENTING_ADDRTYPE, PR_SENT_REPRESENTING_ENTRYID, PR_SENT_REPRESENTING_SEARCH_KEY);
mapi_copyto($message, array(), $ignoreProps, $outgoing); mapi_copyto($message, array(), $ignoreProps, $outgoing);
mapi_copyto($message, array(), array(), $sub); mapi_copyto($message, array(), array(), $sub);
...@@ -864,11 +880,14 @@ ...@@ -864,11 +880,14 @@
switch($type) { switch($type) {
case tdmtTaskAcc: case tdmtTaskAcc:
$props[PR_MESSAGE_CLASS] = "IPM.TaskRequest.Accept"; $props[PR_MESSAGE_CLASS] = "IPM.TaskRequest.Accept";
mapi_setprops($sub, array(PR_ICON_INDEX => ICON_TASK_ASSIGNER));
break; break;
case tdmtTaskDec: case tdmtTaskDec:
$props[PR_MESSAGE_CLASS] = "IPM.TaskRequest.Decline"; $props[PR_MESSAGE_CLASS] = "IPM.TaskRequest.Decline";
mapi_setprops($sub, array(PR_ICON_INDEX => ICON_TASK_DECLINE));
break; break;
case tdmtTaskUpd: case tdmtTaskUpd:
mapi_setprops($sub, array(PR_ICON_INDEX => ICON_TASK_ASSIGNER));
if($messageprops[$this->props['complete']]) { if($messageprops[$this->props['complete']]) {
$props[PR_MESSAGE_CLASS] = "IPM.TaskRequest.Complete"; $props[PR_MESSAGE_CLASS] = "IPM.TaskRequest.Complete";
} else { } else {
...@@ -884,7 +903,6 @@ ...@@ -884,7 +903,6 @@
$props[PR_SUBJECT] = $prefix . $messageprops[PR_CONVERSATION_TOPIC]; $props[PR_SUBJECT] = $prefix . $messageprops[PR_CONVERSATION_TOPIC];
$props[$this->props['taskmode']] = $type; $props[$this->props['taskmode']] = $type;
$props[$this->props['task_assigned_time']] = time(); $props[$this->props['task_assigned_time']] = time();
$props[PR_ICON_INDEX] = 0xFFFFFFFF;
mapi_setprops($outgoing, $props); mapi_setprops($outgoing, $props);
......
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