Commit 4332f0c4 authored by Sebastian Kummer's avatar Sebastian Kummer

ZP-1071 Add documentation TODO, fixed variable names, fixed typo in

regex.

Released under the Affero GNU General Public License (AGPL) version 3.
parent 1877117b
...@@ -855,6 +855,7 @@ class ASDevice extends StateObject { ...@@ -855,6 +855,7 @@ class ASDevice extends StateObject {
* @param string $name the name of the additional folder (has to be unique for all folders on the device). * @param string $name the name of the additional folder (has to be unique for all folders on the device).
* @param string $type AS foldertype of SYNC_FOLDER_TYPE_USER_* * @param string $type AS foldertype of SYNC_FOLDER_TYPE_USER_*
* @param int $flags Additional flags, like DeviceManager::FLD_FLAGS_REPLYASUSER * @param int $flags Additional flags, like DeviceManager::FLD_FLAGS_REPLYASUSER
* //TODO document $parentid and $checkDups (or remove this)
* *
* @access public * @access public
* @return boolean * @return boolean
...@@ -995,8 +996,8 @@ class ASDevice extends StateObject { ...@@ -995,8 +996,8 @@ class ASDevice extends StateObject {
* Sets a list of additional folders of one store to the device. * Sets a list of additional folders of one store to the device.
* If there are additional folders for the set_store, that are not in the list they will be removed. * If there are additional folders for the set_store, that are not in the list they will be removed.
* *
* @param string $set_store the store where this folder is located, e.g. "SYSTEM" (for public folder) or an username/email address. * @param string $store the store where this folder is located, e.g. "SYSTEM" (for public folder) or an username/email address.
* @param array $set_folders a list of folders to be set for this user. Other existing additional folders (that are not in this list) * @param array $folders a list of folders to be set for this user. Other existing additional folders (that are not in this list)
* will be removed. The list is an array containing folders, where each folder is an array with the following keys: * will be removed. The list is an array containing folders, where each folder is an array with the following keys:
* 'folderid' (string) the folder id of the additional folder. * 'folderid' (string) the folder id of the additional folder.
* 'parentid' (string) the folderid of the parent folder. If no parent folder is set or the parent folder is not defined, '0' (main folder) is used. * 'parentid' (string) the folderid of the parent folder. If no parent folder is set or the parent folder is not defined, '0' (main folder) is used.
...@@ -1007,25 +1008,25 @@ class ASDevice extends StateObject { ...@@ -1007,25 +1008,25 @@ class ASDevice extends StateObject {
* @access public * @access public
* @return boolean * @return boolean
*/ */
public function SetAdditionalFolderList($set_store, $set_folders) { public function SetAdditionalFolderList($store, $folders) {
// remove all folders already shared for this store // remove all folders already shared for this store
$newAF = array(); $newAF = array();
$noDupsCheck = array(); $noDupsCheck = array();
foreach($this->additionalfolders as $keepFolder) { foreach($this->additionalfolders as $keepFolder) {
if ($keepFolder['store'] !== $set_store) { if ($keepFolder['store'] !== $store) {
$newAF[] = $keepFolder; $newAF[] = $keepFolder;
} }
else { else {
$noDupsCheck[$keepFolder['folderid']] = true; $noDupsCheck[$keepFolder['folderid']] = true;
} }
} }
ZLog::Write(LOGLEVEL_DEBUG, sprintf("ASDevice->SetAdditionalFolderList(): cleared additional folder lists of store '%s', total %d folders, kept %d and removed %d", $set_store, count($this->additionalfolders), count($newAF), count(array_keys($noDupsCheck)))); ZLog::Write(LOGLEVEL_DEBUG, sprintf("ASDevice->SetAdditionalFolderList(): cleared additional folder lists of store '%s', total %d folders, kept %d and removed %d", $store, count($this->additionalfolders), count($newAF), count($noDupsCheck)));
// set remaining additional folders // set remaining additional folders
$this->additionalfolders = $newAF; $this->additionalfolders = $newAF;
// low level add // low level add
foreach($set_folders as $f) { foreach($folders as $f) {
$status = $this->AddAdditionalFolder($set_store, $f['folderid'], $f['name'], $f['type'], $f['flags'], $f['parentid'], !isset($noDupsCheck[$f['folderid']])); $status = $this->AddAdditionalFolder($store, $f['folderid'], $f['name'], $f['type'], $f['flags'], $f['parentid'], !isset($noDupsCheck[$f['folderid']]));
ZLog::Write(LOGLEVEL_DEBUG, sprintf("ASDevice->SetAdditionalFolderList(): set folder '%s' in additional folders list with status: %s", $f['name'], Utils::PrintAsString($status))); ZLog::Write(LOGLEVEL_DEBUG, sprintf("ASDevice->SetAdditionalFolderList(): set folder '%s' in additional folders list with status: %s", $f['name'], Utils::PrintAsString($status)));
// break if a folder can not be added // break if a folder can not be added
if (!$status) { if (!$status) {
......
...@@ -295,7 +295,7 @@ class WebserviceDevice { ...@@ -295,7 +295,7 @@ class WebserviceDevice {
$folder['folderid'] = preg_replace("/[^A-Za-z0-9]/", "", $folder['folderid']); $folder['folderid'] = preg_replace("/[^A-Za-z0-9]/", "", $folder['folderid']);
$folder['parentid'] = preg_replace("/[^A-Za-z0-9]/", "", $folder['parentid']); $folder['parentid'] = preg_replace("/[^A-Za-z0-9]/", "", $folder['parentid']);
$folder['type'] = preg_replace("/[^0-9]/", "", $folder['type']); $folder['type'] = preg_replace("/[^0-9]/", "", $folder['type']);
$folder['flags'] = preg_replace("/type/", "", $folder['flags']); $folder['flags'] = preg_replace("/[^0-9]/", "", $folder['flags']);
}); });
$status = ZPushAdmin::AdditionalFolderSetList($user, $deviceId, $set_store, $set_folders); $status = ZPushAdmin::AdditionalFolderSetList($user, $deviceId, $set_store, $set_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