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_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)));