Exemple #1
0
 /**
  * updateRelease - update a release in the file release manager, in the package $package_id of the project $group_id with given values
  *
  * @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 the release is in
  * @param int $package_id the ID of the package the release is in
  * @param int $release_id the ID of the release we want to update
  * @param string $notes the notes of the release
  * @param string $changes the changes of the release
  * @param int $status_id the ID of the status of the release
  *
  * @return bool true if release updated
  *              or a soap fault if :
  *              - group_id does not match with a valid project,
  *              - package_id does not match with a valid package,
  *              - package_id does not belong to the project group_id,
  *              - the user does not have the permissions to update a release
  *              - the release creation failed.
  */
 function updateRelease($sessionKey, $group_id, $package_id, $release_id, $notes, $changes, $status_id)
 {
     if (!session_continue($sessionKey)) {
         return new SoapFault(invalid_session_fault, 'Invalid Session', 'updateRelease');
     }
     $project_manager = ProjectManager::instance();
     try {
         $project_manager->getGroupByIdForSoap($group_id, 'updateRelease');
     } catch (SoapFault $e) {
         return $e;
     }
     $pkg_fact = new FRSPackageFactory();
     $package = $pkg_fact->getFRSPackageFromDb($package_id);
     if (!$package || $package->getGroupID() != $group_id) {
         return new SoapFault(invalid_package_fault, 'Invalid Package', 'updateRelease');
     }
     $release_factory = new FRSReleaseFactory();
     if (!$release_factory->userCanUpdate($group_id, $release_id)) {
         return new SoapFault(invalid_release_fault, 'User is not allowed to update a release', 'updateRelease');
     }
     if (!($release = $release_factory->getFRSReleaseFromDb($release_id))) {
         return new SoapFault(invalid_release_fault, 'Release does not exist', 'updateRelease');
     }
     $release_array = array('package_id' => $package_id, 'notes' => $notes, 'changes' => $changes, 'status_id' => $status_id, 'release_id' => $release_id);
     if (!$release_factory->update($release_array)) {
         return new SoapFault(invalid_release_fault, 'Update Failed', 'updateRelease');
     }
     return true;
 }