/** * Uploads the specified file found in $upload for the specified user * to the temp folder. * As of know, only one file per upload is permitted. * make sure the upload has been filtered and validated before passing it * to this method * * @param Zend_File_Transfer_Adapter_Http $upload * @param int $userId * * @return null if an error occured or Conjoon_Groupware_Files_File_Dto * * @throws InvalidArgumentException * @throws Conjoon_Modules_Groupware_Files_Exception */ public function uploadFileToTempFolderForUser(Zend_File_Transfer_Adapter_Http $upload, $userId) { $this->_checkArguments(array('userId' => array('value' => &$userId, 'type' => 'int'))); if (count($upload->getFilters()) && !$upload->isFiltered()) { /** * @see Conjoon_Modules_Groupware_Files_Exception */ require_once 'Conjoon/Modules/Groupware/Files/Exception.php'; throw new Conjoon_Modules_Groupware_Files_Exception("The upload has not been filtered yet."); } if (!$upload->isValid()) { /** * @see Conjoon_Modules_Groupware_Files_Exception */ require_once 'Conjoon/Modules/Groupware/Files/Exception.php'; throw new Conjoon_Modules_Groupware_Files_Exception("The upload has not been validated yet."); } // check if only one file is available if (count(array_keys($upload->getFileInfo())) != 1) { throw new Conjoon_Modules_Groupware_Files_Exception("Only one file per download permitted."); } $fileInfo = array_pop($upload->getFileInfo()); $name = $fileInfo['name']; $path = $fileInfo['tmp_name']; $type = $fileInfo['type']; $tmpFolderId = $this->_getFolderFacade()->getTempFolderIdForUser($userId); $obj = $this->_getFileFacade()->moveFileToFolderForUserId($path, $tmpFolderId, $userId, $name, $type); if (!$obj) { return null; } return $obj->getDto(); }