Commit 344c4f0d authored by Sebastian Kummer's avatar Sebastian Kummer

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

Merge pull request #571 in ZP/z-push from bugfix/ZP-1270-unknown-origin-and-warnings-when to develop

* commit '228c947b':
  ZP-1270 Fixed whitespace.
  ZP-1270 Fixed warning when parentid is not set.
  ZP-1270 Change API so another device can be loaded adhoc into the DeviceManager, fixed warnings.
parents 78a21b31 228c947b
......@@ -101,6 +101,16 @@ class DeviceManager {
}
}
/**
* Load another different device.
* @param ASDevice $asDevice
*/
public function SetDevice($asDevice) {
$this->device = $asDevice;
$this->loadDeviceData();
$this->stateManager->SetDevice($this->device);
}
/**
* Returns the StateManager for the current device
*
......
......@@ -460,6 +460,21 @@ class ZPush {
return ZPush::$deviceManager;
}
/**
* Load another device in the DeviceManager and return it.
*
* @param ASDevice $asDevice
* @param boolean $initialize - default: true
* @return DeviceManager
*/
static public function GetDeviceManagerWithDevice($asDevice, $initialize = true) {
$dm = ZPush::GetDeviceManager($initialize);
if ($dm) {
$dm->SetDevice($asDevice);
}
return $dm;
}
/**
* Returns the Top data collector object
*
......
......@@ -502,6 +502,9 @@ class ZPushAdmin {
return false;
}
// init deviceManage with correct device
ZPush::GetDeviceManagerWithDevice($device);
// unify the lists saved for the user/device and the staticly configured one
$new_list = array();
foreach ($device->GetAdditionalFolders() as $folder) {
......@@ -517,6 +520,7 @@ class ZPushAdmin {
$new_list[$fid] = array(
'store' => $so->Store,
'folderid' => $fid,
'parentid' => $so->parentid,
'syncfolderid' => $syncfolderid,
'name' => $so->displayname,
'type' => $so->type,
......
......@@ -166,6 +166,9 @@ class WebserviceDevice {
$user = Request::GetGETUser();
$deviceId = preg_replace("/[^A-Za-z0-9]/", "", $deviceId);
$folders = ZPushAdmin::AdditionalFolderList($user, $deviceId);
if ($folders === false) {
$folders = array();
}
ZLog::Write(LOGLEVEL_INFO, sprintf("WebserviceDevice::AdditionalFolderList(): found %d folders for device '%s' of user '%s'", count($folders), $deviceId, $user));
// retrieve the permission flags from the backend and convert associative array into stdClass object for PHP7 support
$folderObjects = array();
......@@ -174,7 +177,7 @@ class WebserviceDevice {
$folderObject = new stdClass();
$folderObject->store = $folder['store'];
$folderObject->folderid = $folder['folderid'];
$folderObject->parentid = $folder['parentid'];
$folderObject->parentid = (isset($folder['parentid'])) ? $folder['parentid'] : "0";
$folderObject->syncfolderid = $folder['syncfolderid'];
$folderObject->name = $folder['name'];
$folderObject->type = $folder['type'];
......
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