/** * Deletes an entire addressbook and all its contents * * @param mixed $addressBookId * @return void */ public function deleteAddressBook($addressBookId) { $this->logger->info("deleteAddressBook(" . bin2hex($addressBookId) . ")"); if (READ_ONLY || !ALLOW_DELETE_FOLDER) { $this->logger->warn("Cannot delete address book: permission denied by config"); return false; } $folders = $this->bridge->getAdressBooks(); $parentFolderId = $folders[$addressBookId]['parentId']; $folder = mapi_msgstore_openentry($this->bridge->getStore($addressBookId), $addressBookId); $parentFolder = mapi_msgstore_openentry($this->bridge->getStore($addressBookId), $parentFolderId); // Delete folder content mapi_folder_emptyfolder($folder, DEL_ASSOCIATED); mapi_folder_deletefolder($parentFolder, $addressBookId); if (mapi_last_hresult() > 0) { $this->logger->fatal("Error deleting addressbook: " . get_mapi_error_name()); } }
/** * Terminates a search for a given PID * * @param int $pid * * @return boolean */ public function TerminateSearch($pid) { ZLog::Write(LOGLEVEL_DEBUG, sprintf("ZarafaBackend->TerminateSearch(): terminating search for pid %d", $pid)); $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; } $finderfolder = 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; } $hierarchytable = mapi_folder_gethierarchytable($finderfolder); mapi_table_restrict($hierarchytable, array(RES_CONTENT, array(FUZZYLEVEL => FL_PREFIX, ULPROPTAG => PR_DISPLAY_NAME, VALUE => array(PR_DISPLAY_NAME => "Z-Push Search Folder " . $pid))), TBL_BATCH); $folders = mapi_table_queryallrows($hierarchytable, array(PR_ENTRYID, PR_DISPLAY_NAME, PR_LAST_MODIFICATION_TIME)); foreach ($folders as $folder) { mapi_folder_deletefolder($finderfolder, $folder[PR_ENTRYID]); } return true; }
/** * Deletes the hidden folder. * * @param string $folderid * @param string $gabId the id of the gab where the hidden folder should be searched. If not set (null) the default gab is used. * @param string $gabName the name of the gab where the hidden folder should be searched. If not set (null) the default gab is used. * * @access protected * @return boolean */ protected function deleteHiddenFolder($folderid, $gabId = null, $gabName = 'default') { $store = $this->getStore($gabId, $gabName); if (!$store) { return false; } $parentfolder = $this->getRootFolder($store); $folderentryid = mapi_msgstore_entryidfromsourcekey($store, hex2bin($folderid)); if (mapi_last_hresult()) { $this->Terminate(sprintf("Kopano->deleteHiddenFolder(): Error, could not get PR_ENTRYID for hidden folder: 0x%08X", mapi_last_hresult())); } mapi_folder_deletefolder($parentfolder, $folderentryid); if (mapi_last_hresult()) { $this->Terminate(sprintf("Kopano->deleteHiddenFolder(): Error, mapi_folder_deletefolder() failed: 0x%08X", mapi_last_hresult())); } return true; }