本文整理汇总了PHP中mapi_savechanges函数的典型用法代码示例。如果您正苦于以下问题:PHP mapi_savechanges函数的具体用法?PHP mapi_savechanges怎么用?PHP mapi_savechanges使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mapi_savechanges函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteOccurrence
/**
* Function which recurring task to next occurrence.
* It simply doesn't regenerate task
@param array $action
*/
function deleteOccurrence($action)
{
$this->tz = false;
$this->action = $action;
$result = $this->moveToNextOccurrence();
mapi_savechanges($this->message);
return $result;
}
示例2: copyAttachments
/**
* Copies attachments from one message to another.
*
* @param MAPIMessage $toMessage
* @param MAPIMessage $fromMessage
*
* @return void
*/
private function copyAttachments(&$toMessage, $fromMessage)
{
$attachtable = mapi_message_getattachmenttable($fromMessage);
$rows = mapi_table_queryallrows($attachtable, array(PR_ATTACH_NUM));
foreach ($rows as $row) {
if (isset($row[PR_ATTACH_NUM])) {
$attach = mapi_message_openattach($fromMessage, $row[PR_ATTACH_NUM]);
$newattach = mapi_message_createattach($toMessage);
// Copy all attachments from old to new attachment
$attachprops = mapi_getprops($attach);
mapi_setprops($newattach, $attachprops);
if (isset($attachprops[mapi_prop_tag(PT_ERROR, mapi_prop_id(PR_ATTACH_DATA_BIN))])) {
// Data is in a stream
$srcstream = mapi_openpropertytostream($attach, PR_ATTACH_DATA_BIN);
$dststream = mapi_openpropertytostream($newattach, PR_ATTACH_DATA_BIN, MAPI_MODIFY | MAPI_CREATE);
while (1) {
$data = mapi_stream_read($srcstream, 4096);
if (strlen($data) == 0) {
break;
}
mapi_stream_write($dststream, $data);
}
mapi_stream_commit($dststream);
}
mapi_savechanges($newattach);
}
}
}
示例3: ImportFolderChange
/**
* Imports a change on a folder
*
* @param object $folder SyncFolder
*
* @access public
* @return string id of the folder
* @throws StatusException
*/
public function ImportFolderChange($folder)
{
$id = isset($folder->serverid) ? $folder->serverid : false;
$parent = $folder->parentid;
$displayname = u2wi($folder->displayname);
$type = $folder->type;
if (Utils::IsSystemFolder($type)) {
throw new StatusException(sprintf("ImportChangesICS->ImportFolderChange('%s','%s','%s'): Error, system folder can not be created/modified", Utils::PrintAsString($folder->serverid), $folder->parentid, $displayname), SYNC_FSSTATUS_SYSTEMFOLDER);
}
// create a new folder if $id is not set
if (!$id) {
// the root folder is "0" - get IPM_SUBTREE
if ($parent == "0") {
$parentprops = mapi_getprops($this->store, array(PR_IPM_SUBTREE_ENTRYID));
if (isset($parentprops[PR_IPM_SUBTREE_ENTRYID])) {
$parentfentryid = $parentprops[PR_IPM_SUBTREE_ENTRYID];
}
} else {
$parentfentryid = mapi_msgstore_entryidfromsourcekey($this->store, hex2bin($parent));
}
if (!$parentfentryid) {
throw new StatusException(sprintf("ImportChangesICS->ImportFolderChange('%s','%s','%s'): Error, unable to open parent folder (no entry id)", Utils::PrintAsString(false), $folder->parentid, $displayname), SYNC_FSSTATUS_PARENTNOTFOUND);
}
$parentfolder = mapi_msgstore_openentry($this->store, $parentfentryid);
if (!$parentfolder) {
throw new StatusException(sprintf("ImportChangesICS->ImportFolderChange('%s','%s','%s'): Error, unable to open parent folder (open entry)", Utils::PrintAsString(false), $folder->parentid, $displayname), SYNC_FSSTATUS_PARENTNOTFOUND);
}
// mapi_folder_createfolder() fails if a folder with this name already exists -> MAPI_E_COLLISION
$newfolder = mapi_folder_createfolder($parentfolder, $displayname, "");
if (mapi_last_hresult()) {
throw new StatusException(sprintf("ImportChangesICS->ImportFolderChange('%s','%s','%s'): Error, mapi_folder_createfolder() failed: 0x%X", Utils::PrintAsString(false), $folder->parentid, $displayname, mapi_last_hresult()), SYNC_FSSTATUS_FOLDEREXISTS);
}
mapi_setprops($newfolder, array(PR_CONTAINER_CLASS => MAPIUtils::GetContainerClassFromFolderType($type)));
$props = mapi_getprops($newfolder, array(PR_SOURCE_KEY));
if (isset($props[PR_SOURCE_KEY])) {
$sourcekey = bin2hex($props[PR_SOURCE_KEY]);
ZLog::Write(LOGLEVEL_DEBUG, sprintf("Created folder '%s' with id: '%s'", $displayname, $sourcekey));
return $sourcekey;
} else {
throw new StatusException(sprintf("ImportChangesICS->ImportFolderChange('%s','%s','%s'): Error, folder created but PR_SOURCE_KEY not available: 0x%X", Utils::PrintAsString($folder->serverid), $folder->parentid, $displayname, mapi_last_hresult()), SYNC_FSSTATUS_SERVERERROR);
}
return false;
}
// update folder
$entryid = mapi_msgstore_entryidfromsourcekey($this->store, hex2bin($id));
if (!$entryid) {
throw new StatusException(sprintf("ImportChangesICS->ImportFolderChange('%s','%s','%s'): Error, unable to open folder (no entry id): 0x%X", Utils::PrintAsString($folder->serverid), $folder->parentid, $displayname, mapi_last_hresult()), SYNC_FSSTATUS_PARENTNOTFOUND);
}
$folder = mapi_msgstore_openentry($this->store, $entryid);
if (!$folder) {
throw new StatusException(sprintf("ImportChangesICS->ImportFolderChange('%s','%s','%s'): Error, unable to open folder (open entry): 0x%X", Utils::PrintAsString($folder->serverid), $folder->parentid, $displayname, mapi_last_hresult()), SYNC_FSSTATUS_PARENTNOTFOUND);
}
$props = mapi_getprops($folder, array(PR_SOURCE_KEY, PR_PARENT_SOURCE_KEY, PR_DISPLAY_NAME, PR_CONTAINER_CLASS));
if (!isset($props[PR_SOURCE_KEY]) || !isset($props[PR_PARENT_SOURCE_KEY]) || !isset($props[PR_DISPLAY_NAME]) || !isset($props[PR_CONTAINER_CLASS])) {
throw new StatusException(sprintf("ImportChangesICS->ImportFolderChange('%s','%s','%s'): Error, folder data not available: 0x%X", Utils::PrintAsString($folder->serverid), $folder->parentid, $displayname, mapi_last_hresult()), SYNC_FSSTATUS_SERVERERROR);
}
if ($parent == "0") {
$parentprops = mapi_getprops($this->store, array(PR_IPM_SUBTREE_ENTRYID));
$parentfentryid = $parentprops[PR_IPM_SUBTREE_ENTRYID];
$mapifolder = mapi_msgstore_openentry($this->store, $parentfentryid);
$rootfolderprops = mapi_getprops($mapifolder, array(PR_SOURCE_KEY));
$parent = bin2hex($rootfolderprops[PR_SOURCE_KEY]);
ZLog::Write(LOGLEVEL_DEBUG, sprintf("ImportChangesICS->ImportFolderChange(): resolved AS parent '0' to sourcekey '%s'", $parent));
}
// In theory the parent id could change, which means that the folder was moved.
// It is unknown if any device supports this, so we do currently not implement it (no known device is able to do this)
if (bin2hex($props[PR_PARENT_SOURCE_KEY]) !== $parent) {
throw new StatusException(sprintf("ImportChangesICS->ImportFolderChange('%s','%s','%s'): Folder was moved to another location, which is currently not supported. Please report this to the Z-Push dev team together with the WBXML log and your device details (model, firmware etc).", Utils::PrintAsString($folder->serverid), $folder->parentid, $displayname, mapi_last_hresult()), SYNC_FSSTATUS_UNKNOWNERROR);
}
$props = array(PR_DISPLAY_NAME => $displayname);
mapi_setprops($folder, $props);
mapi_savechanges($folder);
if (mapi_last_hresult()) {
throw new StatusException(sprintf("ImportChangesICS->ImportFolderChange('%s','%s','%s'): Error, mapi_savechanges() failed: 0x%X", Utils::PrintAsString($folder->serverid), $folder->parentid, $displayname, mapi_last_hresult()), SYNC_FSSTATUS_SERVERERROR);
}
ZLog::Write(LOGLEVEL_DEBUG, "Imported changes for folder: {$id}");
return $id;
}
示例4: _storeAttachment
function _storeAttachment($mapimessage, $part)
{
// attachment
$attach = mapi_message_createattach($mapimessage);
$filename = "";
// Filename is present in both Content-Type: name=.. and in Content-Disposition: filename=
if (isset($part->ctype_parameters["name"])) {
$filename = $part->ctype_parameters["name"];
} else {
if (isset($part->d_parameters["name"])) {
$filename = $part->d_parameters["filename"];
} else {
if (isset($part->d_parameters["filename"])) {
// sending appointment with nokia & android only filename is set
$filename = $part->d_parameters["filename"];
} else {
if (isset($part->d_parameters["filename*0"])) {
for ($i = 0; $i < count($part->d_parameters); $i++) {
if (isset($part->d_parameters["filename*" . $i])) {
$filename .= $part->d_parameters["filename*" . $i];
}
}
} else {
$filename = "untitled";
}
}
}
}
// Android just doesn't send content-type, so mimeDecode doesn't performs base64 decoding
// on meeting requests text/calendar somewhere inside content-transfer-encoding
if (isset($part->headers['content-transfer-encoding']) && strpos($part->headers['content-transfer-encoding'], 'base64')) {
if (strpos($part->headers['content-transfer-encoding'], 'text/calendar') !== false) {
$part->ctype_primary = 'text';
$part->ctype_secondary = 'calendar';
}
if (!isset($part->headers['content-type'])) {
$part->body = base64_decode($part->body);
}
}
// Set filename and attachment type
mapi_setprops($attach, array(PR_ATTACH_LONG_FILENAME => u2wi($filename), PR_ATTACH_METHOD => ATTACH_BY_VALUE));
// Set attachment data
mapi_setprops($attach, array(PR_ATTACH_DATA_BIN => $part->body));
// Set MIME type
mapi_setprops($attach, array(PR_ATTACH_MIME_TAG => $part->ctype_primary . "/" . $part->ctype_secondary));
mapi_savechanges($attach);
}
示例5: createExceptionAttachment
/**
* Function which saves the exception data in an attachment.
* @param array $exception_props the exception data (like any other MAPI appointment)
* @param array $exception_recips list of recipients
* @param mapi_message $copy_attach_from mapi message from which attachments should be copied
* @return array properties of the exception
*/
function createExceptionAttachment($exception_props, $exception_recips = array(), $copy_attach_from = false)
{
// Create new attachment.
$attachment = mapi_message_createattach($this->message);
$props = array();
$props[PR_ATTACHMENT_FLAGS] = 2;
$props[PR_ATTACHMENT_HIDDEN] = true;
$props[PR_ATTACHMENT_LINKID] = 0;
$props[PR_ATTACH_FLAGS] = 0;
$props[PR_ATTACH_METHOD] = 5;
$props[PR_DISPLAY_NAME] = "Exception";
$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"]]);
mapi_message_setprops($attachment, $props);
$imessage = mapi_attach_openobj($attachment, MAPI_CREATE | MAPI_MODIFY);
if ($copy_attach_from) {
$attachmentTable = mapi_message_getattachmenttable($copy_attach_from);
if ($attachmentTable) {
$attachments = mapi_table_queryallrows($attachmentTable, array(PR_ATTACH_NUM, PR_ATTACH_SIZE, PR_ATTACH_LONG_FILENAME, PR_ATTACHMENT_HIDDEN, PR_DISPLAY_NAME, PR_ATTACH_METHOD));
foreach ($attachments as $attach_props) {
$attach_old = mapi_message_openattach($copy_attach_from, (int) $attach_props[PR_ATTACH_NUM]);
$attach_newResourceMsg = mapi_message_createattach($imessage);
mapi_copyto($attach_old, array(), array(), $attach_newResourceMsg, 0);
mapi_savechanges($attach_newResourceMsg);
}
}
}
$props = $props + $exception_props;
// FIXME: the following piece of code is written to fix the creation
// of an exception. This is only a quickfix as it is not yet possible
// to change an existing exception.
// remove mv properties when needed
foreach ($props as $propTag => $propVal) {
if ((mapi_prop_type($propTag) & MV_FLAG) == MV_FLAG && is_null($propVal)) {
unset($props[$propTag]);
}
}
mapi_message_setprops($imessage, $props);
$this->setExceptionRecipients($imessage, $exception_recips, true);
mapi_message_savechanges($imessage);
mapi_message_savechanges($attachment);
}
示例6: updateCard
/**
* Updates a card
*
* @param mixed $addressBookId
* @param string $cardUri
* @param string $cardData
* @return bool
*/
public function updateCard($addressBookId, $cardUri, $cardData)
{
$this->logger->info("updateCard - {$cardUri}");
if (READ_ONLY) {
$this->logger->warn("Cannot update card: read-only");
return false;
}
// Update object properties
$entryId = $this->getContactEntryId($addressBookId, $cardUri);
if ($entryId === 0) {
$this->logger->warn("Cannot find contact");
return false;
}
$mapiProperties = $this->bridge->vcardToMapiProperties($cardData);
$contact = mapi_msgstore_openentry($this->bridge->getStore($addressBookId), $entryId);
if (SAVE_RAW_VCARD) {
// Save RAW vCard
$this->logger->debug("Saving raw vcard");
$mapiProperties[PR_CARDDAV_RAW_DATA] = $cardData;
$mapiProperties[PR_CARDDAV_RAW_DATA_GENERATION_TIME] = time();
} else {
$this->logger->trace("Saving raw vcard skiped by config");
}
// Handle contact picture
if (array_key_exists('ContactPicture', $mapiProperties)) {
$this->logger->debug("Updating contact picture");
$contactPicture = $mapiProperties['ContactPicture'];
unset($mapiProperties['ContactPicture']);
$this->bridge->setContactPicture($contact, $contactPicture);
}
// Remove NULL properties
if (CLEAR_MISSING_PROPERTIES) {
$this->logger->debug("Clearing missing properties");
$nullProperties = array();
foreach ($mapiProperties as $p => $v) {
if ($v == NULL) {
$nullProperties[] = $p;
unset($mapiProperties[$p]);
}
}
$dump = print_r($nullProperties, true);
$this->logger->trace("Removing properties\n{$dump}");
mapi_deleteprops($contact, $nullProperties);
}
// Set properties
$mapiProperties[PR_LAST_MODIFICATION_TIME] = time();
mapi_setprops($contact, $mapiProperties);
// Save changes to backend
mapi_savechanges($contact);
return mapi_last_hresult() == 0;
}
示例7: ImportFolderChange
//.........这里部分代码省略.........
$displayname = u2wi($folder->displayname);
$type = $folder->type;
if (Utils::IsSystemFolder($type)) {
throw new StatusException(sprintf("ImportChangesICS->ImportFolderChange('%s','%s','%s'): Error, system folder can not be created/modified", Utils::PrintAsString($folder->serverid), $folder->parentid, $displayname), SYNC_FSSTATUS_SYSTEMFOLDER);
}
// create a new folder if $id is not set
if (!$id) {
// the root folder is "0" - get IPM_SUBTREE
if ($parent == "0") {
$parentprops = mapi_getprops($this->store, array(PR_IPM_SUBTREE_ENTRYID));
if (isset($parentprops[PR_IPM_SUBTREE_ENTRYID])) {
$parentfentryid = $parentprops[PR_IPM_SUBTREE_ENTRYID];
}
} else {
$parentfentryid = mapi_msgstore_entryidfromsourcekey($this->store, hex2bin($parent));
}
if (!$parentfentryid) {
throw new StatusException(sprintf("ImportChangesICS->ImportFolderChange('%s','%s','%s'): Error, unable to open parent folder (no entry id)", Utils::PrintAsString(false), $folder->parentid, $displayname), SYNC_FSSTATUS_PARENTNOTFOUND);
}
$parentfolder = mapi_msgstore_openentry($this->store, $parentfentryid);
if (!$parentfolder) {
throw new StatusException(sprintf("ImportChangesICS->ImportFolderChange('%s','%s','%s'): Error, unable to open parent folder (open entry)", Utils::PrintAsString(false), $folder->parentid, $displayname), SYNC_FSSTATUS_PARENTNOTFOUND);
}
// mapi_folder_createfolder() fails if a folder with this name already exists -> MAPI_E_COLLISION
$newfolder = mapi_folder_createfolder($parentfolder, $displayname, "");
if (mapi_last_hresult()) {
throw new StatusException(sprintf("ImportChangesICS->ImportFolderChange('%s','%s','%s'): Error, mapi_folder_createfolder() failed: 0x%X", Utils::PrintAsString(false), $folder->parentid, $displayname, mapi_last_hresult()), SYNC_FSSTATUS_FOLDEREXISTS);
}
mapi_setprops($newfolder, array(PR_CONTAINER_CLASS => MAPIUtils::GetContainerClassFromFolderType($type)));
$props = mapi_getprops($newfolder, array(PR_SOURCE_KEY));
if (isset($props[PR_SOURCE_KEY])) {
$sourcekey = bin2hex($props[PR_SOURCE_KEY]);
ZLog::Write(LOGLEVEL_DEBUG, sprintf("Created folder '%s' with id: '%s'", $displayname, $sourcekey));
return $sourcekey;
} else {
throw new StatusException(sprintf("ImportChangesICS->ImportFolderChange('%s','%s','%s'): Error, folder created but PR_SOURCE_KEY not available: 0x%X", Utils::PrintAsString($folder->serverid), $folder->parentid, $displayname, mapi_last_hresult()), SYNC_FSSTATUS_SERVERERROR);
}
return false;
}
// open folder for update
$entryid = mapi_msgstore_entryidfromsourcekey($this->store, hex2bin($id));
if (!$entryid) {
throw new StatusException(sprintf("ImportChangesICS->ImportFolderChange('%s','%s','%s'): Error, unable to open folder (no entry id): 0x%X", Utils::PrintAsString($folder->serverid), $folder->parentid, $displayname, mapi_last_hresult()), SYNC_FSSTATUS_PARENTNOTFOUND);
}
// check if this is a MAPI default folder
if ($this->mapiprovider->IsMAPIDefaultFolder($entryid)) {
throw new StatusException(sprintf("ImportChangesICS->ImportFolderChange('%s','%s','%s'): Error, MAPI default folder can not be created/modified", Utils::PrintAsString($folder->serverid), $folder->parentid, $displayname), SYNC_FSSTATUS_SYSTEMFOLDER);
}
$mfolder = mapi_msgstore_openentry($this->store, $entryid);
if (!$mfolder) {
throw new StatusException(sprintf("ImportChangesICS->ImportFolderChange('%s','%s','%s'): Error, unable to open folder (open entry): 0x%X", Utils::PrintAsString($folder->serverid), $folder->parentid, $displayname, mapi_last_hresult()), SYNC_FSSTATUS_PARENTNOTFOUND);
}
$props = mapi_getprops($mfolder, array(PR_SOURCE_KEY, PR_PARENT_SOURCE_KEY, PR_DISPLAY_NAME, PR_CONTAINER_CLASS));
if (!isset($props[PR_SOURCE_KEY]) || !isset($props[PR_PARENT_SOURCE_KEY]) || !isset($props[PR_DISPLAY_NAME]) || !isset($props[PR_CONTAINER_CLASS])) {
throw new StatusException(sprintf("ImportChangesICS->ImportFolderChange('%s','%s','%s'): Error, folder data not available: 0x%X", Utils::PrintAsString($folder->serverid), $folder->parentid, $displayname, mapi_last_hresult()), SYNC_FSSTATUS_SERVERERROR);
}
// get the real parent source key from mapi
if ($parent == "0") {
$parentprops = mapi_getprops($this->store, array(PR_IPM_SUBTREE_ENTRYID));
$parentfentryid = $parentprops[PR_IPM_SUBTREE_ENTRYID];
$mapifolder = mapi_msgstore_openentry($this->store, $parentfentryid);
$rootfolderprops = mapi_getprops($mapifolder, array(PR_SOURCE_KEY));
$parent = bin2hex($rootfolderprops[PR_SOURCE_KEY]);
ZLog::Write(LOGLEVEL_DEBUG, sprintf("ImportChangesICS->ImportFolderChange(): resolved AS parent '0' to sourcekey '%s'", $parent));
}
// a changed parent id means that the folder should be moved
if (bin2hex($props[PR_PARENT_SOURCE_KEY]) !== $parent) {
$sourceparentfentryid = mapi_msgstore_entryidfromsourcekey($this->store, $props[PR_PARENT_SOURCE_KEY]);
if (!$sourceparentfentryid) {
throw new StatusException(sprintf("ImportChangesICS->ImportFolderChange('%s','%s','%s'): Error, unable to open parent source folder (no entry id): 0x%X", Utils::PrintAsString($folder->serverid), $folder->parentid, $displayname, mapi_last_hresult()), SYNC_FSSTATUS_PARENTNOTFOUND);
}
$sourceparentfolder = mapi_msgstore_openentry($this->store, $sourceparentfentryid);
if (!$sourceparentfolder) {
throw new StatusException(sprintf("ImportChangesICS->ImportFolderChange('%s','%s','%s'): Error, unable to open parent source folder (open entry): 0x%X", Utils::PrintAsString($folder->serverid), $folder->parentid, $displayname, mapi_last_hresult()), SYNC_FSSTATUS_PARENTNOTFOUND);
}
$destparentfentryid = mapi_msgstore_entryidfromsourcekey($this->store, hex2bin($parent));
if (!$sourceparentfentryid) {
throw new StatusException(sprintf("ImportChangesICS->ImportFolderChange('%s','%s','%s'): Error, unable to open destination folder (no entry id): 0x%X", Utils::PrintAsString($folder->serverid), $folder->parentid, $displayname, mapi_last_hresult()), SYNC_FSSTATUS_SERVERERROR);
}
$destfolder = mapi_msgstore_openentry($this->store, $destparentfentryid);
if (!$destfolder) {
throw new StatusException(sprintf("ImportChangesICS->ImportFolderChange('%s','%s','%s'): Error, unable to open destination folder (open entry): 0x%X", Utils::PrintAsString($folder->serverid), $folder->parentid, $displayname, mapi_last_hresult()), SYNC_FSSTATUS_SERVERERROR);
}
// mapi_folder_copyfolder() fails if a folder with this name already exists -> MAPI_E_COLLISION
if (!mapi_folder_copyfolder($sourceparentfolder, $entryid, $destfolder, $displayname, FOLDER_MOVE)) {
throw new StatusException(sprintf("ImportChangesICS->ImportFolderChange('%s','%s','%s'): Error, unable to move folder: 0x%X", Utils::PrintAsString($folder->serverid), $folder->parentid, $displayname, mapi_last_hresult()), SYNC_FSSTATUS_FOLDEREXISTS);
}
$folderProps = mapi_getprops($mfolder, array(PR_SOURCE_KEY));
return $folderProps[PR_SOURCE_KEY];
}
// update the display name
$props = array(PR_DISPLAY_NAME => $displayname);
mapi_setprops($mfolder, $props);
mapi_savechanges($mfolder);
if (mapi_last_hresult()) {
throw new StatusException(sprintf("ImportChangesICS->ImportFolderChange('%s','%s','%s'): Error, mapi_savechanges() failed: 0x%X", Utils::PrintAsString($folder->serverid), $folder->parentid, $displayname, mapi_last_hresult()), SYNC_FSSTATUS_SERVERERROR);
}
ZLog::Write(LOGLEVEL_DEBUG, "Imported changes for folder: {$id}");
return $id;
}
示例8: SendMail
function SendMail($rfc822, $forward = false, $reply = false, $parent = false)
{
$message = Mail_mimeDecode::decode(array('decode_headers' => true, 'decode_bodies' => true, 'include_bodies' => true, 'input' => $rfc822, 'crlf' => "\r\n", 'charset' => 'utf-8'));
// Open the outbox and create the message there
$storeprops = mapi_getprops($this->_defaultstore, array(PR_IPM_OUTBOX_ENTRYID, PR_IPM_SENTMAIL_ENTRYID));
if (!isset($storeprops[PR_IPM_OUTBOX_ENTRYID])) {
debugLog("Outbox not found to create message");
return false;
}
$outbox = mapi_msgstore_openentry($this->_defaultstore, $storeprops[PR_IPM_OUTBOX_ENTRYID]);
if (!$outbox) {
debugLog("Unable to open outbox");
return false;
}
$mapimessage = mapi_folder_createmessage($outbox);
mapi_setprops($mapimessage, array(PR_SUBJECT => u2w($message->headers["subject"]), PR_SENTMAIL_ENTRYID => $storeprops[PR_IPM_SENTMAIL_ENTRYID], PR_MESSAGE_CLASS => "IPM.Note", PR_MESSAGE_DELIVERY_TIME => time()));
if (isset($message->headers["x-priority"])) {
switch ($message->headers["x-priority"]) {
case 1:
case 2:
$priority = PRIO_URGENT;
$importance = IMPORTANCE_HIGH;
break;
case 4:
case 5:
$priority = PRIO_NONURGENT;
$importance = IMPORTANCE_LOW;
break;
case 3:
default:
$priority = PRIO_NORMAL;
$importance = IMPORTANCE_NORMAL;
break;
}
mapi_setprops($mapimessage, array(PR_IMPORTANCE => $importance, PR_PRIORITY => $priority));
}
$addresses = array();
$toaddr = $ccaddr = $bccaddr = array();
if (isset($message->headers["to"])) {
$toaddr = Mail_RFC822::parseAddressList($message->headers["to"]);
}
if (isset($message->headers["cc"])) {
$ccaddr = Mail_RFC822::parseAddressList($message->headers["cc"]);
}
if (isset($message->headers["bcc"])) {
$bccaddr = Mail_RFC822::parseAddressList($message->headers["bcc"]);
}
// Add recipients
$recips = array();
if (isset($toaddr)) {
foreach (array(MAPI_TO => $toaddr, MAPI_CC => $ccaddr, MAPI_BCC => $bccaddr) as $type => $addrlist) {
foreach ($addrlist as $addr) {
$mapirecip[PR_ADDRTYPE] = "SMTP";
$mapirecip[PR_EMAIL_ADDRESS] = $addr->mailbox . "@" . $addr->host;
if (isset($addr->personal) && strlen($addr->personal) > 0) {
$mapirecip[PR_DISPLAY_NAME] = u2w($addr->personal);
} else {
$mapirecip[PR_DISPLAY_NAME] = $mapirecip[PR_EMAIL_ADDRESS];
}
$mapirecip[PR_RECIPIENT_TYPE] = $type;
$mapirecip[PR_ENTRYID] = mapi_createoneoff($mapirecip[PR_DISPLAY_NAME], $mapirecip[PR_ADDRTYPE], $mapirecip[PR_EMAIL_ADDRESS]);
array_push($recips, $mapirecip);
}
}
}
mapi_message_modifyrecipients($mapimessage, 0, $recips);
// Loop through subparts. We currently only support single-level
// multiparts. The PDA currently only does this because you are adding
// an attachment and the type will be multipart/mixed.
if ($message->ctype_primary == "multipart" && $message->ctype_secondary == "mixed") {
foreach ($message->parts as $part) {
if ($part->ctype_primary == "text") {
$body = u2w($part->body);
} else {
// attachment
$attach = mapi_message_createattach($mapimessage);
// Filename is present in both Content-Type: name=.. and in Content-Disposition: filename=
if (isset($part->ctype_parameters["name"])) {
$filename = $part->ctype_parameters["name"];
} else {
if (isset($part->d_parameters["name"])) {
$filename = $part->d_parameters["filename"];
} else {
$filename = "untitled";
}
}
// Set filename and attachment type
mapi_setprops($attach, array(PR_ATTACH_LONG_FILENAME => u2w($filename), PR_ATTACH_METHOD => ATTACH_BY_VALUE));
// Set attachment data
mapi_setprops($attach, array(PR_ATTACH_DATA_BIN => $part->body));
// Set MIME type
mapi_setprops($attach, array(PR_ATTACH_MIME_TAG => $part->ctype_primary . "/" . $part->ctype_secondary));
mapi_savechanges($attach);
}
}
} else {
$body = u2w($message->body);
}
if ($forward) {
$orig = $forward;
//.........这里部分代码省略.........
示例9: _storeAttachment
function _storeAttachment($mapimessage, $part)
{
// attachment
$attach = mapi_message_createattach($mapimessage);
// Filename is present in both Content-Type: name=.. and in Content-Disposition: filename=
if (isset($part->ctype_parameters["name"])) {
$filename = $part->ctype_parameters["name"];
} else {
if (isset($part->d_parameters["name"])) {
$filename = $part->d_parameters["filename"];
} else {
if (isset($part->d_parameters["filename"])) {
//sending appointment with nokia only filename is set
$filename = $part->d_parameters["filename"];
} else {
$filename = "untitled";
}
}
}
// Set filename and attachment type
mapi_setprops($attach, array(PR_ATTACH_LONG_FILENAME => u2w($filename), PR_ATTACH_METHOD => ATTACH_BY_VALUE));
// Set attachment data
mapi_setprops($attach, array(PR_ATTACH_DATA_BIN => $part->body));
// Set MIME type
mapi_setprops($attach, array(PR_ATTACH_MIME_TAG => $part->ctype_primary . "/" . $part->ctype_secondary));
mapi_savechanges($attach);
}
示例10: setMailingAdress
$props[$properties["mailing_address"]] = 2;
setMailingAdress($props[$properties["business_address_street"]], $props[$properties["business_address_postal_code"]], $props[$properties["business_address_city"]], $props[$properties["business_address_state"]], $props[$properties["business_address_country"]], $props[$properties["business_address"]], $props, $properties);
} elseif (isset($props[$properties["home_address"]])) {
$props[$properties["mailing_address"]] = 1;
setMailingAdress($props[$properties["home_address_street"]], $props[$properties["home_address_postal_code"]], $props[$properties["home_address_city"]], $props[$properties["home_address_state"]], $props[$properties["home_address_country"]], $props[$properties["home_address"]], $props, $properties);
} elseif (isset($props[$properties["other_address"]])) {
$props[$properties["mailing_address"]] = 3;
setMailingAdress($props[$properties["other_address_street"]], $props[$properties["other_address_postal_code"]], $props[$properties["other_address_city"]], $props[$properties["other_address_state"]], $props[$properties["other_address_country"]], $props[$properties["other_address"]], $props, $properties);
}
// if the display name is set, then it is a valid contact: save it to the folder
if (isset($props[$properties["display_name"]])) {
$props[$properties["message_class"]] = "IPM.Contact";
$props[$properties["icon_index"]] = "512";
$message = mapi_folder_createmessage($folder);
mapi_setprops($message, $props);
mapi_savechanges($message);
printf("New contact added \"%s\".\n", $props[$properties["display_name"]]);
}
$i++;
}
// EOF
function getPropIdsFromStrings($store, $mapping)
{
$props = array();
$ids = array("name" => array(), "id" => array(), "guid" => array(), "type" => array());
// this array stores all the information needed to retrieve a named property
$num = 0;
// caching
$guids = array();
foreach ($mapping as $name => $val) {
if (is_string($val)) {
示例11: copyAttachments
/**
* Copies attachments from one message to another.
*
* @param MAPIMessage $toMessage
* @param MAPIMessage $fromMessage
*
* @return void
*/
private function copyAttachments(&$toMessage, $fromMessage)
{
$attachtable = mapi_message_getattachmenttable($fromMessage);
$rows = mapi_table_queryallrows($attachtable, array(PR_ATTACH_NUM));
foreach ($rows as $row) {
if (isset($row[PR_ATTACH_NUM])) {
$attach = mapi_message_openattach($fromMessage, $row[PR_ATTACH_NUM]);
$newattach = mapi_message_createattach($toMessage);
mapi_copyto($attach, array(), array(), $newattach, 0);
mapi_savechanges($newattach);
}
}
}
示例12: setContactPicture
/**
* Assign a contact picture to a contact
* @param entryId contact entry id
* @param contactPicture must be a valid jpeg file. If contactPicture is NULL will remove contact picture from contact if exists
*/
public function setContactPicture(&$contact, $contactPicture)
{
$this->logger->trace("setContactPicture");
// Find if contact picture is already set
$contactAttachment = -1;
$hasattachProp = mapi_getprops($contact, array(PR_HASATTACH));
if ($hasattachProp) {
$attachmentTable = mapi_message_getattachmenttable($contact);
$attachments = mapi_table_queryallrows($attachmentTable, array(PR_ATTACH_NUM, PR_ATTACH_SIZE, PR_ATTACH_LONG_FILENAME, PR_ATTACH_FILENAME, PR_ATTACHMENT_HIDDEN, PR_DISPLAY_NAME, PR_ATTACH_METHOD, PR_ATTACH_CONTENT_ID, PR_ATTACH_MIME_TAG, PR_ATTACHMENT_CONTACTPHOTO, PR_EC_WA_ATTACHMENT_HIDDEN_OVERRIDE));
foreach ($attachments as $attachmentRow) {
if (isset($attachmentRow[PR_ATTACHMENT_CONTACTPHOTO]) && $attachmentRow[PR_ATTACHMENT_CONTACTPHOTO]) {
$contactAttachment = $attachmentRow[PR_ATTACH_NUM];
break;
}
}
}
// Remove existing attachment if necessary
if ($contactAttachment != -1) {
$this->logger->trace("removing existing contact picture");
$attach = mapi_message_deleteattach($contact, $contactAttachment);
}
if ($contactPicture !== NULL) {
$this->logger->debug("Saving contact picture as attachment");
// Create attachment
$attach = mapi_message_createattach($contact);
// Update contact attachment properties
$properties = array(PR_ATTACH_SIZE => strlen($contactPicture), PR_ATTACH_LONG_FILENAME => 'ContactPicture.jpg', PR_ATTACHMENT_HIDDEN => false, PR_DISPLAY_NAME => 'ContactPicture.jpg', PR_ATTACH_METHOD => ATTACH_BY_VALUE, PR_ATTACH_MIME_TAG => 'image/jpeg', PR_ATTACHMENT_CONTACTPHOTO => true, PR_ATTACH_DATA_BIN => $contactPicture, PR_ATTACHMENT_FLAGS => 1, PR_ATTACH_EXTENSION_A => '.jpg', PR_ATTACH_NUM => 1);
mapi_setprops($attach, $properties);
mapi_savechanges($attach);
}
// Test
if (mapi_last_hresult() > 0) {
$this->logger->warn("Error saving contact picture: " . get_mapi_error_name());
} else {
$this->logger->trace("contact picture done");
}
}
示例13: clearSuggestionList
function clearSuggestionList($session, $store, $userName)
{
// create entryid of user's store
$userStoreEntryId = mapi_msgstore_createentryid($store, $userName);
if (!$userStoreEntryId) {
print "Error in creating entryid for user's store - " . $userName . "\n";
return false;
}
// open user's store
$userStore = mapi_openmsgstore($session, $userStoreEntryId);
if (!$userStore) {
print "Error in opening user's store - " . $userName . "\n";
return false;
}
// we are not checking here that property exists or not because it could happen that getprops will return
// MAPI_E_NOT_ENOUGH_MEMORY for very large property, if property does not exists then it will be created
// remove property data, overwirte existing data with a blank string (PT_STRING8)
mapi_setprops($userStore, array(PR_EC_RECIPIENT_HISTORY => ""));
$result = mapi_last_hresult();
if ($result == NOERROR) {
// Save changes
mapi_savechanges($userStore);
return mapi_last_hresult() == NOERROR ? true : false;
}
return false;
}
示例14: import
//.........这里部分代码省略.........
}
// set display name
if (isset($csv_mapping["display_name"]) && isset($line[$csv_mapping["display_name"]])) {
$name = to_windows1252($line[$csv_mapping["display_name"]]);
$propValues[$properties["display_name"]] = $propValues[$properties["subject"]] = $propValues[$properties["fileas"]] = $name;
$propValues[$properties["fileas_selection"]] = -1;
} else {
$propValues[$properties["display_name"]] = $propValues[$properties["subject"]] = $propValues[$properties["fileas"]] = "";
if (isset($propValues[$properties["given_name"]])) {
$propValues[$properties["display_name"]] .= $propValues[$properties["given_name"]];
$propValues[$properties["subject"]] .= $propValues[$properties["given_name"]];
}
if (isset($propValues[$properties["surname"]])) {
if (strlen($propValues[$properties["display_name"]]) > 0) {
$propValues[$properties["display_name"]] .= " " . $propValues[$properties["surname"]];
$propValues[$properties["subject"]] .= " " . $propValues[$properties["surname"]];
} else {
$propValues[$properties["display_name"]] .= $propValues[$properties["surname"]];
$propValues[$properties["subject"]] .= $propValues[$properties["surname"]];
}
}
if (isset($propValues[$properties["surname"]])) {
$propValues[$properties["fileas"]] .= $propValues[$properties["surname"]];
}
if (isset($propValues[$properties["given_name"]])) {
if (strlen($propValues[$properties["fileas"]]) > 0) {
$propValues[$properties["fileas"]] .= ", " . $propValues[$properties["given_name"]];
} else {
$propValues[$properties["fileas"]] .= $propValues[$properties["given_name"]];
}
}
}
$nremails = array();
$abprovidertype = 0;
if (isset($csv_mapping["email_address_1"]) && isset($line[$csv_mapping["email_address_1"]])) {
setEmailAddress($line[$csv_mapping["email_address_1"]], $propValues[$properties["display_name"]], 1, $propValues, $properties, $nremails, $abprovidertype);
}
if (isset($csv_mapping["email_address_2"]) && isset($line[$csv_mapping["email_address_2"]])) {
setEmailAddress($line[$csv_mapping["email_address_2"]], $propValues[$properties["display_name"]], 2, $propValues, $properties, $nremails, $abprovidertype);
}
if (isset($csv_mapping["email_address_3"]) && isset($line[$csv_mapping["email_address_3"]])) {
setEmailAddress($line[$csv_mapping["email_address_3"]], $propValues[$properties["display_name"]], 3, $propValues, $properties, $nremails, $abprovidertype);
}
if (!empty($nremails)) {
$propValues[$properties["address_book_mv"]] = $nremails;
}
$propValues[$properties["address_book_long"]] = $abprovidertype;
//set addresses
if (isset($csv_mapping["home_address_street2"])) {
mergeStreet("home", $line[$csv_mapping["home_address_street2"]], $propValues, $properties);
}
if (isset($csv_mapping["home_address_street3"])) {
mergeStreet("home", $line[$csv_mapping["home_address_street3"]], $propValues, $properties);
}
if (!isset($propValues[$properties["home_address"]]) && isset($propValues[$properties["home_address_street"]]) && isset($propValues[$properties["home_address_postal_code"]]) && isset($propValues[$properties["home_address_city"]]) && isset($propValues[$properties["home_address_state"]]) && isset($propValues[$properties["home_address_country"]])) {
buildAddressString("home", $propValues[$properties["home_address_street"]], $propValues[$properties["home_address_postal_code"]], $propValues[$properties["home_address_city"]], $propValues[$properties["home_address_state"]], $propValues[$properties["home_address_country"]], $propValues, $properties);
}
if (isset($csv_mapping["business_address_street2"])) {
mergeStreet("business", $line[$csv_mapping["business_address_street2"]], $propValues, $properties);
}
if (isset($csv_mapping["business_address_street3"])) {
mergeStreet("business", $line[$csv_mapping["business_address_street3"]], $propValues, $properties);
}
if (!isset($propValues[$properties["business_address"]]) && isset($propValues[$properties["business_address_street"]]) && isset($propValues[$properties["business_address_postal_code"]]) && isset($propValues[$properties["business_address_city"]]) && isset($propValues[$properties["business_address_state"]]) && isset($propValues[$properties["business_address_country"]])) {
buildAddressString("business", $propValues[$properties["business_address_street"]], $propValues[$properties["business_address_postal_code"]], $propValues[$properties["business_address_city"]], $propValues[$properties["business_address_state"]], $propValues[$properties["business_address_country"]], $propValues, $properties);
}
if (isset($csv_mapping["other_address_street2"])) {
mergeStreet("other", $line[$csv_mapping["other_address_street2"]], $propValues, $properties);
}
if (isset($csv_mapping["other_address_street3"])) {
mergeStreet("other", $line[$csv_mapping["other_address_street3"]], $propValues, $properties);
}
if (!isset($propValues[$properties["other_address"]]) && isset($propValues[$properties["other_address_street"]]) && isset($propValues[$properties["other_address_postal_code"]]) && isset($propValues[$properties["other_address_city"]]) && isset($propValues[$properties["other_address_state"]]) && isset($propValues[$properties["other_address_country"]])) {
buildAddressString("other", $propValues[$properties["other_address_street"]], $propValues[$properties["other_address_postal_code"]], $propValues[$properties["other_address_city"]], $propValues[$properties["other_address_state"]], $propValues[$properties["other_address_country"]], $propValues, $properties);
}
if (isset($propValues[$properties["home_address"]])) {
$propValues[$properties["mailing_address"]] = 1;
setMailingAdress($propValues[$properties["home_address_street"]], $propValues[$properties["home_address_postal_code"]], $propValues[$properties["home_address_city"]], $propValues[$properties["home_address_state"]], $propValues[$properties["home_address_country"]], $propValues[$properties["home_address"]], $propValues, $properties);
} elseif (isset($propValues[$properties["business_address"]])) {
$propValues[$properties["mailing_address"]] = 2;
setMailingAdress($propValues[$properties["business_address_street"]], $propValues[$properties["business_address_postal_code"]], $propValues[$properties["business_address_city"]], $propValues[$properties["business_address_state"]], $propValues[$properties["business_address_country"]], $propValues[$properties["business_address"]], $propValues, $properties);
} elseif (isset($propValues[$properties["other_address"]])) {
$propValues[$properties["mailing_address"]] = 3;
setMailingAdress($propValues[$properties["other_address_street"]], $propValues[$properties["other_address_postal_code"]], $propValues[$properties["other_address_city"]], $propValues[$properties["other_address_state"]], $propValues[$properties["other_address_country"]], $propValues[$properties["other_address"]], $propValues, $properties);
}
if (isset($categories) && !empty($categories)) {
setProperty("categories", $categories, $propValues, $properties);
}
// if the display name is set, then it is a valid contact: save it to the folder
if (isset($propValues[$properties["display_name"]])) {
$propValues[$properties["message_class"]] = "IPM.Contact";
$propValues[$properties["icon_index"]] = "512";
$message = mapi_folder_createmessage($folder);
mapi_setprops($message, $propValues);
mapi_savechanges($message);
printf("New contact added: \"%s\".\n", $propValues[$properties["display_name"]]);
}
$i++;
}
}
示例15: checkSignificantChanges
/**
* Checks if there has been any significant changes on appointment/meeting item.
* Significant changes be:
* 1) startdate has been changed
* 2) duedate has been changed OR
* 3) recurrence pattern has been created, modified or removed
*
* @param Array oldProps old props before an update
* @param Number basedate basedate
* @param Boolean isRecurrenceChanged for change in recurrence pattern.
* isRecurrenceChanged true means Recurrence pattern has been changed, so clear all attendees response
*/
function checkSignificantChanges($oldProps, $basedate, $isRecurrenceChanged = false)
{
$message = null;
$attach = null;
// If basedate is specified then we need to open exception message to clear recipient responses
if ($basedate) {
$recurrence = new Recurrence($this->store, $this->message);
if ($recurrence->isException($basedate)) {
$attach = $recurrence->getExceptionAttachment($basedate);
if ($attach) {
$message = mapi_attach_openobj($attach, MAPI_MODIFY);
}
}
} else {
// use normal message or recurring series message
$message = $this->message;
}
if (!$message) {
return;
}
$newProps = mapi_getprops($message, array($this->proptags['startdate'], $this->proptags['duedate'], $this->proptags['updatecounter']));
// Check whether message is updated or not.
if (isset($newProps[$this->proptags['updatecounter']]) && $newProps[$this->proptags['updatecounter']] == 0) {
return;
}
if ($newProps[$this->proptags['startdate']] != $oldProps[$this->proptags['startdate']] || $newProps[$this->proptags['duedate']] != $oldProps[$this->proptags['duedate']] || $isRecurrenceChanged) {
$this->clearRecipientResponse($message);
mapi_setprops($message, array($this->proptags['owner_critical_change'] => time()));
mapi_savechanges($message);
if ($attach) {
// Also save attachment Object.
mapi_savechanges($attach);
}
}
}