本文整理汇总了PHP中mapi_openmsgstore函数的典型用法代码示例。如果您正苦于以下问题:PHP mapi_openmsgstore函数的具体用法?PHP mapi_openmsgstore怎么用?PHP mapi_openmsgstore使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mapi_openmsgstore函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exit
if (!$session) {
print "Unable to open session\n";
exit(1);
}
$msgstorestable = mapi_getmsgstorestable($session);
if (!$msgstorestable) {
print "Unable to open message stores table\n";
exit(1);
}
$msgstores = mapi_table_queryallrows($msgstorestable, array(PR_DEFAULT_STORE, PR_ENTRYID));
foreach ($msgstores as $row) {
if ($row[PR_DEFAULT_STORE]) {
$default_store_entry_id = $row[PR_ENTRYID];
}
}
$default_store = mapi_openmsgstore($session, $default_store_entry_id);
if (!$default_store) {
print "Unable to open default store\n";
exit(1);
}
$root = mapi_msgstore_openentry($default_store);
// get folders
$folders = mapi_folder_gethierarchytable($root, CONVENIENT_DEPTH);
// loop over every folder
while (1) {
$rows = mapi_table_queryrows($folders, array(PR_DISPLAY_NAME, PR_FOLDER_TYPE, PR_ENTRYID), 0, 100);
if (count($rows) == 0) {
break;
}
foreach ($rows as $row) {
// skip searchfolders
示例2: getDefaultStore
function getDefaultStore()
{
$table = mapi_getmsgstorestable($this->session);
$rows = mapi_table_queryallrows($table, array(PR_DEFAULT_STORE, PR_ENTRYID));
foreach ($rows as $row) {
if ($row[PR_DEFAULT_STORE]) {
return mapi_openmsgstore($this->session, $row[PR_ENTRYID]);
}
}
return false;
}
示例3: UpdateFB
function UpdateFB($addressbook, $session, $rootstore, $entryid)
{
$abentry = mapi_ab_openentry($addressbook, $entryid);
if (!$abentry) {
print "Unable to open entry in addressbook\n";
return false;
}
$abprops = mapi_getprops($abentry, array(PR_ACCOUNT));
$storeid = mapi_msgstore_createentryid($rootstore, $abprops[PR_ACCOUNT]);
if (!$storeid) {
print "Unable to get store entryid\n";
return false;
}
$store = mapi_openmsgstore($session, $storeid);
if (!$store) {
print "Unable to open store\n";
return false;
}
$root = mapi_msgstore_openentry($store);
if (!$root) {
print "Unable to open root folder\n";
return false;
}
$rootprops = mapi_getprops($root, array(PR_IPM_APPOINTMENT_ENTRYID));
$calendar = mapi_msgstore_openentry($store, $rootprops[PR_IPM_APPOINTMENT_ENTRYID]);
$fbupdate = new FreeBusyPublish($session, $store, $calendar, $entryid);
$fbupdate->publishFB(0, 0);
// publish from one week ago, 6 months ahead
return true;
}
示例4: 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);
}
示例5: openMsgStore
function openMsgStore($username, $password)
{
$session = mapi_logon_zarafa($username, $password, SERVER);
if (mapi_last_hresult() != 0) {
trigger_error(sprintf("MAPI Error: 0x%x", mapi_last_hresult()), E_USER_ERROR);
}
$storesTable = mapi_getmsgstorestable($session);
$stores = mapi_table_queryallrows($storesTable, array(PR_ENTRYID, PR_MDB_PROVIDER));
for ($i = 0; $i < count($stores); $i++) {
if ($stores[$i][PR_MDB_PROVIDER] == ZARAFA_SERVICE_GUID) {
$storeEntryid = $stores[$i][PR_ENTRYID];
break;
}
}
if (!isset($storeEntryid)) {
trigger_error("Default store not found", E_USER_ERROR);
}
$store = mapi_openmsgstore($session, $storeEntryid);
isUnicodeStore($store);
return $store;
}
示例6: 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);
}
}
示例7: 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;
}
示例8: mapi_logon_zarafa
$session = mapi_logon_zarafa($username, $password, SERVER);
if (mapi_last_hresult() != 0) {
trigger_error(sprintf("MAPI Error: 0x%x", mapi_last_hresult()), E_USER_ERROR);
}
$storesTable = mapi_getmsgstorestable($session);
$stores = mapi_table_queryallrows($storesTable, array(PR_ENTRYID, PR_MDB_PROVIDER));
for ($i = 0; $i < count($stores); $i++) {
if ($stores[$i][PR_MDB_PROVIDER] == ZARAFA_SERVICE_GUID) {
$storeEntryid = $stores[$i][PR_ENTRYID];
break;
}
}
if (!isset($storeEntryid)) {
trigger_error("Default store not found", E_USER_ERROR);
}
$store = mapi_openmsgstore($session, $storeEntryid);
$root = mapi_msgstore_openentry($store, null);
$rootProps = mapi_getprops($root, array(PR_IPM_CONTACT_ENTRYID));
$folder = mapi_msgstore_openentry($store, $rootProps[PR_IPM_CONTACT_ENTRYID]);
isUnicodeStore($store);
// open the csv file and start reading
$fh = fopen($csv_file, "r");
if (!$fh) {
trigger_error("Can't open CSV file \"" . $csv_file . "\"", E_USER_ERROR);
}
// empty folder if needed
if (EMPTY_FOLDER) {
mapi_folder_emptyfolder($folder, DEL_ASSOCIATED);
}
$properties = array();
loadProperties($properties);
示例9: 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);
}
示例10: 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;
}
示例11: connect
/**
* Connect to Zarafa and do some init
* @param $user user login
* @param $password user password
*/
public function connect($user, $password)
{
$this->logger->debug("connect({$user}," . md5($password) . ")");
$this->session = NULL;
try {
$session = mapi_logon_zarafa($user, $password, ZARAFA_SERVER);
} catch (Exception $e) {
$this->logger->debug("connection failed: " . get_mapi_error_name());
return false;
}
if ($session === FALSE) {
// Failed
return false;
}
$this->logger->trace("Connected to zarafa server - init bridge");
$this->session = $session;
// Find user store
$storesTable = mapi_getmsgstorestable($session);
$stores = mapi_table_queryallrows($storesTable, array(PR_ENTRYID, PR_MDB_PROVIDER));
for ($i = 0; $i < count($stores); $i++) {
switch ($stores[$i][PR_MDB_PROVIDER]) {
case ZARAFA_SERVICE_GUID:
$storeEntryid = $stores[$i][PR_ENTRYID];
break;
case ZARAFA_STORE_PUBLIC_GUID:
$pubStoreEntryid = $stores[$i][PR_ENTRYID];
break;
}
}
if (!isset($storeEntryid)) {
trigger_error("Default store not found", E_USER_ERROR);
}
$this->store = mapi_openmsgstore($this->session, $storeEntryid);
$root = mapi_msgstore_openentry($this->store, null);
$rootProps = mapi_getprops($root, array(PR_IPM_CONTACT_ENTRYID));
// Store rootfolder
$this->rootFolder = mapi_msgstore_openentry($this->store, $rootProps[PR_IPM_CONTACT_ENTRYID]);
$this->rootFolderId = $rootProps[PR_IPM_CONTACT_ENTRYID];
if (isset($pubStoreEntryid)) {
$this->pubStore = mapi_openmsgstore($this->session, $pubStoreEntryid);
$pubFolder = mapi_msgstore_openentry($this->pubStore);
$h_table = mapi_folder_gethierarchytable($pubFolder, CONVENIENT_DEPTH);
// $subfolders = mapi_table_queryallrows($h_table, array(PR_ENTRYID, PR_DISPLAY_NAME));
$subfolders = mapi_table_queryallrows($h_table);
for ($i = 0; $i < count($subfolders); $i++) {
$name = $subfolders[$i][PR_DISPLAY_NAME];
$entryid = $subfolders[$i][PR_ENTRYID];
$folder = mapi_msgstore_openentry($this->pubStore, $entryid);
$props = mapi_getprops($folder);
if (isset($props[PR_CONTAINER_CLASS_A]) && $props[PR_CONTAINER_CLASS_A] == "IPF.Contact") {
$this->pubFolderIds[] = $entryid;
$this->pubFolders[] = mapi_msgstore_openentry($this->pubStore, $entryid);
}
}
}
// Check for unicode
$this->isUnicodeStore($this->store);
// Load properties
$this->initProperties();
// Store username for principals
$this->connectedUser = $user;
// Set protected variable to NULL.
$this->adressBooks = NULL;
return true;
}
示例12: define
define("ZARAFA_PASS", "");
require MAPI_PATH . "mapi.util.php";
require MAPI_PATH . "mapicode.php";
require MAPI_PATH . "mapidefs.php";
require MAPI_PATH . "mapitags.php";
require MAPI_PATH . "mapiguid.php";
$supported_classes = array("IPF.Note" => "SYNC_FOLDER_TYPE_USER_MAIL", "IPF.Task" => "SYNC_FOLDER_TYPE_USER_TASK", "IPF.Appointment" => "SYNC_FOLDER_TYPE_USER_APPOINTMENT", "IPF.Contact" => "SYNC_FOLDER_TYPE_USER_CONTACT", "IPF.StickyNote" => "SYNC_FOLDER_TYPE_USER_NOTE");
$session = @mapi_logon_zarafa(ZARAFA_USER, ZARAFA_PASS, ZARAFA_SERVER);
if (!$session) {
die("Login to Zarafa failed\n");
}
$storetable = @mapi_getmsgstorestable($session);
$storeslist = @mapi_table_queryallrows($storetable, array(PR_ENTRYID, PR_MDB_PROVIDER));
for ($i = 0; $i < count($storeslist); $i++) {
if ($storeslist[$i][PR_MDB_PROVIDER] == ZARAFA_STORE_PUBLIC_GUID) {
$publicstore = @mapi_openmsgstore($session, $storeslist[$i][PR_ENTRYID]);
break;
}
}
if (!isset($publicstore)) {
die("Public folder not available");
}
$pub_folder = @mapi_msgstore_openentry($publicstore);
$h_table = @mapi_folder_gethierarchytable($pub_folder, CONVENIENT_DEPTH);
$subfolders = @mapi_table_queryallrows($h_table, array(PR_ENTRYID, PR_DISPLAY_NAME, PR_CONTAINER_CLASS, PR_SOURCE_KEY));
echo "Available folders in public folder:\n" . str_repeat("-", 50) . "\n";
foreach ($subfolders as $folder) {
if (isset($folder[PR_CONTAINER_CLASS]) && array_key_exists($folder[PR_CONTAINER_CLASS], $supported_classes)) {
echo "Name:\t\t" . $folder[PR_DISPLAY_NAME] . "\n";
echo "Sync-class:\t" . $supported_classes[$folder[PR_CONTAINER_CLASS]] . "\n";
echo "PUID:\t\t" . bin2hex($folder[PR_SOURCE_KEY]) . "\n\n";
示例13: open_zarafa
/**
* open_zarafa
*
* @param descriptor An open Zarafa session id.
* @return array Array with session and store information.
*/
function open_zarafa($session)
{
$ret = array("root" => "/");
$storesTable = mapi_getmsgstorestable($session);
$stores = mapi_table_queryallrows($storesTable, array(PR_ENTRYID, PR_MDB_PROVIDER));
for ($i = 0; $i < count($stores); $i++) {
if ($stores[$i][PR_MDB_PROVIDER] == ZARAFA_SERVICE_GUID) {
$storeEntryid = $stores[$i][PR_ENTRYID];
break;
}
}
if (!isset($storeEntryid)) {
trigger_error("Default store not found", PR_USER_ERROR);
}
$store = mapi_openmsgstore($session, $storeEntryid);
$root = mapi_msgstore_openentry($store, null);
$rootProps = mapi_getprops($root, array(PR_IPM_CONTACT_ENTRYID));
$folder = mapi_msgstore_openentry($store, $rootProps[PR_IPM_CONTACT_ENTRYID]);
$table = mapi_folder_getcontentstable($folder);
$contacts = mapi_table_queryallrows($table);
$ret["session"] = $session;
$ret["store"] = $store;
$ret["contacts"] = $contacts;
// ZCP 7 and up know unicode...
$supportmask = mapi_getprops($store, array(PR_STORE_SUPPORT_MASK));
if (isset($supportmask[PR_STORE_SUPPORT_MASK]) && $supportmask[PR_STORE_SUPPORT_MASK] & STORE_UNICODE_OK) {
$ret["unicode_store"] = true;
setlocale(LC_CTYPE, 'en_US.utf-8');
}
// END ZCP7 and up know unicode
return $ret;
}
示例14: listfolders_getlist
function listfolders_getlist($adminStore, $session, $user)
{
global $supported_classes;
if (strtoupper($user) == 'SYSTEM') {
// Find the public store store
$storestables = @mapi_getmsgstorestable($session);
$result = @mapi_last_hresult();
if ($result == NOERROR) {
$rows = @mapi_table_queryallrows($storestables, array(PR_ENTRYID, PR_MDB_PROVIDER));
foreach ($rows as $row) {
if (isset($row[PR_MDB_PROVIDER]) && $row[PR_MDB_PROVIDER] == ZARAFA_STORE_PUBLIC_GUID) {
if (!isset($row[PR_ENTRYID])) {
echo "Public folder are not available.\nIf this is a multi-tenancy system, use -u and -p and login with an admin user of the company.\nThe script will exit.\n";
exit(1);
}
$entryid = $row[PR_ENTRYID];
break;
}
}
}
} else {
$entryid = @mapi_msgstore_createentryid($adminStore, $user);
}
$userStore = @mapi_openmsgstore($session, $entryid);
$hresult = mapi_last_hresult();
// Cache the store for later use
if ($hresult != NOERROR) {
echo "Could not open store for '{$user}'. The script will exit.\n";
exit(1);
}
if (strtoupper($user) != 'SYSTEM') {
$inbox = mapi_msgstore_getreceivefolder($userStore);
if (mapi_last_hresult() != NOERROR) {
printf("Could not open inbox for %s (0x%08X). The script will exit.\n", $user, mapi_last_hresult());
exit(1);
}
$inboxProps = mapi_getprops($inbox, array(PR_SOURCE_KEY));
}
$storeProps = mapi_getprops($userStore, array(PR_IPM_OUTBOX_ENTRYID, PR_IPM_SENTMAIL_ENTRYID, PR_IPM_WASTEBASKET_ENTRYID));
$root = @mapi_msgstore_openentry($userStore, null);
$h_table = @mapi_folder_gethierarchytable($root, CONVENIENT_DEPTH);
$subfolders = @mapi_table_queryallrows($h_table, array(PR_ENTRYID, PR_DISPLAY_NAME, PR_CONTAINER_CLASS, PR_SOURCE_KEY, PR_PARENT_SOURCE_KEY, PR_FOLDER_TYPE, PR_ATTR_HIDDEN));
echo "Available folders in store '{$user}':\n" . str_repeat("-", 50) . "\n";
foreach ($subfolders as $folder) {
// do not display hidden and search folders
if (isset($folder[PR_ATTR_HIDDEN]) && $folder[PR_ATTR_HIDDEN] || isset($folder[PR_FOLDER_TYPE]) && $folder[PR_FOLDER_TYPE] == FOLDER_SEARCH) {
continue;
}
// handle some special folders
if (strtoupper($user) != 'SYSTEM' && (isset($inboxProps[PR_SOURCE_KEY]) && $folder[PR_SOURCE_KEY] == $inboxProps[PR_SOURCE_KEY] || $folder[PR_ENTRYID] == $storeProps[PR_IPM_SENTMAIL_ENTRYID] || $folder[PR_ENTRYID] == $storeProps[PR_IPM_WASTEBASKET_ENTRYID])) {
$folder[PR_CONTAINER_CLASS] = "IPF.Note";
}
if (isset($folder[PR_CONTAINER_CLASS]) && array_key_exists($folder[PR_CONTAINER_CLASS], $supported_classes)) {
echo "Folder name:\t" . $folder[PR_DISPLAY_NAME] . "\n";
echo "Folder ID:\t" . bin2hex($folder[PR_SOURCE_KEY]) . "\n";
echo "Type:\t\t" . $supported_classes[$folder[PR_CONTAINER_CLASS]] . "\n";
echo "\n";
}
}
}
示例15: _openDefaultMessageStore
function _openDefaultMessageStore($session)
{
// Find the default store
$storestables = mapi_getmsgstorestable($session);
$result = mapi_last_hresult();
$entryid = false;
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_DEFAULT_STORE]) && $row[PR_DEFAULT_STORE] == true) {
$entryid = $row[PR_ENTRYID];
break;
}
}
}
if ($entryid) {
return mapi_openmsgstore($session, $entryid);
} else {
return false;
}
}