本文整理汇总了PHP中mapi_getprops函数的典型用法代码示例。如果您正苦于以下问题:PHP mapi_getprops函数的具体用法?PHP mapi_getprops怎么用?PHP mapi_getprops使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mapi_getprops函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ExportChangesICS
/**
* Constructor
*
* @param mapisession $session
* @param mapistore $store
* @param string (opt)
*
* @access public
* @throws StatusException
*/
public function ExportChangesICS($session, $store, $folderid = false)
{
// Open a hierarchy or a contents exporter depending on whether a folderid was specified
$this->session = $session;
$this->folderid = $folderid;
$this->store = $store;
$this->restriction = false;
try {
if ($folderid) {
$entryid = mapi_msgstore_entryidfromsourcekey($store, $folderid);
} else {
$storeprops = mapi_getprops($this->store, array(PR_IPM_SUBTREE_ENTRYID));
$entryid = $storeprops[PR_IPM_SUBTREE_ENTRYID];
}
$folder = false;
if ($entryid) {
$folder = mapi_msgstore_openentry($this->store, $entryid);
}
// Get the actual ICS exporter
if ($folderid) {
if ($folder) {
$this->exporter = mapi_openproperty($folder, PR_CONTENTS_SYNCHRONIZER, IID_IExchangeExportChanges, 0, 0);
} else {
$this->exporter = false;
}
} else {
$this->exporter = mapi_openproperty($folder, PR_HIERARCHY_SYNCHRONIZER, IID_IExchangeExportChanges, 0, 0);
}
} catch (MAPIException $me) {
$this->exporter = false;
// We return the general error SYNC_FSSTATUS_CODEUNKNOWN (12) which is also SYNC_STATUS_FOLDERHIERARCHYCHANGED (12)
// if this happened while doing content sync, the mobile will try to resync the folderhierarchy
throw new StatusException(sprintf("ExportChangesICS('%s','%s','%s'): Error, unable to open folder: 0x%X", $session, $store, Utils::PrintAsString($folderid), mapi_last_hresult()), SYNC_FSSTATUS_CODEUNKNOWN);
}
}
示例2: isUnicodeStore
function isUnicodeStore($store)
{
$supportmask = mapi_getprops($store, array(PR_STORE_SUPPORT_MASK));
if (isset($supportmask[PR_STORE_SUPPORT_MASK]) && $supportmask[PR_STORE_SUPPORT_MASK] & STORE_UNICODE_OK) {
print "Store supports properties containing Unicode characters.\n";
define('STORE_SUPPORTS_UNICODE', true);
} else {
print "Store does not support properties containing Unicode characters.\n";
define('STORE_SUPPORTS_UNICODE', false);
}
}
示例3: publishFreeBusy
/**
* Publishing the FreeBusy information of the default calendar. The
* folderentryid argument is used to check if the default calendar
* should be updated or not.
*
* @param $store MAPIobject Store object of the store that needs publishing
* @param $folderentryid binary entryid of the folder that needs to be updated.
*/
function publishFreeBusy($store, $l_rSession, $folderentryid = false)
{
// Publish updated free/busy information
// First get default calendar from the root folder
$rootFolder = mapi_msgstore_openentry($store, null);
$rootFolderProps = mapi_getprops($rootFolder, array(PR_IPM_APPOINTMENT_ENTRYID));
// If no folderentryid supplied or if the supplied entryid matches the default calendar.
if (!$folderentryid || $rootFolderProps[PR_IPM_APPOINTMENT_ENTRYID] == $folderentryid) {
// Get the calendar and owner entryID
$calendar = mapi_msgstore_openentry($store, $rootFolderProps[PR_IPM_APPOINTMENT_ENTRYID]);
$storeProps = mapi_msgstore_getprops($store, array(PR_MAILBOX_OWNER_ENTRYID));
if (isset($storeProps[PR_MAILBOX_OWNER_ENTRYID])) {
// Lets share!
$pub = new FreeBusyPublish($l_rSession, $store, $calendar, $storeProps[PR_MAILBOX_OWNER_ENTRYID]);
$pub->publishFB(time() - 7 * 24 * 60 * 60, 6 * 30 * 24 * 60 * 60);
// publish from one week ago, 6 months ahead
}
}
}
示例4: isZPushEnabled
/**
* Checks if the user is not disabled for Z-Push.
*
* @access private
* @throws FatalException if user is disabled for Z-Push
*
* @return boolean
*/
private function isZPushEnabled()
{
$addressbook = $this->getAddressbook();
$userEntryid = mapi_getprops($this->store, array(PR_MAILBOX_OWNER_ENTRYID));
$mailuser = mapi_ab_openentry($addressbook, $userEntryid[PR_MAILBOX_OWNER_ENTRYID]);
$enabledFeatures = mapi_getprops($mailuser, array(PR_EC_DISABLED_FEATURES));
if (isset($enabledFeatures[PR_EC_DISABLED_FEATURES]) && is_array($enabledFeatures[PR_EC_DISABLED_FEATURES]) && in_array(self::ZPUSH_ENABLED, $enabledFeatures[PR_EC_DISABLED_FEATURES])) {
throw new FatalException("User is disabled for Z-Push.");
}
return true;
}
示例5: getDelegatorStore
function getDelegatorStore($messageprops)
{
// Find the organiser of appointment in addressbook
$delegatorName = array(array(PR_DISPLAY_NAME => $messageprops[PR_RCVD_REPRESENTING_NAME]));
$ab = mapi_openaddressbook($this->session);
$user = mapi_ab_resolvename($ab, $delegatorName, EMS_AB_ADDRESS_LOOKUP);
// Get StoreEntryID by username
$delegatorEntryid = mapi_msgstore_createentryid($this->store, $user[0][PR_EMAIL_ADDRESS]);
// Open store of the delegator
$delegatorStore = mapi_openmsgstore($this->session, $delegatorEntryid);
// Open root folder
$delegatorRoot = mapi_msgstore_openentry($delegatorStore, null);
// Get calendar entryID
$delegatorRootProps = mapi_getprops($delegatorRoot, array(PR_IPM_APPOINTMENT_ENTRYID));
// Open the calendar Folder
$calFolder = mapi_msgstore_openentry($delegatorStore, $delegatorRootProps[PR_IPM_APPOINTMENT_ENTRYID]);
return array('store' => $delegatorStore, 'calFolder' => $calFolder);
}
示例6: getPrivateContactFolders
/**
* Get the private contact folder of all users
*/
function getPrivateContactFolders($session, $defaultstore)
{
$addrbook = mapi_openaddressbook($session);
$addr_entryid = mapi_ab_getdefaultdir($addrbook);
$abcontainer = mapi_ab_openentry($addrbook, $addr_entryid);
$contentstable = mapi_folder_getcontentstable($abcontainer);
// restrict table on only MAPI_MAILUSER accounts
mapi_table_restrict($contentstable, array(RES_PROPERTY, array(RELOP => RELOP_EQ, ULPROPTAG => PR_OBJECT_TYPE, VALUE => array(PR_OBJECT_TYPE => MAPI_MAILUSER))));
// sort table on display name
mapi_table_sort($contentstable, array(PR_DISPLAY_NAME => TABLE_SORT_ASCEND));
$users = mapi_table_queryrows($contentstable, array(PR_ACCOUNT, PR_ENTRYID, PR_DISPLAY_NAME), 0, mapi_table_getrowcount($contentstable));
$contactArray = array();
for ($i = 0; $i < sizeof($users); $i++) {
$store_entryid = mapi_msgstore_createentryid($defaultstore, $users[$i][PR_ACCOUNT]);
$store = mapi_openmsgstore($session, $store_entryid);
$rootcontainer = mapi_msgstore_openentry($store);
if ($rootcontainer) {
$props = mapi_getprops($rootcontainer, array(PR_IPM_CONTACT_ENTRYID));
if (isset($props[PR_IPM_CONTACT_ENTRYID])) {
$entryid = $props[PR_IPM_CONTACT_ENTRYID];
$folder = mapi_msgstore_openentry($store, $entryid);
if ($folder) {
$table = mapi_folder_getcontentstable($folder);
$totalrow = mapi_table_getrowcount($table);
$rows = array();
$contacts = array();
$properties = getContactProperties($defaultstore);
if ($totalrow > 0) {
$rows = mapi_table_queryrows($table, $properties, 0, $totalrow);
for ($j = 0; $j < sizeof($rows); $j++) {
$rows[$j][268370178] = md5($rows[$j][268370178]);
}
for ($k = 0; $k < sizeof($rows); $k++) {
// do not add private contacts
if (!array_key_exists(-2119827445, $rows[$k]) || array_key_exists(-2119827445, $rows[$k]) && $rows[$k][-2119827445] != 1) {
foreach ($rows[$k] as $key => $value) {
$attribute = mapKey($key);
if ($attribute != "") {
$contacts[$k][$attribute] = $value;
}
}
}
}
$contactArray[] = array("username" => $users[$i][PR_ACCOUNT], "contacts" => $contacts);
}
}
}
}
}
// print_r($contactArray);
return $contactArray;
}
示例7: getInboxProps
/**
* Gets the required inbox properties.
*
* @access private
* @return array
*/
private function getInboxProps()
{
if (!isset($this->inboxProps) || empty($this->inboxProps)) {
ZLog::Write(LOGLEVEL_DEBUG, "MAPIProvider->getInboxProps(): Getting inbox properties.");
$inbox = mapi_msgstore_getreceivefolder($this->store);
$this->inboxProps = mapi_getprops($inbox, array(PR_ENTRYID, PR_IPM_DRAFTS_ENTRYID, PR_IPM_TASK_ENTRYID, PR_IPM_APPOINTMENT_ENTRYID, PR_IPM_CONTACT_ENTRYID, PR_IPM_NOTE_ENTRYID, PR_IPM_JOURNAL_ENTRYID));
}
return $this->inboxProps;
}
示例8: 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;
}
示例9: getSearchFoldersRoot
/**
* Function will open FINDER_ROOT folder in root container
* public folder's don't have FINDER_ROOT folder
*
* @see getSearchFoldersRoot($store) function in the webaccess
*
* @return mapiFolderObject root folder for search folders
*/
private function getSearchFoldersRoot()
{
// check if we can create search folders
$storeProps = mapi_getprops($this->store, array(PR_STORE_SUPPORT_MASK, PR_FINDER_ENTRYID));
if (($storeProps[PR_STORE_SUPPORT_MASK] & STORE_SEARCH_OK) != STORE_SEARCH_OK) {
ZLog::Write(LOGLEVEL_WARN, "Store doesn't support search folders. Public store doesn't have FINDER_ROOT folder");
return false;
}
// open search folders root
$searchRootFolder = mapi_msgstore_openentry($this->store, $storeProps[PR_FINDER_ENTRYID]);
if (mapi_last_hresult() != NOERROR) {
ZLog::Write(LOGLEVEL_WARN, sprintf("Unable to open search folder (0x%X)", mapi_last_hresult()));
return false;
}
return $searchRootFolder;
}
示例10: saveRecurrence
//.........这里部分代码省略.........
break;
}
// UTC date
$utcstart = $this->toGMT($this->tz, (int) $this->recur["start"]);
$utcend = $this->toGMT($this->tz, (int) $this->recur["end"]);
//utc date+time
$utcfirstoccstartdatetime = isset($this->recur["startocc"]) ? $utcstart + (int) $this->recur["startocc"] * 60 : $utcstart;
$utcfirstoccenddatetime = isset($this->recur["endocc"]) ? $utcstart + (int) $this->recur["endocc"] * 60 : $utcstart;
// update reminder time
mapi_setprops($this->message, array($this->proptags["reminder_time"] => $utcfirstoccstartdatetime));
// update first occurrence date
mapi_setprops($this->message, array($this->proptags["startdate"] => $utcfirstoccstartdatetime));
mapi_setprops($this->message, array($this->proptags["duedate"] => $utcfirstoccenddatetime));
mapi_setprops($this->message, array($this->proptags["commonstart"] => $utcfirstoccstartdatetime));
mapi_setprops($this->message, array($this->proptags["commonend"] => $utcfirstoccenddatetime));
// Set Outlook properties, if it is an appointment
if (isset($this->recur["message_class"]) && $this->recur["message_class"] == "IPM.Appointment") {
// update real begin and real end date
mapi_setprops($this->message, array($this->proptags["startdate_recurring"] => $utcstart));
mapi_setprops($this->message, array($this->proptags["enddate_recurring"] => $utcend));
// recurrencetype
// Strange enough is the property recurrencetype, (type-0x9) and not the CDO recurrencetype
mapi_setprops($this->message, array($this->proptags["recurrencetype"] => (int) $this->recur["type"] - 0x9));
// set named prop 'side_effects' to 369, needed for Outlook to ask for single or total recurrence when deleting
mapi_setprops($this->message, array($this->proptags["side_effects"] => 369));
} else {
mapi_setprops($this->message, array($this->proptags["side_effects"] => 3441));
}
// FlagDueBy is datetime of the first reminder occurrence. Outlook gives on this time a reminder popup dialog
// Any change of the recurrence (including changing and deleting exceptions) causes the flagdueby to be reset
// to the 'next' occurrence; this makes sure that deleting the next ocurrence will correctly set the reminder to
// the occurrence after that. The 'next' occurrence is defined as being the first occurrence that starts at moment X (server time)
// with the reminder flag set.
$reminderprops = mapi_getprops($this->message, array($this->proptags["reminder_minutes"]));
if (isset($reminderprops[$this->proptags["reminder_minutes"]])) {
$occ = false;
$occurrences = $this->getItems(time(), 0x7ff00000, 3, true);
for ($i = 0, $len = count($occurrences); $i < $len; $i++) {
// This will actually also give us appointments that have already started, but not yet ended. Since we want the next
// reminder that occurs after time(), we may have to skip the first few entries. We get 3 entries since that is the maximum
// number that would be needed (assuming reminder for item X cannot be before the previous occurrence starts). Worst case:
// time() is currently after start but before end of item, but reminder of next item has already passed (reminder for next item
// can be DURING the previous item, eg daily allday events). In that case, the first and second items must be skipped.
if ($occurrences[$i][$this->proptags["startdate"]] - $reminderprops[$this->proptags["reminder_minutes"]] * 60 > time()) {
$occ = $occurrences[$i];
break;
}
}
if ($occ) {
mapi_setprops($this->message, array($this->proptags["flagdueby"] => $occ[$this->proptags["startdate"]] - $reminderprops[$this->proptags["reminder_minutes"]] * 60));
} else {
// Last reminder passed, no reminders any more.
mapi_setprops($this->message, array($this->proptags["reminder"] => false, $this->proptags["flagdueby"] => 0x7ff00000));
}
}
// Default data
// Second item (0x08) indicates the Outlook version (see documentation at the bottom of this file for more information)
$rdata .= pack("VCCCC", 0x3006, 0x8, 0x30, 0x0, 0x0);
if (isset($this->recur["startocc"]) && isset($this->recur["endocc"])) {
// Set start and endtime in minutes
$rdata .= pack("VV", (int) $this->recur["startocc"], (int) $this->recur["endocc"]);
}
// Detailed exception data
$changed_items = $this->recur["changed_occurences"];
$rdata .= pack("v", count($changed_items));
foreach ($changed_items as $changed_item) {
示例11: _isUnicodeStore
function _isUnicodeStore()
{
$supportmask = mapi_getprops($this->_defaultstore, array(PR_STORE_SUPPORT_MASK));
if (isset($supportmask[PR_STORE_SUPPORT_MASK]) && $supportmask[PR_STORE_SUPPORT_MASK] & STORE_UNICODE_OK) {
debugLog("Store supports properties containing Unicode characters.");
define('STORE_SUPPORTS_UNICODE', true);
//setlocale to UTF-8 in order to support properties containing Unicode characters
//dw2412 this is nice but it does not work if for Heartbeat sync where during the sync something reverts the locale to i.e. "C"
// since setlocale works on process level...
setlocale(LC_CTYPE, 'en_US.utf-8');
}
}
示例12: getSMTPAddressFromEntryID
/**
* Returns an SMTP address from an entry id
*
* @param string $entryid
*
* @access private
* @return string
*/
private function getSMTPAddressFromEntryID($entryid)
{
$ab = mapi_openaddressbook($this->session);
$mailuser = mapi_ab_openentry($ab, $entryid);
if (!$mailuser) {
return "";
}
$props = mapi_getprops($mailuser, array(PR_ADDRTYPE, PR_SMTP_ADDRESS, PR_EMAIL_ADDRESS));
$addrtype = isset($props[PR_ADDRTYPE]) ? $props[PR_ADDRTYPE] : "";
if (isset($props[PR_SMTP_ADDRESS])) {
return $props[PR_SMTP_ADDRESS];
}
if ($addrtype == "SMTP" && isset($props[PR_EMAIL_ADDRESS])) {
return $props[PR_EMAIL_ADDRESS];
}
return "";
}
示例13: mapi_table_queryallrows
$l_aTableRows = mapi_table_queryallrows($l_rTableStores, array(PR_ENTRYID, PR_DEFAULT_STORE));
echo (mapi_last_hresult() == 0 ? "Fetching Deleted Folder..." : "Some error in fetching...") . "\n";
$l_bbnEntryID = false;
// Either boolean or binary
// Loop through returned rows
for ($i = 0; $i < count($l_aTableRows); $i++) {
// Check to see if this entry is the default store
if (isset($l_aTableRows[$i][PR_DEFAULT_STORE]) && $l_aTableRows[$i][PR_DEFAULT_STORE] == true) {
$storeEntryId = $l_aTableRows[$i][PR_ENTRYID];
break;
}
}
// check if default root store's entry id found
if ($storeEntryId) {
$store = mapi_openmsgstore($l_rSession, $storeEntryId);
$delStoreProps = mapi_getprops($store, array(PR_IPM_WASTEBASKET_ENTRYID));
$deletedFolder = mapi_msgstore_openentry($store, $delStoreProps[PR_IPM_WASTEBASKET_ENTRYID]);
$table = mapi_folder_getcontentstable($deletedFolder);
$delRows = mapi_table_queryallrows($table, array(PR_ENTRYID, PR_CREATION_TIME));
echo (mapi_last_hresult() == 0 ? "Fetching messages from Deleted Folder..." : "Some error in fetching...") . "\n";
if (count($delRows) > 0) {
$delEntryIds = array();
echo 'Total messages in deleted folder found are : ' . count($delRows) . "\n";
for ($i = 0; $i < count($delRows); $i++) {
if (greaterDate(date("Y-m-d G:i:s", $delRows[$i][PR_CREATION_TIME]), $daysBeforeDeleted)) {
array_push($delEntryIds, $delRows[$i][PR_ENTRYID]);
}
}
if (count($delEntryIds) > 0) {
echo "\nDeleting all " . count($delEntryIds) . " messages...\n";
mapi_folder_deletemessages($deletedFolder, $delEntryIds);
示例14: propertiesToVObject
/**
* Convert vObject to an array of properties
* @param array $properties
* @param object $vCard
*/
public function propertiesToVObject($contact, &$vCard)
{
$this->logger->debug("Generating contact vCard from properties");
$p = $this->bridge->getExtendedProperties();
$contactProperties = mapi_getprops($contact);
// $this->bridge->getProperties($contactId);
$dump = print_r($contactProperties, true);
$this->logger->trace("Contact properties:\n{$contactProperties}");
// Version check
switch ($this->version) {
case 2:
$vCard->add('VERSION', '2.1');
break;
case 3:
$vCard->add('VERSION', '3.0');
break;
case 4:
$vCard->add('VERSION', '4.0');
break;
default:
$this->logger->fatal("Unrecognised VCard version: " . $this->version);
return;
}
// Private contact ?
if (isset($contactProperties[$p['private']]) && $contactProperties[$p['private']]) {
$vCard->add('CLASS', 'PRIVATE');
// Not in VCARD 4.0 but keep it for compatibility
}
// Mandatory FN
$this->setVCard($vCard, 'FN', $contactProperties, $p['display_name']);
// Contact name and pro information
// N property
/*
Special note: The structured property value corresponds, in
sequence, to the Family Names (also known as surnames), Given
Names, Additional Names, Honorific Prefixes, and Honorific
Suffixes. The text components are separated by the SEMICOLON
character (U+003B). Individual text components can include
multiple text values separated by the COMMA character (U+002C).
This property is based on the semantics of the X.520 individual
name attributes [CCITT.X520.1988]. The property SHOULD be present
in the vCard object when the name of the object the vCard
represents follows the X.520 model.
The SORT-AS parameter MAY be applied to this property.
*/
$contactInfos = array();
$contactInfos[] = isset($contactProperties[$p['surname']]) ? $contactProperties[$p['surname']] : '';
$contactInfos[] = isset($contactProperties[$p['given_name']]) ? $contactProperties[$p['given_name']] : '';
$contactInfos[] = isset($contactProperties[$p['middle_name']]) ? $contactProperties[$p['middle_name']] : '';
$contactInfos[] = isset($contactProperties[$p['display_name_prefix']]) ? $contactProperties[$p['display_name_prefix']] : '';
$contactInfos[] = isset($contactProperties[$p['generation']]) ? $contactProperties[$p['generation']] : '';
$element = new Sabre_VObject_Property("N");
$element->setValue(implode(';', $contactInfos));
// $element->offsetSet("SORT-AS", '"' . $contactProperties[$p['fileas']] . '"');
$vCard->add($element);
$this->setVCard($vCard, 'SORT-AS', $contactProperties, $p['fileas']);
$this->setVCard($vCard, 'NICKNAME', $contactProperties, $p['nickname']);
$this->setVCard($vCard, 'TITLE', $contactProperties, $p['title']);
$this->setVCard($vCard, 'ROLE', $contactProperties, $p['profession']);
$this->setVCard($vCard, 'ORG', $contactProperties, $p['company_name']);
$this->setVCard($vCard, 'OFFICE', $contactProperties, $p['office_location']);
if ($this->version >= 4) {
if (isset($contactProperties[$p['assistant']])) {
if (!empty($contactProperties[$p['assistant']])) {
$element = new Sabre_VObject_Property('RELATED');
$element->setValue($contactProperties[$p['assistant']]);
$element->offsetSet('TYPE', 'assistant');
// Not RFC compliant
$vCard->add($element);
}
}
if (isset($contactProperties[$p['manager_name']])) {
if (!empty($contactProperties[$p['manager_name']])) {
$element = new Sabre_VObject_Property('RELATED');
$element->setValue($contactProperties[$p['manager_name']]);
$element->offsetSet('TYPE', 'manager');
// Not RFC compliant
$vCard->add($element);
}
}
if (isset($contactProperties[$p['spouse_name']])) {
if (!empty($contactProperties[$p['spouse_name']])) {
$element = new Sabre_VObject_Property('RELATED');
$element->setValue($contactProperties[$p['spouse_name']]);
$element->offsetSet('TYPE', 'spouse');
$vCard->add($element);
}
}
}
// older syntax - may be needed by some clients so keep it!
$this->setVCard($vCard, 'X-MS-ASSISTANT', $contactProperties, $p['assistant']);
$this->setVCard($vCard, 'X-MS-MANAGER', $contactProperties, $p['manager_name']);
$this->setVCard($vCard, 'X-MS-SPOUSE', $contactProperties, $p['spouse_name']);
// Dates
//.........这里部分代码省略.........
示例15: resolveRecipientContact
/**
* Resolves recipient from the contact list and gets his certificates.
*
* @param string $to
*
* @return SyncResolveRecipient|boolean
*/
private function resolveRecipientContact($to)
{
// go through all contact folders of the user and
// check if there's a contact with the given email address
$root = mapi_msgstore_openentry($this->defaultstore);
if (!$root) {
ZLog::Write(LOGLEVEL_ERROR, sprintf("Unable to open default store: 0x%X", mapi_last_hresult));
}
$rootprops = mapi_getprops($root, array(PR_IPM_CONTACT_ENTRYID));
$contacts = $this->getContactsFromFolder($this->defaultstore, $rootprops[PR_IPM_CONTACT_ENTRYID], $to);
$recipients = array();
if ($contacts !== false) {
// create resolve recipient object
foreach ($contacts as $contact) {
$certificates = isset($contact[PR_USER_X509_CERTIFICATE]) && is_array($contact[PR_USER_X509_CERTIFICATE]) && count($contact[PR_USER_X509_CERTIFICATE]) ? $this->getCertificates($contact[PR_USER_X509_CERTIFICATE], 1) : false;
if ($certificates !== false) {
return $this->createResolveRecipient(SYNC_RESOLVERECIPIENTS_TYPE_CONTACT, u2w($contact[PR_DISPLAY_NAME]), $to, $certificates);
}
}
}
$contactfolder = mapi_msgstore_openentry($this->defaultstore, $rootprops[PR_IPM_CONTACT_ENTRYID]);
$subfolders = MAPIUtils::GetSubfoldersForType($contactfolder, "IPF.Contact");
foreach ($subfolders as $folder) {
$contacts = $this->getContactsFromFolder($this->defaultstore, $folder[PR_ENTRYID], $to);
if ($contacts !== false) {
foreach ($contacts as $contact) {
$certificates = isset($contact[PR_USER_X509_CERTIFICATE]) && is_array($contact[PR_USER_X509_CERTIFICATE]) && count($contact[PR_USER_X509_CERTIFICATE]) ? $this->getCertificates($contact[PR_USER_X509_CERTIFICATE], 1) : false;
if ($certificates !== false) {
return $this->createResolveRecipient(SYNC_RESOLVERECIPIENTS_TYPE_CONTACT, u2w($contact[PR_DISPLAY_NAME]), $to, $certificates);
}
}
}
}
// search contacts in public folders
$storestables = mapi_getmsgstorestable($this->session);
$result = mapi_last_hresult();
if ($result == NOERROR) {
$rows = mapi_table_queryallrows($storestables, array(PR_ENTRYID, PR_DEFAULT_STORE, PR_MDB_PROVIDER));
foreach ($rows as $row) {
if (isset($row[PR_MDB_PROVIDER]) && $row[PR_MDB_PROVIDER] == ZARAFA_STORE_PUBLIC_GUID) {
// TODO refactor public store
$publicstore = mapi_openmsgstore($this->session, $row[PR_ENTRYID]);
$publicfolder = mapi_msgstore_openentry($publicstore);
$subfolders = MAPIUtils::GetSubfoldersForType($publicfolder, "IPF.Contact");
if ($subfolders !== false) {
foreach ($subfolders as $folder) {
$contacts = $this->getContactsFromFolder($publicstore, $folder[PR_ENTRYID], $to);
if ($contacts !== false) {
foreach ($contacts as $contact) {
$certificates = isset($contact[PR_USER_X509_CERTIFICATE]) && is_array($contact[PR_USER_X509_CERTIFICATE]) && count($contact[PR_USER_X509_CERTIFICATE]) ? $this->getCertificates($contact[PR_USER_X509_CERTIFICATE], 1) : false;
if ($certificates !== false) {
return $this->createResolveRecipient(SYNC_RESOLVERECIPIENTS_TYPE_CONTACT, u2w($contact[PR_DISPLAY_NAME]), $to, $certificates);
}
}
}
}
}
break;
}
}
} else {
ZLog::Write(LOGLEVEL_WARN, sprintf("Unable to open public store: 0x%X", $result));
}
$certificates = $this->getCertificates(false);
return $this->createResolveRecipient(SYNC_RESOLVERECIPIENTS_TYPE_CONTACT, $to, $to, $certificates);
}