function getFiles($session_ser, $group_id, $package_id, $release_id) { continue_session($session_ser); $grp =& group_get_object($group_id); if (!$grp || !is_object($grp)) { return new soap_fault('', 'getFiles', 'Could Not Get Group', 'Could Not Get Group'); } elseif ($grp->isError()) { return new soap_fault('', 'getFiles', $grp->getErrorMessage(), $grp->getErrorMessage()); } $frsp =& frspackage_get_object($package_id); if (!$frsp || !is_object($frsp)) { return new soap_fault('', 'getFiles', 'Could Not Get Package', 'Could Not Get Package'); } else { if ($frsp->isError()) { return new soap_fault('', 'getFiles', $frsp->getErrorMessage(), $frsp->getErrorMessage()); } } //TODO: Check that the release belongs to the package $frsr =& frsrelease_get_object($release_id); if (!$frsr || !is_object($frsr)) { return new soap_fault('', 'getFiles', 'Could Not Get Release', 'Could Not Get Release'); } else { if ($frsr->isError()) { return new soap_fault('', 'getFiles', $frsr->getErrorMessage(), $frsr->getErrorMessage()); } } $files_arr =& $frsr->getFiles(); return files_to_soap($files_arr); }
/** * getFiles - returns an array of FRSFiles that belongs to the release identified by release_id, in the package package_id, in 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 array of files * @param int $package_id the ID of the package we want to retrieve the array of files * @param int $release_id the ID of the release we want to retrieve the array of files * @return array the array of SOAPFRSFile that belongs to the project identified by $group_id, in the package $package_id, in the release $release_id * or a soap fault if group_id does not match with a valid project or if package_id does not match with group_id, or if release_id does not match with package_id. */ function getFiles($sessionKey, $group_id, $package_id, $release_id) { if (session_continue($sessionKey)) { try { $pm = ProjectManager::instance(); $pm->getGroupByIdForSoap($group_id, 'getFiles'); } catch (SoapFault $e) { return $e; } // retieve the package $pkg_fact = new FRSPackageFactory(); $package =& $pkg_fact->getFRSPackageFromDb($package_id); if (!$package || $package->isDeleted() || $package->getGroupID() != $group_id) { return new SoapFault(invalid_package_fault, 'Invalid Package', 'getFiles'); } // check access rights to this package if (!$package->userCanRead() || !$package->isActive()) { return new SoapFault(invalid_package_fault, 'Permission to this Package denied', 'getFiles'); } // retrieve the release $release_fact = new FRSReleaseFactory(); $release =& $release_fact->getFRSReleaseFromDb($release_id); if (!$release || $release->isDeleted() || $release->getPackageID() != $package_id) { return new SoapFault(invalid_release_fault, 'Invalid Release', 'getFiles'); } // check access rights to this release if (!$release->userCanRead() || !$release->isActive()) { return new SoapFault(invalid_release_fault, 'Permission to this Release denied', 'getFiles'); } $files_arr =& $release->getFiles(); return files_to_soap($files_arr); } else { return new SoapFault(invalid_session_fault, 'Invalid Session', 'getFiles'); } }