/** * Indicates if the entry id is a default MAPI folder * * @param string $entryid * * @access public * @return boolean */ public function IsMAPIDefaultFolder($entryid) { $msgstore_props = mapi_getprops($this->store, array(PR_ENTRYID, PR_DISPLAY_NAME, PR_IPM_SUBTREE_ENTRYID, PR_IPM_OUTBOX_ENTRYID, PR_IPM_SENTMAIL_ENTRYID, PR_IPM_WASTEBASKET_ENTRYID, PR_MDB_PROVIDER, PR_IPM_PUBLIC_FOLDERS_ENTRYID, PR_IPM_FAVORITES_ENTRYID, PR_MAILBOX_OWNER_ENTRYID)); $inboxProps = array(); $inbox = mapi_msgstore_getreceivefolder($this->store); if (!mapi_last_hresult()) { $inboxProps = mapi_getprops($inbox, array(PR_ENTRYID)); } $root = mapi_msgstore_openentry($this->store, null); $rootProps = mapi_getprops($root, array(PR_IPM_APPOINTMENT_ENTRYID, PR_IPM_CONTACT_ENTRYID, PR_IPM_DRAFTS_ENTRYID, PR_IPM_JOURNAL_ENTRYID, PR_IPM_NOTE_ENTRYID, PR_IPM_TASK_ENTRYID, PR_ADDITIONAL_REN_ENTRYIDS)); $additional_ren_entryids = array(); if (isset($rootProps[PR_ADDITIONAL_REN_ENTRYIDS])) { $additional_ren_entryids = $rootProps[PR_ADDITIONAL_REN_ENTRYIDS]; } $defaultfolders = array("inbox" => array("inbox" => PR_ENTRYID), "outbox" => array("store" => PR_IPM_OUTBOX_ENTRYID), "sent" => array("store" => PR_IPM_SENTMAIL_ENTRYID), "wastebasket" => array("store" => PR_IPM_WASTEBASKET_ENTRYID), "favorites" => array("store" => PR_IPM_FAVORITES_ENTRYID), "publicfolders" => array("store" => PR_IPM_PUBLIC_FOLDERS_ENTRYID), "calendar" => array("root" => PR_IPM_APPOINTMENT_ENTRYID), "contact" => array("root" => PR_IPM_CONTACT_ENTRYID), "drafts" => array("root" => PR_IPM_DRAFTS_ENTRYID), "journal" => array("root" => PR_IPM_JOURNAL_ENTRYID), "note" => array("root" => PR_IPM_NOTE_ENTRYID), "task" => array("root" => PR_IPM_TASK_ENTRYID), "junk" => array("additional" => 4), "syncissues" => array("additional" => 1), "conflicts" => array("additional" => 0), "localfailures" => array("additional" => 2), "serverfailures" => array("additional" => 3)); foreach ($defaultfolders as $key => $prop) { $tag = reset($prop); $from = key($prop); switch ($from) { case "inbox": if (isset($inboxProps[$tag]) && $entryid == $inboxProps[$tag]) { ZLog::Write(LOGLEVEL_DEBUG, sprintf("MAPIProvider->IsMAPIFolder(): Inbox found, key '%s'", $key)); return true; } break; case "store": if (isset($msgstore_props[$tag]) && $entryid == $msgstore_props[$tag]) { ZLog::Write(LOGLEVEL_DEBUG, sprintf("MAPIProvider->IsMAPIFolder(): Store folder found, key '%s'", $key)); return true; } break; case "root": if (isset($rootProps[$tag]) && $entryid == $rootProps[$tag]) { ZLog::Write(LOGLEVEL_DEBUG, sprintf("MAPIProvider->IsMAPIFolder(): Root folder found, key '%s'", $key)); return true; } break; case "additional": if (isset($additional_ren_entryids[$tag]) && $entryid == $additional_ren_entryids[$tag]) { ZLog::Write(LOGLEVEL_DEBUG, sprintf("MAPIProvider->IsMAPIFolder(): Additional folder found, key '%s'", $key)); return true; } } } return false; }
function getDefaultFolderEntryID($prop) { try { $inbox = mapi_msgstore_getreceivefolder($this->store); } catch (MAPIException $e) { // public store doesn't support this method if ($e->getCode() == MAPI_E_NO_SUPPORT) { // don't propogate this error to parent handlers, if store doesn't support it $e->setHandled(); return; } } $inboxprops = mapi_getprops($inbox, array($prop)); if (!isset($inboxprops[$prop])) { return; } return $inboxprops[$prop]; }
if (!$store) { print "Unable to open system store\n"; exit(1); } $userstoreentryid = mapi_msgstore_createentryid($store, $argv[1]); if (!$userstoreentryid) { print "Unknown user\n"; exit(1); } $userstore = mapi_openmsgstore($session, $userstoreentryid); if (!$userstore) { print "Unable to open user store\n"; exit(1); } isUnicodeStore($userstore); $inbox = mapi_msgstore_getreceivefolder($userstore); $root = mapi_msgstore_openentry($userstore); $storeprops = mapi_getprops($userstore, array(PR_IPM_SENTMAIL_ENTRYID, PR_IPM_OUTBOX_ENTRYID, PR_IPM_WASTEBASKET_ENTRYID)); $inboxprops = mapi_getprops($inbox, array(PR_ENTRYID, PR_IPM_APPOINTMENT_ENTRYID, PR_IPM_CONTACT_ENTRYID, PR_IPM_DRAFTS_ENTRYID, PR_IPM_JOURNAL_ENTRYID, PR_IPM_NOTE_ENTRYID, PR_IPM_TASK_ENTRYID)); $rootprops = mapi_getprops($root, array(PR_ADDITIONAL_REN_ENTRYIDS)); $trans_array = translate($argv[2]); renamefolder($userstore, $storeprops[PR_IPM_SENTMAIL_ENTRYID], utf8_decode($trans_array["Sent Items"])); renamefolder($userstore, $storeprops[PR_IPM_OUTBOX_ENTRYID], utf8_decode($trans_array["Outbox"])); renamefolder($userstore, $storeprops[PR_IPM_WASTEBASKET_ENTRYID], utf8_decode($trans_array["Deleted Items"])); renamefolder($userstore, $inboxprops[PR_ENTRYID], utf8_decode($trans_array["Inbox"])); renamefolder($userstore, $inboxprops[PR_IPM_APPOINTMENT_ENTRYID], utf8_decode($trans_array["Calendar"])); renamefolder($userstore, $inboxprops[PR_IPM_CONTACT_ENTRYID], $trans_array["Contacts"]); renamefolder($userstore, $inboxprops[PR_IPM_DRAFTS_ENTRYID], $trans_array["Drafts"]); renamefolder($userstore, $inboxprops[PR_IPM_JOURNAL_ENTRYID], $trans_array["Journal"]); renamefolder($userstore, $inboxprops[PR_IPM_NOTE_ENTRYID], utf8_decode($trans_array["Notes"])); renamefolder($userstore, $inboxprops[PR_IPM_TASK_ENTRYID], utf8_decode($trans_array["Tasks"]));
function _getFolderType($entryid) { $storeprops = mapi_getprops($this->_store, array(PR_IPM_OUTBOX_ENTRYID, PR_IPM_WASTEBASKET_ENTRYID, PR_IPM_SENTMAIL_ENTRYID)); $inbox = mapi_msgstore_getreceivefolder($this->_store); $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)); if ($entryid == $inboxprops[PR_ENTRYID]) { return SYNC_FOLDER_TYPE_INBOX; } if ($entryid == $inboxprops[PR_IPM_DRAFTS_ENTRYID]) { return SYNC_FOLDER_TYPE_DRAFTS; } if ($entryid == $storeprops[PR_IPM_WASTEBASKET_ENTRYID]) { return SYNC_FOLDER_TYPE_WASTEBASKET; } if ($entryid == $storeprops[PR_IPM_SENTMAIL_ENTRYID]) { return SYNC_FOLDER_TYPE_SENTMAIL; } if ($entryid == $storeprops[PR_IPM_OUTBOX_ENTRYID]) { return SYNC_FOLDER_TYPE_OUTBOX; } if ($entryid == $inboxprops[PR_IPM_TASK_ENTRYID]) { return SYNC_FOLDER_TYPE_TASK; } if ($entryid == $inboxprops[PR_IPM_APPOINTMENT_ENTRYID]) { return SYNC_FOLDER_TYPE_APPOINTMENT; } if ($entryid == $inboxprops[PR_IPM_CONTACT_ENTRYID]) { return SYNC_FOLDER_TYPE_CONTACT; } if ($entryid == $inboxprops[PR_IPM_NOTE_ENTRYID]) { return SYNC_FOLDER_TYPE_NOTE; } if ($entryid == $inboxprops[PR_IPM_JOURNAL_ENTRYID]) { return SYNC_FOLDER_TYPE_JOURNAL; } return SYNC_FOLDER_TYPE_OTHER; }
/** * 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; }
/** Deletes incoming task request from Inbox * * @returns array returns PR_ENTRYID, PR_STORE_ENTRYID and PR_PARENT_ENTRYID of the deleted task request */ function deleteReceivedTR() { $store = $this->getTaskFolderStore(); $inbox = mapi_msgstore_getreceivefolder($store); $storeProps = mapi_getprops($store, array(PR_IPM_WASTEBASKET_ENTRYID)); $props = mapi_getprops($this->message, array($this->props['taskglobalobjid'])); $globalobjid = $props[$this->props['taskglobalobjid']]; // Find the task by looking for the taskglobalobjid $restriction = array(RES_PROPERTY, array(RELOP => RELOP_EQ, ULPROPTAG => $this->props['taskglobalobjid'], VALUE => $globalobjid)); $contents = mapi_folder_getcontentstable($inbox); $rows = mapi_table_queryallrows($contents, array(PR_ENTRYID, PR_PARENT_ENTRYID, PR_STORE_ENTRYID), $restriction); $taskrequest = false; if (!empty($rows)) { // If there are multiple, just use the first $entryid = $rows[0][PR_ENTRYID]; $wastebasket = mapi_msgstore_openentry($store, $storeProps[PR_IPM_WASTEBASKET_ENTRYID]); mapi_folder_copymessages($inbox, array($entryid), $wastebasket, MESSAGE_MOVE); return array(PR_ENTRYID => $entryid, PR_PARENT_ENTRYID => $rows[0][PR_PARENT_ENTRYID], PR_STORE_ENTRYID => $rows[0][PR_STORE_ENTRYID]); } return false; }
function PHPHierarchyImportProxy($store, &$importer) { $this->importer =& $importer; $this->_store = $store; // dw2412: moved from different functions in here to improve performance since these values should not change // ever during sync. $this->_storeprops = mapi_getprops($this->_store, array(PR_IPM_SUBTREE_ENTRYID, PR_IPM_OUTBOX_ENTRYID, PR_IPM_WASTEBASKET_ENTRYID, PR_IPM_SENTMAIL_ENTRYID)); $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)); }
/** * Returns the foldertype for an entryid * Gets the folder type by checking the default folders in MAPI * * @param string $entryid * @param string $class (opt) * * @access public * @return long */ public function GetFolderType($entryid, $class = false) { $storeprops = mapi_getprops($this->store, array(PR_IPM_OUTBOX_ENTRYID, PR_IPM_WASTEBASKET_ENTRYID, PR_IPM_SENTMAIL_ENTRYID)); $inbox = mapi_msgstore_getreceivefolder($this->store); $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)); if ($entryid == $inboxprops[PR_ENTRYID]) { return SYNC_FOLDER_TYPE_INBOX; } if ($entryid == $inboxprops[PR_IPM_DRAFTS_ENTRYID]) { return SYNC_FOLDER_TYPE_DRAFTS; } if ($entryid == $storeprops[PR_IPM_WASTEBASKET_ENTRYID]) { return SYNC_FOLDER_TYPE_WASTEBASKET; } if ($entryid == $storeprops[PR_IPM_SENTMAIL_ENTRYID]) { return SYNC_FOLDER_TYPE_SENTMAIL; } if ($entryid == $storeprops[PR_IPM_OUTBOX_ENTRYID]) { return SYNC_FOLDER_TYPE_OUTBOX; } if ($entryid == $inboxprops[PR_IPM_TASK_ENTRYID]) { return SYNC_FOLDER_TYPE_TASK; } if ($entryid == $inboxprops[PR_IPM_APPOINTMENT_ENTRYID]) { return SYNC_FOLDER_TYPE_APPOINTMENT; } if ($entryid == $inboxprops[PR_IPM_CONTACT_ENTRYID]) { return SYNC_FOLDER_TYPE_CONTACT; } if ($entryid == $inboxprops[PR_IPM_NOTE_ENTRYID]) { return SYNC_FOLDER_TYPE_NOTE; } if ($entryid == $inboxprops[PR_IPM_JOURNAL_ENTRYID]) { return SYNC_FOLDER_TYPE_JOURNAL; } // user created folders if ($class == "IPF.Note") { return SYNC_FOLDER_TYPE_USER_MAIL; } if ($class == "IPF.Task") { return SYNC_FOLDER_TYPE_USER_TASK; } if ($class == "IPF.Appointment") { return SYNC_FOLDER_TYPE_USER_APPOINTMENT; } if ($class == "IPF.Contact") { return SYNC_FOLDER_TYPE_USER_CONTACT; } if ($class == "IPF.StickyNote") { return SYNC_FOLDER_TYPE_USER_NOTE; } if ($class == "IPF.Journal") { return SYNC_FOLDER_TYPE_USER_JOURNAL; } return SYNC_FOLDER_TYPE_OTHER; }
// 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) { $l_bbnEntryID = $l_aTableRows[$i][PR_ENTRYID]; break; } } // check if default root store's entry id found if ($l_bbnEntryID) { // Open msg store by using the entryID $l_rDefaultStore = mapi_openmsgstore($l_rSession, $l_bbnEntryID); echo 'Opening default store result (0=success): ' . mapi_last_hresult() . "\n"; // Get inbox $l_rInbox = mapi_msgstore_getreceivefolder($l_rDefaultStore); echo 'Getting entryID of inbox folder result (0=success): ' . mapi_last_hresult() . "\n"; // Check if folder has been opened if ($l_rInbox) { // Open contents table $l_rInboxTable = mapi_folder_getcontentstable($l_rInbox); echo 'Opening contents table result (0=success): ' . mapi_last_hresult() . "\n"; // Find the item by restricting all items to the correct ID $restrict = array(RES_AND, array(array(RES_PROPERTY, array(RELOP => RELOP_NE, ULPROPTAG => PR_PROCESSED, VALUE => array(PR_PROCESSED => true))), array(RES_CONTENT, array(FUZZYLEVEL => FL_PREFIX, ULPROPTAG => PR_MESSAGE_CLASS, VALUE => array(PR_SUBJECT => 'IPM.Schedule.Meeting'))), array(RES_BITMASK, array(ULTYPE => BMR_EQZ, ULMASK => MSGFLAG_READ, ULPROPTAG => PR_MESSAGE_FLAGS)))); // Just get all items from table $l_aRows = mapi_table_queryallrows($l_rInboxTable, array(PR_ENTRYID, PR_MESSAGE_CLASS, PR_SUBJECT, PR_PROCESSED), $restrict); echo 'Querying contents table result (0=success): ' . mapi_last_hresult() . "\n"; //print_r(count($l_aRows)); //exit; echo 'Processing messages' . "\n"; $l_iCounter = 0;
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"; } } }