function &getGroupsByName($session_ser, $group_names) { session_continue($session_ser); $grps =& group_get_objects_by_name($group_names); if (!$grps) { return new soap_fault('2002', 'group', 'Could Not Get Groups by Name', 'Could Not Get Groups by Name'); } return groups_to_soap($grps); }
function checkUsersExistence($sessionKey, $users) { if (session_continue($sessionKey)) { try { $existingUsers = array(); $um = UserManager::instance(); $currentUser = $um->getCurrentUser(); foreach ($users as $userIdentifier) { $userObj = $um->getUserByIdentifier($userIdentifier); $userInfo = user_to_soap($userIdentifier, $userObj, $currentUser); if ($userInfo) { $existingUsers[] = $userInfo; } } return $existingUsers; } catch (Exception $e) { return new SoapFault('0', $e->getMessage(), 'checkUsersExistence'); } } else { return new SoapFault(invalid_session_fault, 'Invalid Session ', 'checkUsersExistence'); } }
/** * continueSession - A utility method to carry on with an already established session * * @param string The session key */ function continue_session($sessionKey) { session_continue($sessionKey); }
/** * deleteEmptyRelease - Delete an empty release or all empty releases in 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 Integer $group_id Id of the project in which we want to delete empty releases * @param Integer $package_id Id of the package in which we want to delete empty releases * @param Integer $release_id Id of the release to delete * @param Boolean $cleanup_all Set to true to delete all empty releases * * @return Array list of deleted releases, or a soap fault if: * - group_id does not match with a valid project * - the package_id does not match * - the user does not have permissions to delete releases * - the system was not able to delete the releases. */ function deleteEmptyRelease($sessionKey, $group_id, $package_id, $release_id, $cleanup_all) { if (session_continue($sessionKey)) { try { $pm = ProjectManager::instance(); $pm->getGroupByIdForSoap($group_id, 'deleteRelease'); } catch (SoapFault $e) { return $e; } $packageFactory = new FRSPackageFactory(); $package = $packageFactory->getFRSPackageFromDb($package_id); if (!$package || $package->getGroupID() != $group_id) { return new SoapFault(invalid_package_fault, 'Invalid Package', 'deleteRelease'); } $releaseFactory = new FRSReleaseFactory(); $releases = array(); if ($release_id && !$cleanup_all) { $release = $releaseFactory->getFRSReleaseFromDb($release_id); if (!$release || $release->getPackageID() != $package_id) { return new SoapFault(invalid_release_fault, 'Invalid Release', 'deleteRelease'); } $releases[] = $release; } elseif ($cleanup_all) { // retrieve all the releases $releases = $releaseFactory->getFRSReleasesFromDb($package_id); } $deleted = array(); foreach ($releases as $release) { $fileFactory = new FRSFileFactory(); $files = $fileFactory->getFRSFilesFromDb($release->getReleaseID()); if (empty($files)) { if ($releaseFactory->userCanUpdate($group_id, $release->getReleaseID())) { if ($releaseFactory->delete_release($group_id, $release->getReleaseID())) { $deleted[] = release_to_soap($release); } else { return new SoapFault(invalid_package_fault, 'Release ' . $release->getReleaseID() . ' could not be deleted', 'deleteRelease'); } } else { return new SoapFault(invalid_package_fault, 'You don\'t have permission to delete package ' . $release->getReleaseID(), 'deleteRelease'); } } } return $deleted; } else { return new SoapFault(invalid_session_fault, 'Invalid Session', 'deleteRelease'); } }
/** * MSPCreateProject * Create SubProjects * * @author Luis Hurtado luis@gforgegroup.com * @param groupid ID Group * @param session_hash User Session * @param name Project name * @param ispublic 1 Public 0 Private * @param description Project Description * @return ProjectGroup Object ProjectGroup * @date 2005-01-19 * */ function &MSPCreateProject($groupid, $session_hash, $name, $ispublic, $description) { if (!session_continue($session_hash)) { $array['success'] = false; $array['errormessage'] = 'Could Not Continue Session'; } $group = group_get_object($groupid); if (!$group || !is_object($group)) { $res['code'] = "error"; $res['description'] = "No Such Group"; return $res; } else { $perm =& $group->getPermission(session_get_user()); if (!$perm || !is_object($perm)) { $res['code'] = "error"; $res['description'] = "Could Not Get Perm Object"; return $res; } elseif ($perm->isError()) { $res['code'] = "error"; $res['description'] = "Error in Perm Object: " . $perm->getErrorMessage(); return $res; } elseif (!$perm->isPMAdmin()) { $res['code'] = "error"; $res['description'] = "User must be Admin"; return $res; } else { $pg = new ProjectGroup($group); if (!$pg || !is_object($pg)) { $res['code'] = "error"; $res['description'] = "Could Not Get ProjectGroup"; return $res; } else { if (!$pg->create($name, $description, $ispublic)) { $res['code'] = "error"; $res['description'] = 'Error Creating Subproject ' . $pg->getErrorMessage(); return $res; } else { return $pg; } } } } }
/** * Makes a docman request * * @param string $sessionKey Session Key * @param int $group_id Group ID * @param array $params Request parameters * @return unknown Request response */ function _makeDocmanRequest($sessionKey, $group_id, $action, $params = array()) { $actor = "_makeDocmanRequest ({$action})"; if (session_continue($sessionKey)) { try { $pm = ProjectManager::instance(); $pm->getGroupByIdForSoap($group_id, $actor); } catch (SoapFault $e) { return $e; } $params['group_id'] = $group_id; $params['action'] = $action; $params['confirm'] = true; $request =& new SOAPRequest($params); $plugin_manager =& PluginManager::instance(); $p =& $plugin_manager->getPluginByName('docman'); if ($p && $plugin_manager->isPluginAvailable($p)) { // Process request $result = $p->processSOAP($request); if ($GLOBALS['Response']->feedbackHasErrors()) { $msg = $GLOBALS['Response']->getRawFeedback(); return new SoapFault(null, $msg, $actor); } else { return $result; } } else { return new SoapFault(PLUGIN_DOCMAN_SOAP_FAULT_UNAVAILABLE_PLUGIN, 'Unavailable plugin', $actor); } } else { return new SoapFault(invalid_session_fault, 'Invalid Session', $actor); } }
/** * 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'); } }
/** * 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'); } }
/** * logout : logout the Codendi server * * @param string $sessionKey the session hash associated with the session opened by the person who calls the service */ function logout($sessionKey) { global $session_hash; if (session_continue($sessionKey)) { UserManager::instance()->logout(); } else { return new SoapFault(invalid_session_fault, 'Invalid Session', 'logout'); } }
/** * Returns the Ugroups associated to the given project * This function can only be called by members of the group */ function getGroupUgroups($sessionKey, $group_id) { if (session_continue($sessionKey)) { try { $pm = ProjectManager::instance(); $group = $pm->getGroupByIdForSoap($group_id, 'getGroupUgroups'); $ugroups = ugroup_get_ugroups_with_members($group_id); return ugroups_to_soap($ugroups); } catch (SoapFault $e) { return $e; } } else { return new SoapFault(invalid_session_fault, 'Invalid Session', 'getGroupUgroups'); } }