/** * Function which save an exception into recurring item * * @param resource $recurringItem reference to MAPI_message of recurring item * @param resource $occurrenceItem reference to MAPI_message of occurrence * @param string $basedate basedate of occurrence * @param boolean $move if true then occurrence item is deleted * @param boolean $tentative true if user has tentatively accepted it or false if user has accepted it. * @param boolean $userAction true if user has manually responded to meeting request * @param resource $store user store * @param boolean $isDelegate true if delegate is processing this meeting request */ function acceptException(&$recurringItem, &$occurrenceItem, $basedate, $move = false, $tentative, $userAction = false, $store, $isDelegate = false) { $recurr = new Recurrence($store, $recurringItem); // Copy properties from meeting request $exception_props = mapi_getprops($occurrenceItem); // Copy recipients list $reciptable = mapi_message_getrecipienttable($occurrenceItem); // If delegate, then do not add the delegate in recipients if ($isDelegate) { $delegate = mapi_getprops($this->message, array(PR_RECEIVED_BY_EMAIL_ADDRESS)); $res = array(RES_PROPERTY, array(RELOP => RELOP_NE, ULPROPTAG => PR_EMAIL_ADDRESS, VALUE => $delegate[PR_RECEIVED_BY_EMAIL_ADDRESS])); $recips = mapi_table_queryallrows($reciptable, $this->recipprops, $res); } else { $recips = mapi_table_queryallrows($reciptable, $this->recipprops); } // add owner to recipient table $this->addOrganizer($exception_props, $recips, true); // add delegator to meetings if ($isDelegate) { $this->addDelegator($exception_props, $recips); } $exception_props[$this->proptags['meetingstatus']] = olMeetingReceived; $exception_props[$this->proptags['responsestatus']] = $userAction ? $tentative ? olResponseTentative : olResponseAccepted : olResponseNotResponded; // Set basedate property (ExceptionReplaceTime) if (isset($exception_props[$this->proptags['intendedbusystatus']])) { if ($tentative && $exception_props[$this->proptags['intendedbusystatus']] !== fbFree) { $exception_props[$this->proptags['busystatus']] = $tentative; } else { $exception_props[$this->proptags['busystatus']] = $exception_props[$this->proptags['intendedbusystatus']]; } // we already have intendedbusystatus value in $exception_props so no need to copy it } else { $exception_props[$this->proptags['busystatus']] = $tentative ? fbTentative : fbBusy; } if ($userAction) { // if user has responded then set replytime $exception_props[$this->proptags['replytime']] = time(); } if ($recurr->isException($basedate)) { $recurr->modifyException($exception_props, $basedate, $recips, $occurrenceItem); } else { $recurr->createException($exception_props, $basedate, false, $recips, $occurrenceItem); } // Move the occurrenceItem to the waste basket if ($move) { $wastebasket = $this->openDefaultWastebasket(); $sourcefolder = mapi_msgstore_openentry($this->store, $exception_props[PR_PARENT_ENTRYID]); mapi_folder_copymessages($sourcefolder, array($exception_props[PR_ENTRYID]), $wastebasket, MESSAGE_MOVE); } mapi_savechanges($recurringItem); }
/** Deletes incoming task request from Inbox * * @returns array returns PR_ENTRYID, PR_STORE_ENTRYID and PR_PARENT_ENTRYID of the deleted task request */ function deleteReceivedTR() { $store = $this->getTaskFolderStore(); $inbox = mapi_msgstore_getreceivefolder($store); $storeProps = mapi_getprops($store, array(PR_IPM_WASTEBASKET_ENTRYID)); $props = mapi_getprops($this->message, array($this->props['taskglobalobjid'])); $globalobjid = $props[$this->props['taskglobalobjid']]; // Find the task by looking for the taskglobalobjid $restriction = array(RES_PROPERTY, array(RELOP => RELOP_EQ, ULPROPTAG => $this->props['taskglobalobjid'], VALUE => $globalobjid)); $contents = mapi_folder_getcontentstable($inbox); $rows = mapi_table_queryallrows($contents, array(PR_ENTRYID, PR_PARENT_ENTRYID, PR_STORE_ENTRYID), $restriction); $taskrequest = false; if (!empty($rows)) { // If there are multiple, just use the first $entryid = $rows[0][PR_ENTRYID]; $wastebasket = mapi_msgstore_openentry($store, $storeProps[PR_IPM_WASTEBASKET_ENTRYID]); mapi_folder_copymessages($inbox, array($entryid), $wastebasket, MESSAGE_MOVE); return array(PR_ENTRYID => $entryid, PR_PARENT_ENTRYID => $rows[0][PR_PARENT_ENTRYID], PR_STORE_ENTRYID => $rows[0][PR_STORE_ENTRYID]); } return false; }
/** * Function which merges an exception mapi message to recurring message. * This will be used when we receive recurring meeting request and we already have an exception message * of same meeting in calendar and we need to remove that exception message and add it to attachment table * of recurring meeting. * * @param resource $recurringItem reference to MAPI_message of recurring item * @param resource $occurrenceItem reference to MAPI_message of occurrence * @param string $basedate basedate of occurrence * @param resource $store user store * @param boolean $isDelegate true if delegate is processing this meeting request */ function mergeException(&$recurringItem, &$occurrenceItem, $basedate, $store, $isDelegate = false) { $recurr = new Recurrence($store, $recurringItem); // Copy properties from meeting request $exception_props = mapi_getprops($occurrenceItem); // Get recipient list from message and add it to exception attachment $reciptable = mapi_message_getrecipienttable($occurrenceItem); $recips = mapi_table_queryallrows($reciptable, $this->recipprops); if ($recurr->isException($basedate)) { $recurr->modifyException($exception_props, $basedate, $recips, $occurrenceItem); } else { $recurr->createException($exception_props, $basedate, false, $recips, $occurrenceItem); } // Move the occurrenceItem to the waste basket $wastebasket = $this->openDefaultWastebasket($this->openDefaultStore()); $sourcefolder = mapi_msgstore_openentry($store, $exception_props[PR_PARENT_ENTRYID]); mapi_folder_copymessages($sourcefolder, array($exception_props[PR_ENTRYID]), $wastebasket, MESSAGE_MOVE); mapi_savechanges($recurringItem); }
function ImportMessageMove($id, $newfolder) { $sourcekey = hex2bin($id); $parentsourcekey = $this->_folderid; // Get the entryid of the message we're moving $entryid = mapi_msgstore_entryidfromsourcekey($this->_store, $parentsourcekey, $sourcekey); if (!$entryid) { debugLog("Unable to resolve source message id"); return false; } $dstentryid = mapi_msgstore_entryidfromsourcekey($this->_store, hex2bin($newfolder)); if (!$dstentryid) { debugLog("Unable to resolve destination folder"); return false; } $dstfolder = mapi_msgstore_openentry($this->_store, $dstentryid); if (!$dstfolder) { debugLog("Unable to open destination folder"); return false; } // Open the source folder (we just open the root because it doesn't matter which folder you open as a source // folder) $root = mapi_msgstore_openentry($this->_store); // Do the actual move return mapi_folder_copymessages($root, array($entryid), $dstfolder, MESSAGE_MOVE); }