Commit 5aeff49b authored by Sebastian Kummer's avatar Sebastian Kummer

Merge pull request #661 in ZP/z-push from...

Merge pull request #661 in ZP/z-push from bugfix/ZP-1370-impersonation-public-folder-can-t-be-opened to develop

* commit 'c17e1bdf':
  ZP-1370 Recognize Public root as root folder.
  ZP-1370 isZPushEnabled flag always needs to be checked on the main store.
  ZP-1370 PR_IPM_SUBTREE_ENTRYID doesn't work on the public folder.
parents 7b361e37 c17e1bdf
......@@ -69,8 +69,13 @@ class ExportChangesICS implements IExportChanges{
$entryid = mapi_msgstore_entryidfromsourcekey($store, $folderid);
}
else {
$storeprops = mapi_getprops($this->store, array(PR_IPM_SUBTREE_ENTRYID));
$entryid = $storeprops[PR_IPM_SUBTREE_ENTRYID];
$storeprops = mapi_getprops($this->store, array(PR_IPM_SUBTREE_ENTRYID, PR_IPM_PUBLIC_FOLDERS_ENTRYID));
if (ZPush::GetBackend()->GetImpersonatedUser() == 'system') {
$entryid = $storeprops[PR_IPM_PUBLIC_FOLDERS_ENTRYID];
}
else {
$entryid = $storeprops[PR_IPM_SUBTREE_ENTRYID];
}
}
$folder = false;
......
......@@ -87,8 +87,13 @@ class ImportChangesICS implements IImportChanges {
}
}
else {
$storeprops = mapi_getprops($store, array(PR_IPM_SUBTREE_ENTRYID));
$entryid = $storeprops[PR_IPM_SUBTREE_ENTRYID];
$storeprops = mapi_getprops($store, array(PR_IPM_SUBTREE_ENTRYID, PR_IPM_PUBLIC_FOLDERS_ENTRYID));
if (ZPush::GetBackend()->GetImpersonatedUser() == 'system') {
$entryid = $storeprops[PR_IPM_PUBLIC_FOLDERS_ENTRYID];
}
else {
$entryid = $storeprops[PR_IPM_SUBTREE_ENTRYID];
}
}
$folder = false;
......@@ -664,9 +669,13 @@ class ImportChangesICS implements IImportChanges {
if (!$id) {
// the root folder is "0" - get IPM_SUBTREE
if ($parent == "0") {
$parentprops = mapi_getprops($this->store, array(PR_IPM_SUBTREE_ENTRYID));
if (isset($parentprops[PR_IPM_SUBTREE_ENTRYID]))
$parentprops = mapi_getprops($this->store, array(PR_IPM_SUBTREE_ENTRYID, PR_IPM_PUBLIC_FOLDERS_ENTRYID));
if (ZPush::GetBackend()->GetImpersonatedUser() == 'system' && isset($parentprops[PR_IPM_PUBLIC_FOLDERS_ENTRYID])) {
$parentfentryid = $parentprops[PR_IPM_PUBLIC_FOLDERS_ENTRYID];
}
elseif (isset($parentprops[PR_IPM_SUBTREE_ENTRYID])) {
$parentfentryid = $parentprops[PR_IPM_SUBTREE_ENTRYID];
}
}
else
$parentfentryid = mapi_msgstore_entryidfromsourcekey($this->store, hex2bin($parent));
......@@ -719,8 +728,13 @@ class ImportChangesICS implements IImportChanges {
// get the real parent source key from mapi
if ($parent == "0") {
$parentprops = mapi_getprops($this->store, array(PR_IPM_SUBTREE_ENTRYID));
$parentfentryid = $parentprops[PR_IPM_SUBTREE_ENTRYID];
$parentprops = mapi_getprops($this->store, array(PR_IPM_SUBTREE_ENTRYID, PR_IPM_PUBLIC_FOLDERS_ENTRYID));
if (ZPush::GetBackend()->GetImpersonatedUser() == 'system') {
$parentfentryid = $parentprops[PR_IPM_PUBLIC_FOLDERS_ENTRYID];
}
else {
$parentfentryid = $parentprops[PR_IPM_SUBTREE_ENTRYID];
}
$mapifolder = mapi_msgstore_openentry($this->store, $parentfentryid);
$rootfolderprops = mapi_getprops($mapifolder, array(PR_SOURCE_KEY));
......
......@@ -2566,7 +2566,9 @@ class BackendKopano implements IBackend, ISearchProvider {
*/
private function isZPushEnabled() {
$addressbook = $this->getAddressbook();
$userEntryid = mapi_getprops($this->store, array(PR_MAILBOX_OWNER_ENTRYID));
// this check needs to be performed on the store of the main (authenticated) user
$store = $this->storeCache[$this->mainUser];
$userEntryid = mapi_getprops($store, array(PR_MAILBOX_OWNER_ENTRYID));
$mailuser = mapi_ab_openentry($addressbook, $userEntryid[PR_MAILBOX_OWNER_ENTRYID]);
$enabledFeatures = mapi_getprops($mailuser, array(PR_EC_DISABLED_FEATURES));
if (isset($enabledFeatures[PR_EC_DISABLED_FEATURES]) && is_array($enabledFeatures[PR_EC_DISABLED_FEATURES])) {
......
......@@ -994,7 +994,7 @@ class MAPIProvider {
$folderOrigin = DeviceManager::FLD_ORIGIN_IMPERSONATED;
}
$folder->serverid = ZPush::GetDeviceManager()->GetFolderIdForBackendId($folder->BackendId, true, $folderOrigin, $folderprops[PR_DISPLAY_NAME]);
if($folderprops[PR_PARENT_ENTRYID] == $storeprops[PR_IPM_SUBTREE_ENTRYID]) {
if($folderprops[PR_PARENT_ENTRYID] == $storeprops[PR_IPM_SUBTREE_ENTRYID] || $folderprops[PR_PARENT_ENTRYID] == $storeprops[PR_IPM_PUBLIC_FOLDERS_ENTRYID]) {
$folder->parentid = "0";
}
else {
......
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