Commit e5c5e3ac authored by Sebastian Kummer's avatar Sebastian Kummer

Merge pull request #290 in ZP/z-push from bugfix/ZP-884-zcp--gethierarchy-is-broken to develop

* commit '98d70540':
  ZP-884 Improve retrieval of hierarchy, also filter search folders.
  ZP-884 Fix GetHierarchy() to provide otherwise streamed properties to MAPIProvider->GetFolder().
parents 96d81986 98d70540
...@@ -337,22 +337,25 @@ class BackendKopano implements IBackend, ISearchProvider { ...@@ -337,22 +337,25 @@ class BackendKopano implements IBackend, ISearchProvider {
*/ */
public function GetHierarchy() { public function GetHierarchy() {
$folders = array(); $folders = array();
$importer = false;
$mapiprovider = new MAPIProvider($this->session, $this->store); $mapiprovider = new MAPIProvider($this->session, $this->store);
$rootfolder = mapi_msgstore_openentry($this->store); $rootfolder = mapi_msgstore_openentry($this->store);
$rootfolderprops = mapi_getprops($rootfolder, array(PR_SOURCE_KEY)); $rootfolderprops = mapi_getprops($rootfolder, array(PR_SOURCE_KEY));
$rootfoldersourcekey = bin2hex($rootfolderprops[PR_SOURCE_KEY]);
$hierarchy = mapi_folder_gethierarchytable($rootfolder, CONVENIENT_DEPTH); $hierarchy = mapi_folder_gethierarchytable($rootfolder, CONVENIENT_DEPTH);
$rows = mapi_table_queryallrows($hierarchy, array(PR_ENTRYID)); $rows = mapi_table_queryallrows($hierarchy, array(PR_DISPLAY_NAME, PR_PARENT_ENTRYID, PR_ENTRYID, PR_SOURCE_KEY, PR_PARENT_SOURCE_KEY, PR_CONTAINER_CLASS, PR_ATTR_HIDDEN, PR_EXTENDED_FOLDER_FLAGS, PR_FOLDER_TYPE));
foreach ($rows as $row) { foreach ($rows as $row) {
$mapifolder = mapi_msgstore_openentry($this->store, $row[PR_ENTRYID]); // do not display hidden and search folders
$folder = $mapiprovider->GetFolder($mapifolder); if ((isset($row[PR_ATTR_HIDDEN]) && $row[PR_ATTR_HIDDEN]) ||
(isset($row[PR_FOLDER_TYPE]) && $row[PR_FOLDER_TYPE] == FOLDER_SEARCH) ||
if (isset($folder->parentid) && $folder->parentid != $rootfoldersourcekey) (isset($row[PR_PARENT_SOURCE_KEY]) && $row[PR_PARENT_SOURCE_KEY] == $rootfolderprops[PR_SOURCE_KEY]) ) {
continue;
}
$folder = $mapiprovider->GetFolder($row);
if ($folder) {
$folders[] = $folder; $folders[] = $folder;
}
} }
return $folders; return $folders;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment