ZLog::Write(LOGLEVEL_ERROR,sprintf("ASDevice->AddAdditionalFolder(): folder can not be added because the specified type '%s' is not a permitted user type.",$type));
returnfalse;
}
// check if a folder with this ID is already in the list
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));
returnfalse;
}
// check if a folder with that Name is already in the list
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));
returnfalse;
}
}
// check if a folder with this ID or Name is already known on the device (regular folder)
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));
returnfalse;
}
// $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));
returnfalse;
}
}
// add the folder
$af=$this->additionalfolders;
$af[$folderid]=array(
'store'=>$store,
'folderid'=>$folderid,
'name'=>$name,
'type'=>$type,
);
$this->additionalfolders=$af;
returntrue;
}
/**
* Edits (sets a new name) for an additional folder. Store, folderid and type can not be edited. Remove and add instead.
*
* @param string $folderid the folder id of the additional folder.
* @param string $name the name of the additional folder (has to be unique for all folders on the device).
ZLog::Write(LOGLEVEL_ERROR,sprintf("ASDevice->EditAdditionalFolder(): folder can not be edited because there is no folder known with this folder id: '%s'. Add the folder first.",$folderid));
returnfalse;
}
// check if a folder with the new name is already in the list
foreach($this->additionalfoldersas$k=>$folder){
if($folder['name']==$name){
ZLog::Write(LOGLEVEL_ERROR,sprintf("ASDevice->EditAdditionalFolder(): folder can not be added because there is already an additional folder with the same name: '%s'",$name));
returnfalse;
}
}
// check if a folder with the new name is already known on the device (regular folder)
ZLog::Write(LOGLEVEL_ERROR,sprintf("ASDevice->EditAdditionalFolder(): folder can not be added because there is already a folder with the same name synchronized: '%s'",$folderid));
returnfalse;
}
}
// update the name
$af=$this->additionalfolders;
$af[$folderid]['name']=$name;
$this->additionalfolders=$af;
returntrue;
}
/**
* Removes an additional folder from this device & user.
*
* @access public
* @return boolean
*/
publicfunctionRemoveAdditionalFolder($folderid){
// check if a folder with this ID is known
if(!isset($this->additionalfolders[$folderid])){
ZLog::Write(LOGLEVEL_ERROR,sprintf("ASDevice->RemoveAdditionalFolder(): folder can not be removed because there is no folder known with this folder id: '%s'",$folderid));
ZLog::Write(LOGLEVEL_DEBUG,sprintf("ZPushAdmin::AdditionalFolderList(): listing data of %d additional folders of device '%s' of user '%s'",count($list),$devid,$user));
}
catch(StateNotFoundException$e){
ZLog::Write(LOGLEVEL_ERROR,sprintf("ZPushAdmin::AdditionalFolderList(): state for device '%s' of user '%s' can not be found",$devid,$user));
returnfalse;
}
return$list;
}
/**
* Adds an additional folder for the user and device.
*
* @param string $user user of the device.
* @param string $devid device id the folder should be added to.
* @param string $add_store the store where this folder is located, e.g. "SYSTEM" (for public folder) or a username.
* @param string $add_folderid the folder id of the additional folder.
* @param string $add_name the name of the additional folder (has to be unique for all folders on the device).
* @param string $add_type AS foldertype of SYNC_FOLDER_TYPE_USER_*
ZLog::Write(LOGLEVEL_DEBUG,sprintf("ZPushAdmin::AdditionalFolderAdd(): added folder '%s' to additional folders list of device '%s' of user '%s' with status: %s",$add_name,$devid,$user,Utils::PrintAsString($status)));
return$status;
}
catch(StateNotFoundException$e){
ZLog::Write(LOGLEVEL_ERROR,sprintf("ZPushAdmin::AdditionalFolderAdd(): state for device '%s' of user '%s' can not be found or saved",$devid,$user));
returnfalse;
}
returnfalse;
}
/**
* Updates an additional folder for the user and device.
*
* @param string $user user of the device.
* @param string $devid device id of where the folder should be updated.
* @param string $add_folderid the folder id of the additional folder.
* @param string $add_name the name of the additional folder (has to be unique for all folders on the device).
ZLog::Write(LOGLEVEL_ERROR,sprintf("ZPushAdmin::AdditionalFolderEdit(): the folder id '%s' can not be edited as it is a statically configured folder. Aborting.",$add_folderid));
ZLog::Write(LOGLEVEL_DEBUG,sprintf("ZPushAdmin::AdditionalFolderEdit(): updated folder '%s' in additional folders list of device '%s' of user '%s' with status: %s",$add_name,$devid,$user,Utils::PrintAsString($status)));
return$status;
}
catch(StateNotFoundException$e){
ZLog::Write(LOGLEVEL_ERROR,sprintf("ZPushAdmin::AdditionalFolderEdit(): state for device '%s' of user '%s' can not be found or saved",$devid,$user));
returnfalse;
}
returnfalse;
}
/**
* Removes an additional folder for the user and device.
*
* @param string $user user of the device.
* @param string $devid device id of where the folder should be removed.
* @param string $add_folderid the folder id of the additional folder.
ZLog::Write(LOGLEVEL_ERROR,sprintf("ZPushAdmin::AdditionalFolderRemove(): data of user '%s' not synchronized on device '%s'. Aborting.",$user,$devid));
ZLog::Write(LOGLEVEL_ERROR,sprintf("ZPushAdmin::AdditionalFolderRemove(): the folder id '%s' can not be removed as it is a statically configured folder. Aborting.",$add_folderid));
ZLog::Write(LOGLEVEL_DEBUG,sprintf("ZPushAdmin::AdditionalFolderRemove(): removed folder '%s' in additional folders list of device '%s' of user '%s' with status: %s",$add_folderid,$devid,$user,Utils::PrintAsString($status)));
return$status;
}
catch(StateNotFoundException$e){
ZLog::Write(LOGLEVEL_ERROR,sprintf("ZPushAdmin::AdditionalFolderRemove(): state for device '%s' of user '%s' can not be found or saved",$devid,$user));
ZLog::Write(LOGLEVEL_INFO,sprintf("WebserviceDevice::AdditionalFolderList(): found %d folders for device '%s' of user '%s'",count($folders),$deviceId,$user));
ZPush::GetTopCollector()->AnnounceInformation(sprintf("Retrieved details of %d folders",count($folders)),true);
return$folders;
}
/**
* Adds an additional folder to the given device and the Request::GetGETUser().
*
* @param string $deviceId device id the folder should be added to.
* @param string $add_store the store where this folder is located, e.g. "SYSTEM" (for public folder) or an username/email address.
* @param string $add_folderid the folder id of the additional folder.
* @param string $add_name the name of the additional folder (has to be unique for all folders on the device).
* @param string $add_type AS foldertype of SYNC_FOLDER_TYPE_USER_*
ZLog::Write(LOGLEVEL_INFO,sprintf("WebserviceDevice::AdditionalFolderAdd(): added folder for device '%s' of user '%s': %s",$deviceId,$user,Utils::PrintAsString($status)));
ZLog::Write(LOGLEVEL_INFO,sprintf("WebserviceDevice::AdditionalFolderEdit(): added folder for device '%s' of user '%s': %s",$deviceId,$user,Utils::PrintAsString($status)));
ZLog::Write(LOGLEVEL_INFO,sprintf("WebserviceDevice::AdditionalFolderRemove(): removed folder for device '%s' of user '%s': %s",$deviceId,$user,Utils::PrintAsString($status)));