Commit 37f038eb authored by Sebastian Kummer's avatar Sebastian Kummer

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

Merge pull request #224 in ZP/z-push from bugfix/ZP-902-zpushadmin--additionalfolderlist-should to develop

* commit '0e103dae':
  ZP-902 List folder types and readonly flag in ZPushAdmin->AdditionalFolderList().
parents 4ae8dedd 0e103dae
...@@ -1085,6 +1085,30 @@ class Utils { ...@@ -1085,6 +1085,30 @@ class Utils {
'ArmSCII8', 'ArmSCII8',
); );
} }
/**
* Returns folder origin from its id.
*
* @param string $fid
*
* @access public
* @return string
*/
public static function GetFolderOriginFromId($fid) {
$origin = substr($fid, 0, 1);
switch ($origin) {
case DeviceManager::FLD_ORIGIN_CONFIG:
return 'configured';
case DeviceManager::FLD_ORIGIN_GAB:
return 'GAB';
case DeviceManager::FLD_ORIGIN_SHARED:
return 'shared';
case DeviceManager::FLD_ORIGIN_USER:
return 'user';
}
ZLog::Write(LOGLEVEL_WARN, sprintf("Utils->GetFolderOriginFromId(): Unknown folder origin for folder with id '%s'", $fid));
return 'unknown';
}
} }
......
...@@ -485,21 +485,23 @@ class ZPushAdmin { ...@@ -485,21 +485,23 @@ class ZPushAdmin {
// unify the lists saved for the user/device and the staticly configured one // unify the lists saved for the user/device and the staticly configured one
$new_list = array(); $new_list = array();
foreach ($device->GetAdditionalFolders() as $folder) { foreach ($device->GetAdditionalFolders() as $folder) {
$folder['source'] = 'user'; $syncfolderid = $device->GetFolderIdForBackendId($folder['folderid'], false, false, null);
$folder['syncfolderid'] = $device->GetFolderIdForBackendId($folder['folderid'], false, false, null); $folder['syncfolderid'] = $syncfolderid;
$folder['origin'] = Utils::GetFolderOriginFromId($syncfolderid);
$new_list[$folder['folderid']] = $folder; $new_list[$folder['folderid']] = $folder;
} }
foreach (ZPush::GetAdditionalSyncFolders() as $fid => $so) { foreach (ZPush::GetAdditionalSyncFolders() as $fid => $so) {
// if this is not part of the device list // if this is not part of the device list
if (!isset($new_list[$fid])) { if (!isset($new_list[$fid])) {
$syncfolderid = $device->GetFolderIdForBackendId($fid, false, false, null);
$new_list[$fid] = array( $new_list[$fid] = array(
'store' => $so->Store, 'store' => $so->Store,
'folderid' => $fid, 'folderid' => $fid,
'syncfolderid' => $device->GetFolderIdForBackendId($fid, false, false, null), 'syncfolderid' => $syncfolderid,
'name' => $so->displayname, 'name' => $so->displayname,
'type' => $so->type, 'type' => $so->type,
'readonly' => $so->ReadOnly, 'readonly' => $so->ReadOnly,
'source' => 'static' 'origin' => Utils::GetFolderOriginFromId($syncfolderid),
); );
} }
} }
......
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