Exemple #1
0
 /**
  * addRelease - add 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 we want to add the release
  * @param int $package_id the ID of the package we want to add the release
  * @param string $name the name of the release we want to add
  * @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
  * @param int $release_date the release date, in timestamp format
  * @return int the ID of the new created release, 
  *              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 create a release
  *              - the release creation failed.
  */
 function addRelease($sessionKey, $group_id, $package_id, $name, $notes, $changes, $status_id, $release_date)
 {
     if (session_continue($sessionKey)) {
         try {
             $pm = ProjectManager::instance();
             $pm->getGroupByIdForSoap($group_id, 'addRelease');
         } 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', 'addRelease');
         }
         $release_fact = new FRSReleaseFactory();
         if ($release_fact->userCanCreate($group_id)) {
             if ($release_fact->isReleaseNameExist($name, $package_id)) {
                 return new SoapFault(invalid_release_fault, 'Release name already exists in this package', 'addRelease');
             } else {
                 $release_array = array('package_id' => $package_id, 'name' => $name, 'notes' => $notes, 'changes' => $changes, 'status_id' => $status_id, 'release_date' => $release_date);
                 $dar = $release_fact->create($release_array);
                 if (!$dar) {
                     return new SoapFault(invalid_release_fault, $dar->isError(), 'addRelease');
                 } else {
                     // if there is no error, $dar contains the release_id
                     //add the default permission inherited from package
                     //we can modify it from web UI
                     $release_array['release_id'] = $dar;
                     $release = new FRSRelease($release_array);
                     if ($release_fact->setDefaultPermissions($release)) {
                         return $dar;
                     } else {
                         return new SoapFault(invalid_release_fault, 'Could not retrieve parent package permission', 'addRelease');
                     }
                 }
             }
         } else {
             return new SoapFault(invalid_release_fault, 'User is not allowed to create a release', 'addRelease');
         }
     } else {
         return new SoapFault(invalid_session_fault, 'Invalid Session', 'addRelease');
     }
 }