public function put($data) { if (!file_put_contents($this->getFileLocation(), $data)) { throw new Sabre_DAV_Exception_Forbidden('Permission denied to change data'); } $frs_file_factory = new FRSFileFactory(); $frs_file_factory->update(array('file_id' => $this->file->getFileId(), 'file_size' => filesize($this->getFileLocation()))); }
/** * updateFileComment - Update the comment of a File in a release with the values given by * group_id, package_id, release_id, file_id and comment. * * @param string $sessionKey the session hash associated with the session opened by the person who calls the service * @param int $group_id the ID of the group we want to add the file * @param int $package_id the ID of the package we want to add the file * @param int $release_id the ID of the release we want to add the file * @param int $file_id the ID of the file we want to retrieve the content * @param string $comment A comment/description of the uploaded file * @return boolean true if the file was updated, or a soap fault if: * - group_id does not match with a valid project, * - the package_id, release_id, file_id does not match * - the user does not have permissions to delete this file * - the system was not able to update the file. */ function updateFileComment($sessionKey, $group_id, $package_id, $release_id, $file_id, $comment) { if (session_continue($sessionKey)) { try { $project_manager = ProjectManager::instance(); $project_manager->getGroupByIdForSoap($group_id, 'updateFileComment'); } catch (SoapFault $e) { return $e; } // retieve the package $pkg_fact = new FRSPackageFactory(); $package =& $pkg_fact->getFRSPackageFromDb($package_id); if (!$package || $package->getGroupID() != $group_id) { return new SoapFault(invalid_package_fault, 'Invalid Package', 'updateFileComment'); } // retrieve the release $release_fact = new FRSReleaseFactory(); $release =& $release_fact->getFRSReleaseFromDb($release_id); if (!$release || $release->getPackageID() != $package_id) { return new SoapFault(invalid_release_fault, 'Invalid Release', 'updateFileComment'); } // retrieve the file $file_factory = new FRSFileFactory(); if (!$file_factory->userCanAdd($group_id)) { return new SoapFault(invalid_file_fault, 'User is not allowed to update file', 'updateFileComment'); } $file = $file_factory->getFRSFileFromDb($file_id); if (!$file) { return new SoapFault(invalid_file_fault, 'Invalid File', 'updateFileComment'); } $data_array = array('comment' => $comment, 'file_id' => $file_id); try { $file_factory->update($data_array); } catch (Exception $e) { return new SoapFault(invalid_file_fault, 'Unable to update: ' . $e->getMessage(), 'updateFileComment'); } } else { return new SoapFault(invalid_session_fault, 'Invalid Session', 'updateFileComment'); } return true; }