thrownewFatalMisconfigurationException(sprintf("SqlStateMachine(): invalid database name '%s'. The name may contain ASCII 7bit letters, numbers and the '$' and '_' signs. Please change your configuration.",STATE_SQL_DATABASE));
ZLog::Write(LOGLEVEL_ERROR,sprintf("ASDevice->AddAdditionalFolder(): No valid folderid ('%s') or name ('%s') sent. Aborting. ",$folderid,$name));
...
...
@@ -860,15 +862,29 @@ class ASDevice extends StateObject {
returnfalse;
}
// check if a folder with that Name is already in the list
// check if a folder with that Name is already in the list and that its parent exists
$parentFound=false;
foreach($this->additionalfoldersas$k=>$folder){
if($folder['name']==$name){
ZLog::Write(LOGLEVEL_ERROR,sprintf("ASDevice->AddAdditionalFolder(): folder can not be added because there is already an additional folder with the same name: '%s'",$name));
// TODO: this parentid check should go into fixstates!
ZLog::Write(LOGLEVEL_ERROR,sprintf("ASDevice->AddAdditionalFolder(): folder can not be added because there is already an additional folder with the same name in the same folder: '%s'",$name));
returnfalse;
}
if($folder['folderid']==$parentid){
$parentFound=true;
}
}
if($parentid!='0'&&!$parentFound){
ZLog::Write(LOGLEVEL_ERROR,sprintf("ASDevice->AddAdditionalFolder(): folder '%s' ('%s') can not be added because the parent folder '%s' can not be found'",$name,$folderid,$parentid));
returnfalse;
}
// check if a folder with this ID or Name is already known on the device (regular folder)
if($checkDups){
// in order to check for the parent-ids we need a shortid
ZLog::Write(LOGLEVEL_ERROR,sprintf("ASDevice->AddAdditionalFolder(): folder can not be added because there is already a folder with the same folder id synchronized: '%s'",$folderid));
...
...
@@ -876,17 +892,19 @@ class ASDevice extends StateObject {
}
// $folder is a SyncFolder object here
if($folder->displayname==$name){
ZLog::Write(LOGLEVEL_ERROR,sprintf("ASDevice->AddAdditionalFolder(): folder can not be added because there is already a folder with the same name synchronized: '%s'",$name));
ZLog::Write(LOGLEVEL_ERROR,sprintf("ASDevice->AddAdditionalFolder(): folder can not be added because there is already a folder with the same name synchronized in the same parent: '%s'",$name));
returnfalse;
}
}
}
// add the folder
$af=$this->additionalfolders;
$af[$folderid]=array(
'store'=>$store,
'folderid'=>$folderid,
'parentid'=>$parentid,
'name'=>$name,
'type'=>$type,
'flags'=>$flags,
...
...
@@ -973,6 +991,108 @@ class ASDevice extends StateObject {
returntrue;
}
/**
* 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.
*
* @param string $store the store where this folder is located, e.g. "SYSTEM" (for public folder) or an username/email address.
* @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:
* '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.
* 'name' (string) the name of the additional folder (has to be unique for all folders on the device).
* 'type' (string) AS foldertype of SYNC_FOLDER_TYPE_USER_*
* 'flags' (int) Additional flags, like DeviceManager::FLD_FLAGS_REPLYASUSER
// remove all folders already shared for this store
$newAF=array();
$noDupsCheck=array();
foreach($this->additionalfoldersas$keepFolder){
if($keepFolder['store']!==$store){
$newAF[$keepFolder['folderid']]=$keepFolder;
}
else{
$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",$store,count($this->additionalfolders),count($newAF),count($noDupsCheck)));
// set remaining additional folders
$this->additionalfolders=$newAF;
// transform our array in a key/value array where folderids are keys and do some basic checks
ZLog::Write(LOGLEVEL_ERROR,sprintf("ASDevice->SetAdditionalFolderList(): No valid folderid ('%s') or name ('%s') sent. Aborting. ",$f['folderid'],$f['name']));
returnfalse;
}
// check if type is of a additional user type
if(!in_array($f['type'],$validTypes)){
ZLog::Write(LOGLEVEL_ERROR,sprintf("ASDevice->SetAdditionalFolderList(): folder (id: '%s' - name: '%s') can not be added because the specified type '%s' is not a permitted user type.",$f['folderid'],$f['name'],$f['type']));
returnfalse;
}
$toOrder[$f['folderid']]=$f;
}
// order the array, so folders with leafs come first
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
if(!$status){
returnfalse;
}
}
returntrue;
}
/**
* Orders a list of folders so the parents are first in the array, all leaves come afterwards.
*
* @param array $toOrderFolders an array of folders, where the folderids are keys. This array should be empty at the end.
* @param array $orderedFolders the ordered array
* @param string $parentid the parentid to start with, if not set '0' (main folders) is used.
ZLog::Write(LOGLEVEL_DEBUG,sprintf("ChangesMemoryWrapper->ImportFolderChange(): Change for folder '%s' will not be sent as modification is not relevant.",$folder->displayname));
ZLog::Write(LOGLEVEL_WARN,sprintf("DeviceManager->GetAdditionalUserSyncFolders(): Additional folder '%s' has no flags. Please run 'z-push-admin -a fixstates' to fix this issue.",$df['name']));
}
if(!isset($df['parentid'])){
$df['parentid']='0';
ZLog::Write(LOGLEVEL_WARN,sprintf("DeviceManager->GetAdditionalUserSyncFolders(): Additional folder '%s' has no parentid. // TODO FIX: Please run 'z-push-admin -a fixstates' to fix this issue.",$df['name']));
@@ -129,7 +129,7 @@ abstract class SyncObject extends Streamer {
}
else{
if(isset($this->$val)&&isset($odo->$val)){
if($this->$val!=$odo->$val){
if($this->$val!==$odo->$val){
ZLog::Write(LOGLEVEL_DEBUG,sprintf("SyncObject->equals() false on field '%s': '%s' != '%s'",$val,Utils::PrintAsString($this->$val),Utils::PrintAsString($odo->$val)));
ZLog::Write(LOGLEVEL_ERROR,sprintf("ZPushAdmin::AdditionalFolderSetList(): data of user '%s' not synchronized on device '%s'. Aborting.",$user,$devid));
ZLog::Write(LOGLEVEL_DEBUG,sprintf("ZPushAdmin::AdditionalFolderSetList(): added '%s' folders of '%s' to additional folders list of device '%s' of user '%s' with status: %s",count($set_folders),$set_store,$devid,$user,Utils::PrintAsString($status)));
return$status;
}
catch(StateNotFoundException$e){
ZLog::Write(LOGLEVEL_ERROR,sprintf("ZPushAdmin::AdditionalFolderSetList(): state for device '%s' of user '%s' can not be found or saved",$devid,$user));
ZLog::Write(LOGLEVEL_INFO,sprintf("WebserviceDevice::AdditionalFolderSetList(): set '%d' folders for device '%s' of user '%s': %s",count($set_folders),$deviceId,$user,Utils::PrintAsString($status)));