本文整理汇总了PHP中mapi_setprops函数的典型用法代码示例。如果您正苦于以下问题:PHP mapi_setprops函数的具体用法?PHP mapi_setprops怎么用?PHP mapi_setprops使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mapi_setprops函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renamefolder
function renamefolder($store, $entryid, $name)
{
if (!$entryid) {
print "Unable to find {$name} folder\n";
return;
}
$folder = mapi_msgstore_openentry($store, $entryid);
if (!$folder) {
print "Unable to open folder " . bin2hex($entryid) . "\n";
return;
}
mapi_setprops($folder, array(PR_DISPLAY_NAME => $name));
if (mapi_last_hresult() != 0) {
print "Unable to rename " . bin2hex($entryid) . " to '{$name}'\n";
} else {
print "Renamed " . bin2hex($entryid) . " to '{$name}'\n";
}
}
示例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: saveRecurrencePattern
//.........这里部分代码省略.........
$type = _('week');
$occSingleDayRank = true;
} else {
$type = _('weeks');
$occSingleDayRank = false;
}
break;
// Monthly
// Monthly
case 0xc:
if ($everyn == 1) {
$type = _('month');
$occSingleDayRank = true;
} else {
$type = _('months');
$occSingleDayRank = false;
}
break;
// Yearly
// Yearly
case 0xd:
if ($everyn <= 12) {
$everyn = 1;
$type = _('year');
$occSingleDayRank = true;
} else {
$everyn = $everyn / 12;
$type = _('years');
$occSingleDayRank = false;
}
break;
}
// get timings of the first occurence
$firstoccstartdate = isset($startocc) ? $start + (int) $startocc * 60 : $start;
$firstoccenddate = isset($endocc) ? $end + (int) $endocc * 60 : $end;
$start = gmdate(_('d-m-Y'), $firstoccstartdate);
$end = gmdate(_('d-m-Y'), $firstoccenddate);
$startocc = gmdate(_('G:i'), $firstoccstartdate);
$endocc = gmdate(_('G:i'), $firstoccenddate);
// Based on the properties, we need to generate the recurrence pattern string.
// This is obviously very easy since we can simply concatenate a bunch of strings,
// however this messes up translations for languages which order their words
// differently.
// To improve translation quality we create a series of default strings, in which
// we only have to fill in the correct variables. The base string is thus selected
// based on the available properties.
if ($term == 0x23) {
// Never ends
if ($occTimeRange) {
if ($occSingleDayRank) {
$pattern = sprintf(_('Occurs every %s effective %s from %s to %s.'), $type, $start, $startocc, $endocc);
} else {
$pattern = sprintf(_('Occurs every %s %s effective %s from %s to %s.'), $everyn, $type, $start, $startocc, $endocc);
}
} else {
if ($occSingleDayRank) {
$pattern = sprintf(_('Occurs every %s effective %s.'), $type, $start);
} else {
$pattern = sprintf(_('Occurs every %s %s effective %s.'), $everyn, $type, $start);
}
}
} else {
if ($term == 0x22) {
// After a number of times
if ($occTimeRange) {
if ($occSingleDayRank) {
$pattern = sprintf(ngettext('Occurs every %s effective %s for %s occurence from %s to %s.', 'Occurs every %s effective %s for %s occurences from %s to %s.', $numocc), $type, $start, $numocc, $startocc, $endocc);
} else {
$pattern = sprintf(ngettext('Occurs every %s %s effective %s for %s occurence from %s to %s.', 'Occurs every %s %s effective %s for %s occurences %s to %s.', $numocc), $everyn, $type, $start, $numocc, $startocc, $endocc);
}
} else {
if ($occSingleDayRank) {
$pattern = sprintf(ngettext('Occurs every %s effective %s for %s occurence.', 'Occurs every %s effective %s for %s occurences.', $numocc), $type, $start, $numocc);
} else {
$pattern = sprintf(ngettext('Occurs every %s %s effective %s for %s occurence.', 'Occurs every %s %s effective %s for %s occurences.', $numocc), $everyn, $type, $start, $numocc);
}
}
} else {
if ($term == 0x21) {
// After the given enddate
if ($occTimeRange) {
if ($occSingleDayRank) {
$pattern = sprintf(_('Occurs every %s effective %s until %s from %s to %s.'), $type, $start, $end, $startocc, $endocc);
} else {
$pattern = sprintf(_('Occurs every %s %s effective %s until %s from %s to %s.'), $everyn, $type, $start, $end, $startocc, $endocc);
}
} else {
if ($occSingleDayRank) {
$pattern = sprintf(_('Occurs every %s effective %s until %s.'), $type, $start, $end);
} else {
$pattern = sprintf(_('Occurs every %s %s effective %s until %s.'), $everyn, $type, $start, $end);
}
}
}
}
}
if (!empty($pattern)) {
mapi_setprops($this->message, array($this->proptags["recurring_pattern"] => $pattern));
}
}
示例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: 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;
}
// 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);
}
//.........这里部分代码省略.........
示例6: ParseSmime
/**
* Function will be used to decode smime messages and convert it to normal messages.
*
* @param MAPISession $session
* @param MAPIStore $store
* @param MAPIAdressBook $addressBook
* @param MAPIMessage $message smime message
*
* @access public
* @return void
*/
public static function ParseSmime($session, $store, $addressBook, &$mapimessage)
{
$props = mapi_getprops($mapimessage, array(PR_MESSAGE_CLASS));
if (isset($props[PR_MESSAGE_CLASS]) && stripos($props[PR_MESSAGE_CLASS], 'IPM.Note.SMIME.MultipartSigned') !== false) {
// this is a signed message. decode it.
$attachTable = mapi_message_getattachmenttable($mapimessage);
$rows = mapi_table_queryallrows($attachTable, array(PR_ATTACH_MIME_TAG, PR_ATTACH_NUM));
$attnum = false;
foreach ($rows as $row) {
if (isset($row[PR_ATTACH_MIME_TAG]) && $row[PR_ATTACH_MIME_TAG] == 'multipart/signed') {
$attnum = $row[PR_ATTACH_NUM];
}
}
if ($attnum !== false) {
$att = mapi_message_openattach($mapimessage, $attnum);
$data = mapi_openproperty($att, PR_ATTACH_DATA_BIN);
mapi_message_deleteattach($mapimessage, $attnum);
mapi_inetmapi_imtomapi($session, $store, $addressBook, $mapimessage, $data, array("parse_smime_signed" => 1));
ZLog::Write(LOGLEVEL_DEBUG, "Convert a smime signed message to a normal message.");
}
mapi_setprops($mapimessage, array(PR_MESSAGE_CLASS => 'IPM.Note.SMIME.MultipartSigned'));
}
// TODO check if we need to do this for encrypted (and signed?) message as well
}
示例7: setReminder
/**
* Function which sets reminder on recurring task after existing occurrence has been deleted or marked complete.
*@param array $nextOccurrence properties of next occurrence
*/
function setReminder($nextOccurrence)
{
$props = array();
if ($nextOccurrence) {
// Check if reminder is reset. Default is 'false'
$reset_reminder = isset($this->messageprops[$this->proptags['reset_reminder']]) ? $this->messageprops[$this->proptags['reset_reminder']] : false;
$reminder = $this->messageprops[$this->proptags['reminder']];
// Either reminder was already set OR reminder was set but was dismissed bty user
if ($reminder || $reset_reminder) {
// Reminder can be set at any time either before or after the duedate, so get duration between the reminder time and duedate
$reminder_time = isset($this->messageprops[$this->proptags['reminder_time']]) ? $this->messageprops[$this->proptags['reminder_time']] : 0;
$reminder_difference = isset($this->messageprops[$this->proptags['duedate']]) ? $this->messageprops[$this->proptags['duedate']] : 0;
$reminder_difference = $reminder_difference - $reminder_time;
// Apply duration to next calculated duedate
$next_reminder_time = $nextOccurrence[$this->proptags['duedate']] - $reminder_difference;
$props[$this->proptags['reminder_time']] = $next_reminder_time;
$props[$this->proptags['flagdueby']] = $next_reminder_time;
$this->action['reminder'] = $props[$this->proptags['reminder']] = true;
}
} else {
// Didn't get next occurrence, probably this is the last occurrence
$props[$this->proptags['reminder']] = false;
$props[$this->proptags['reset_reminder']] = false;
}
if (!empty($props)) {
mapi_setprops($this->message, $props);
}
}
示例8: settingsOOFSEt
/**
* Sets the out of office settings.
*
* @param SyncObject $oof
*
* @access private
* @return void
*/
private function settingsOOFSEt(&$oof)
{
$oof->Status = SYNC_SETTINGSSTATUS_SUCCESS;
$props = array();
if ($oof->oofstate == SYNC_SETTINGSOOF_GLOBAL || $oof->oofstate == SYNC_SETTINGSOOF_TIMEBASED) {
$props[PR_EC_OUTOFOFFICE] = true;
foreach ($oof->oofmessage as $oofmessage) {
if (isset($oofmessage->appliesToInternal)) {
$props[PR_EC_OUTOFOFFICE_MSG] = isset($oofmessage->replymessage) ? u2w($oofmessage->replymessage) : "";
$props[PR_EC_OUTOFOFFICE_SUBJECT] = "Out of office";
}
}
} elseif ($oof->oofstate == SYNC_SETTINGSOOF_DISABLED) {
$props[PR_EC_OUTOFOFFICE] = false;
}
if (!empty($props)) {
@mapi_setprops($this->defaultstore, $props);
$result = mapi_last_hresult();
if ($result != NOERROR) {
ZLog::Write(LOGLEVEL_ERROR, sprintf("Setting oof information failed (%X)", $result));
return false;
}
}
return true;
}
示例9: 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;
//.........这里部分代码省略.........
示例10: 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");
}
}
示例11: setMailingAdress
if (isset($props[$properties["business_address"]])) {
$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) {
示例12: 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;
}
示例13: 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++;
}
}
示例14: 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;
}
示例15: zpa_remove_device
function zpa_remove_device($adminStore, $session, $user, $deviceid)
{
$userEntryId = @mapi_msgstore_createentryid($adminStore, $user);
$userStore = @mapi_openmsgstore($session, $userEntryId);
$hresult = mapi_last_hresult();
if ($hresult != NOERROR) {
echo "Could not open store for {$user}. The script will exit.\n";
exit(1);
}
$devicesprops = mapi_getprops($userStore, array(0x6880101e, 0x6881101e, 0x6882101e, 0x6883101e, 0x68841003, 0x6885101e, 0x6886101e, 0x6887101e, 0x68881040, 0x68891040));
if (isset($devicesprops[0x6881101e]) && is_array($devicesprops[0x6881101e])) {
$ak = array_search($deviceid, $devicesprops[0x6881101e]);
if ($ak !== false) {
if (count($devicesprops[0x6880101e]) == 1) {
mapi_deleteprops($userStore, array(0x6880101e, 0x6881101e, 0x6882101e, 0x6883101e, 0x68841003, 0x6885101e, 0x6886101e, 0x6887101e, 0x68881040, 0x68891040));
} else {
unset($devicesprops[0x6880101e][$ak], $devicesprops[0x6881101e][$ak], $devicesprops[0x6882101e][$ak], $devicesprops[0x6883101e][$ak], $devicesprops[0x68841003][$ak], $devicesprops[0x6885101e][$ak], $devicesprops[0x6886101e][$ak], $devicesprops[0x6887101e][$ak], $devicesprops[0x68881040][$ak], $devicesprops[0x68891040][$ak]);
mapi_setprops($userStore, array(0x6880101e => isset($devicesprops[0x6880101e]) ? $devicesprops[0x6880101e] : array(), 0x6881101e => isset($devicesprops[0x6881101e]) ? $devicesprops[0x6881101e] : array(), 0x6882101e => isset($devicesprops[0x6882101e]) ? $devicesprops[0x6882101e] : array(), 0x6883101e => isset($devicesprops[0x6883101e]) ? $devicesprops[0x6883101e] : array(), 0x68841003 => isset($devicesprops[0x68841003]) ? $devicesprops[0x68841003] : array(), 0x6885101e => isset($devicesprops[0x6885101e]) ? $devicesprops[0x6885101e] : array(), 0x6886101e => isset($devicesprops[0x6886101e]) ? $devicesprops[0x6886101e] : array(), 0x6887101e => isset($devicesprops[0x6887101e]) ? $devicesprops[0x6887101e] : array(), 0x68881040 => isset($devicesprops[0x68881040]) ? $devicesprops[0x68881040] : array(), 0x68891040 => isset($devicesprops[0x68891040]) ? $devicesprops[0x68891040] : array()));
}
$hresult = mapi_last_hresult();
if ($hresult != NOERROR) {
echo "Could not remove device from list for {$user}. Errorcode 0x" . sprintf("%x", $hresult) . ". The script will exit.\n";
exit(1);
} else {
echo "Removed device from list.\n";
}
} else {
echo "No device found with the given id.\n";
exit(1);
}
} else {
echo "No devices found for the user {$user}.\n";
exit(1);
}
}