Commit 252bdaca authored by Sebastian Kummer's avatar Sebastian Kummer

ZP-768 Check first on folder type, as it fails fast.

Released under the Affero GNU General Public License (AGPL) version 3.
parent 546ac33d
...@@ -730,6 +730,12 @@ class ASDevice extends StateObject { ...@@ -730,6 +730,12 @@ class ASDevice extends StateObject {
* @return boolean * @return boolean
*/ */
public function AddAdditionalFolder($store, $folderid, $name, $type) { public function AddAdditionalFolder($store, $folderid, $name, $type) {
// check if type is of a additional user type
if (!in_array($type, array(SYNC_FOLDER_TYPE_USER_CONTACT, SYNC_FOLDER_TYPE_USER_APPOINTMENT, SYNC_FOLDER_TYPE_USER_TASK, SYNC_FOLDER_TYPE_USER_MAIL, SYNC_FOLDER_TYPE_USER_NOTE, SYNC_FOLDER_TYPE_USER_JOURNAL))) {
ZLog::Write(LOGLEVEL_ERROR, sprintf("ASDevice->AddAdditionalFolder(): folder can not be added because the specified type '%s' is not a permitted user type.", $type));
return false;
}
// check if a folder with this ID is already in the list // check if a folder with this ID is already in the list
if (isset($this->additionalfolders[$folderid])) { if (isset($this->additionalfolders[$folderid])) {
ZLog::Write(LOGLEVEL_ERROR, sprintf("ASDevice->AddAdditionalFolder(): folder can not be added because there is already an additional folder with the same folder id: '%s'", $folderid)); ZLog::Write(LOGLEVEL_ERROR, sprintf("ASDevice->AddAdditionalFolder(): folder can not be added because there is already an additional folder with the same folder id: '%s'", $folderid));
...@@ -758,12 +764,6 @@ class ASDevice extends StateObject { ...@@ -758,12 +764,6 @@ class ASDevice extends StateObject {
} }
} }
// check if type is of a additional user type
if (!in_array($type, array(SYNC_FOLDER_TYPE_USER_CONTACT, SYNC_FOLDER_TYPE_USER_APPOINTMENT, SYNC_FOLDER_TYPE_USER_TASK, SYNC_FOLDER_TYPE_USER_MAIL, SYNC_FOLDER_TYPE_USER_NOTE, SYNC_FOLDER_TYPE_USER_JOURNAL))) {
ZLog::Write(LOGLEVEL_ERROR, sprintf("ASDevice->AddAdditionalFolder(): folder can not be added because the specified type '%s' is not a permitted user type.", $type));
return false;
}
// add the folder // add the folder
$af = $this->additionalfolders; $af = $this->additionalfolders;
$af[$folderid] = array( $af[$folderid] = array(
......
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