$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); $properties = getPropIdsFromStrings($store, $properties); //composed properties which require more work $special_properties = array("email_address_1", "email_address_2", "email_address_3"); $i = 1;
$store = mapi_openmsgstore($session, $storeentryid); 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"]));
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; }