Example #1
0
 /**
  * getArtifactHistory - returns the array of ArtifactHistory of the artifact $artifact_id in the tracker $tracker_id of the project $group_id
  *
  * @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 retrieve the history
  * @param int $tracker_id the ID of the tracker we want to retrieve the history
  * @param int $artifact_id the ID of the artifact we want to retrieve the history
  * @return array{SOAPArtifactHistory} the array of the history of the artifact,
  *              or a soap fault if :
  *              - group_id does not match with a valid project, 
  *              - tracker_id does not match with a valid tracker
  *              - artifact_id does not match with a valid artifact
  */
 function getArtifactHistory($sessionKey, $group_id, $tracker_id, $artifact_id)
 {
     if (session_continue($sessionKey)) {
         $pm = ProjectManager::instance();
         try {
             $grp = $pm->getGroupByIdForSoap($group_id, 'getArtifactHistory');
         } catch (SoapFault $e) {
             return $e;
         }
         if (!$project->usesService('plugin_tracker')) {
             return new SoapFault(get_service_fault, 'Tracker service is not used for this project.', 'getArtifactFollowups');
         }
         $tf = TrackerFactory::instance();
         if (!$tf) {
             return new SoapFault(get_tracker_factory_fault, 'Could Not Get TrackerFactory', 'getArtifactFollowups');
         }
         $tracker = $tf->getTrackerById($tracker_id);
         if ($tracker == null) {
             return new SoapFault(get_tracker_factory_fault, 'Could Not Get Tracker', 'getArtifactFollowups');
         } else {
             if (!$tracker->userCanView()) {
                 return new SoapFault(get_tracker_factory_fault, 'Permission Denied: You are not granted sufficient permission to perform this operation.', 'getArtifactFollowups');
             } else {
                 $af = Tracker_ArtifactFactory::instance();
                 $artifact = $af->getArtifactById($artifact_id);
                 $changesets = $artifact->getChangesets();
                 return history_to_soap($changesets, $group_id);
             }
         }
     } else {
         return new SoapFault(invalid_session_fault, 'Invalid Session', 'getArtifactHistory');
     }
 }
Example #2
0
 /**
  * getArtifactHistory - returns the array of ArtifactHistory of the artifact $artifact_id in the tracker $group_artifact_id of the project $group_id
  *
  * @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 retrieve the history
  * @param int $group_artifact_id the ID of the tracker we want to retrieve the history
  * @param int $artifact_id the ID of the artifact we want to retrieve the history
  * @return array{SOAPArtifactHistory} the array of the history of the artifact,
  *              or a soap fault if :
  *              - group_id does not match with a valid project, 
  *              - group_artifact_id does not match with a valid tracker
  *              - artifact_id does not match with a valid artifact
  */
 function getArtifactHistory($sessionKey, $group_id, $group_artifact_id, $artifact_id)
 {
     global $art_field_fact;
     if (session_continue($sessionKey)) {
         try {
             $pm = ProjectManager::instance();
             $grp = $pm->getGroupByIdForSoap($group_id, 'getArtifactHistory');
         } catch (SoapFault $e) {
             return $e;
         }
         $at = new ArtifactType($grp, $group_artifact_id);
         if (!$at || !is_object($at)) {
             return new SoapFault(get_artifact_type_fault, 'Could Not Get ArtifactType', 'getArtifactHistory');
         } elseif ($at->isError()) {
             return new SoapFault(get_artifact_type_fault, $at->getErrorMessage(), 'getArtifactHistory');
         }
         $art_field_fact = new ArtifactFieldFactory($at);
         if (!$art_field_fact || !is_object($art_field_fact)) {
             return new SoapFault(get_artifact_field_factory_fault, 'Could Not Get ArtifactFieldFactory', 'getArtifactHistory');
         } elseif ($art_field_fact->isError()) {
             return new SoapFault(get_artifact_field_factory_fault, $art_field_fact->getErrorMessage(), 'getArtifactHistory');
         }
         $a = new Artifact($at, $artifact_id);
         if (!$a || !is_object($a)) {
             return new SoapFault(get_artifact_fault, 'Could Not Get Artifact', 'getArtifactHistory');
         } elseif ($a->isError()) {
             return new SoapFault(get_artifact_fault, $a->getErrorMessage(), 'getArtifactHistory');
         } elseif (!$a->userCanView()) {
             return new SoapFault(get_artifact_fault, 'Permissions denied', 'getArtifactHistory');
         }
         return history_to_soap($group_id, $group_artifact_id, $a->getHistory());
     } else {
         return new SoapFault(invalid_session_fault, 'Invalid Session', 'getArtifactHistory');
     }
 }