Beispiel #1
0
 /**
  * getArtifactAttachedFiles - returns the array of ArtifactFile of the artifact $artifact_id in the tracker $group_artifact_id of the project $group_id
  *
  * NOTE : by default, this function does not return the content of the files (for performance reasons). To get the binary content of files, give $set_bin_data the true value. 
  *
  * @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 attached files
  * @param int $group_artifact_id the ID of the tracker we want to retrieve the attached files
  * @param int $artifact_id the ID of the artifact we want to retrieve the attached files
  * @return array{SOAPArtifactFile} the array of the attached file 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 getArtifactAttachedFiles($sessionKey, $group_id, $group_artifact_id, $artifact_id, $set_bin_data = false)
 {
     global $art_field_fact;
     if (session_continue($sessionKey)) {
         $pm = ProjectManager::instance();
         try {
             $grp = $pm->getGroupByIdForSoap($group_id, 'getArtifactAttachedFiles');
         } catch (SoapFault $e) {
             return $e;
         }
         $at = new ArtifactTracker($grp, $group_artifact_id);
         if (!$at || !is_object($at)) {
             return new SoapFault(get_artifact_type_fault, 'Could Not Get ArtifactTracker', 'getArtifactAttachedFiles');
         } elseif ($at->isError()) {
             return new SoapFault(get_artifact_type_fault, $at->getErrorMessage(), 'getArtifactAttachedFiles');
         }
         $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', 'getArtifactAttachedFiles');
         } elseif ($art_field_fact->isError()) {
             return new SoapFault(get_artifact_field_factory_fault, $art_field_fact->getErrorMessage(), 'getArtifactAttachedFiles');
         }
         $a = new Artifact($at, $artifact_id);
         if (!$a || !is_object($a)) {
             return new SoapFault(get_artifact_fault, 'Could Not Get Artifact', 'getArtifactAttachedFiles');
         } elseif ($a->isError()) {
             return new SoapFault(get_artifact_fault, $a->getErrorMessage(), 'getArtifactAttachedFiles');
         } elseif (!$a->userCanView()) {
             return new SoapFault(get_artifact_fault, 'Permissions denied', 'getArtifactAttachedFiles');
         }
         return artifactfiles_to_soap($a->getAttachedFiles(), $set_bin_data);
     } else {
         return new SoapFault(invalid_session_fault, 'Invalid Session', 'getArtifactAttachedFiles');
     }
 }
Beispiel #2
0
function &getArtifactFiles($session_ser, $group_id, $group_artifact_id, $artifact_id)
{
    continue_session($session_ser);
    $grp =& group_get_object($group_id);
    if (!$grp || !is_object($grp)) {
        return new soap_fault('', 'getArtifactFiles', 'Could Not Get Group', 'Could Not Get Group');
    } elseif ($grp->isError()) {
        return new soap_fault('', 'getArtifactFiles', $grp->getErrorMessage(), $grp->getErrorMessage());
    }
    $at = new ArtifactType($grp, $group_artifact_id);
    if (!$at || !is_object($at)) {
        return new soap_fault('', 'getArtifactFiles', 'Could Not Get ArtifactType', 'Could Not Get ArtifactType');
    } elseif ($at->isError()) {
        return new soap_fault('', 'getArtifactFiles', $at->getErrorMessage(), $at->getErrorMessage());
    }
    $a = new Artifact($at, $artifact_id);
    if (!$a || !is_object($a)) {
        return new soap_fault('', 'getArtifactFiles', 'Could Not Get Artifact', 'Could Not Get Artifact');
    } elseif ($a->isError()) {
        return new soap_fault('', 'getArtifactFiles', $a->getErrorMessage(), $a->getErrorMessage());
    }
    $files_arr = $a->getFiles();
    $return = artifactfiles_to_soap($files_arr);
    return $return;
}