Commit 018199bc authored by Sebastian Kummer's avatar Sebastian Kummer

ZP-1134 Added DeviceManager->IsKoeSupportingSecondaryContacts() to check

if secondary contacts should be synchronized, renamed
DeviceManager->getAdditionalSyncFolderObject() to
DeviceManager->BuildSyncFolderObject() and made it public - nethod
updates unpatched contact folders for correct processing by
ChangesMemoryWrapper.

Released under the Affero GNU General Public License (AGPL) version 3.
parent cf35c690
...@@ -488,15 +488,7 @@ class DeviceManager { ...@@ -488,15 +488,7 @@ class DeviceManager {
ZLog::Write(LOGLEVEL_WARN, sprintf("DeviceManager->GetAdditionalUserSyncFolders(): Additional folder '%s' has no parentid. Please run 'z-push-admin -a fixstates' to fix this issue.", $df['name'])); ZLog::Write(LOGLEVEL_WARN, sprintf("DeviceManager->GetAdditionalUserSyncFolders(): Additional folder '%s' has no parentid. Please run 'z-push-admin -a fixstates' to fix this issue.", $df['name']));
} }
$folder = $this->getAdditionalSyncFolderObject($df['store'], $df['folderid'], $df['parentid'], $df['name'], $df['type'], $df['flags'], DeviceManager::FLD_ORIGIN_SHARED); $folder = $this->BuildSyncFolderObject($df['store'], $df['folderid'], $df['parentid'], $df['name'], $df['type'], $df['flags'], DeviceManager::FLD_ORIGIN_SHARED);
// adjust additional folders so it matches not yet processed KOE type UNKNOWN folders
$type = $this->device->GetFolderType($folder->serverid);
if (defined('KOE_CAPABILITY_SECONDARYCONTACTS') && KOE_CAPABILITY_SECONDARYCONTACTS && $type !== $folder->type && $type == SYNC_FOLDER_TYPE_UNKNOWN) {
ZLog::Write(LOGLEVEL_DEBUG, "DeviceManager->GetAdditionalUserSyncFolders(): Modifying additional folder so it matches an unprocessed KOE folder");
$folder = Utils::ChangeFolderToTypeUnknownForKoe($folder);
}
$folders[$folder->BackendId] = $folder; $folders[$folder->BackendId] = $folder;
} }
...@@ -504,7 +496,7 @@ class DeviceManager { ...@@ -504,7 +496,7 @@ class DeviceManager {
if (KOE_CAPABILITY_GAB && $this->IsKoe() && KOE_GAB_STORE != "" && KOE_GAB_NAME != "") { if (KOE_CAPABILITY_GAB && $this->IsKoe() && KOE_GAB_STORE != "" && KOE_GAB_NAME != "") {
// if KOE_GAB_FOLDERID is set, use it // if KOE_GAB_FOLDERID is set, use it
if (KOE_GAB_FOLDERID != "") { if (KOE_GAB_FOLDERID != "") {
$folder = $this->getAdditionalSyncFolderObject(KOE_GAB_STORE, KOE_GAB_FOLDERID, '0', KOE_GAB_NAME, SYNC_FOLDER_TYPE_USER_APPOINTMENT, 0, DeviceManager::FLD_ORIGIN_GAB); $folder = $this->BuildSyncFolderObject(KOE_GAB_STORE, KOE_GAB_FOLDERID, '0', KOE_GAB_NAME, SYNC_FOLDER_TYPE_USER_APPOINTMENT, 0, DeviceManager::FLD_ORIGIN_GAB);
$folders[$folder->BackendId] = $folder; $folders[$folder->BackendId] = $folder;
} }
else { else {
...@@ -521,7 +513,7 @@ class DeviceManager { ...@@ -521,7 +513,7 @@ class DeviceManager {
} }
if ($backendGabId) { if ($backendGabId) {
$folders[$backendGabId] = $this->getAdditionalSyncFolderObject(KOE_GAB_STORE, $backendGabId, '0', KOE_GAB_NAME, SYNC_FOLDER_TYPE_USER_APPOINTMENT, 0, DeviceManager::FLD_ORIGIN_GAB); $folders[$backendGabId] = $this->BuildSyncFolderObject(KOE_GAB_STORE, $backendGabId, '0', KOE_GAB_NAME, SYNC_FOLDER_TYPE_USER_APPOINTMENT, 0, DeviceManager::FLD_ORIGIN_GAB);
} }
} }
} }
...@@ -791,6 +783,18 @@ class DeviceManager { ...@@ -791,6 +783,18 @@ class DeviceManager {
return in_array($feature, $capabilities); return in_array($feature, $capabilities);
} }
/**
* Indicates if the connected device is Outlook + KOE and supports the
* secondary contact folder synchronization.
*
* @access public
* @return boolean
*/
public function IsKoeSupportingSecondaryContacts() {
// TODO: ZP-1124 still needs to check if KOE version this feature
return defined('KOE_CAPABILITY_SECONDARYCONTACTS') && KOE_CAPABILITY_SECONDARYCONTACTS && $this->IsKoe(); // && $this->HasKoeFeature('secondarycontacts');
}
/** /**
* Adds an Exceptions to the process tracking * Adds an Exceptions to the process tracking
* *
...@@ -1201,10 +1205,10 @@ class DeviceManager { ...@@ -1201,10 +1205,10 @@ class DeviceManager {
* @param int $flags * @param int $flags
* @param string $folderOrigin * @param string $folderOrigin
* *
* @access private * @access public
* @returns SyncFolder * @returns SyncFolder
*/ */
private function getAdditionalSyncFolderObject($store, $folderid, $parentid, $name, $type, $flags, $folderOrigin) { public function BuildSyncFolderObject($store, $folderid, $parentid, $name, $type, $flags, $folderOrigin) {
$folder = new SyncFolder(); $folder = new SyncFolder();
$folder->BackendId = $folderid; $folder->BackendId = $folderid;
$folder->serverid = $this->GetFolderIdForBackendId($folder->BackendId, true, $folderOrigin, $name); $folder->serverid = $this->GetFolderIdForBackendId($folder->BackendId, true, $folderOrigin, $name);
...@@ -1216,6 +1220,12 @@ class DeviceManager { ...@@ -1216,6 +1220,12 @@ class DeviceManager {
$folder->Store = $store; $folder->Store = $store;
$folder->Flags = $flags; $folder->Flags = $flags;
// adjust additional folders so it matches not yet processed KOE type UNKNOWN folders
$synctype = $this->device->GetFolderType($folder->serverid);
if ($this->IsKoeSupportingSecondaryContacts() && $synctype !== $folder->type && $synctype == SYNC_FOLDER_TYPE_UNKNOWN) {
ZLog::Write(LOGLEVEL_DEBUG, "DeviceManager->BuildSyncFolderObject(): Modifying additional folder so it matches an unprocessed KOE folder");
$folder = Utils::ChangeFolderToTypeUnknownForKoe($folder);
}
return $folder; return $folder;
} }
} }
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