/** * Try to find the project that match what can be entred in autocompleter * * This can be either: * - The autocomplter result: Public Name (unixname) * - The group id: 101 * - The project unix name: unixname * * @return Project */ public function getProjectFromAutocompleter($name) { $matches = array(); $dao = new ProjectDao(CodendiDataAccess::instance()); if (preg_match('/^(.*) \\((.*)\\)$/', $name, $matches)) { // Autocompleter "normal" form: Public Name (unix_name); { $dar = $dao->searchByUnixGroupName($matches[2]); } elseif (is_numeric($name)) { // Only group_id (for codex guru or psychopath, more or less the same thing anyway) $dar = $dao->searchById($name); } else { // Give it a try with only the given name $dar = $dao->searchByUnixGroupName($name); } if ($dar && !$dar->isError() && $dar->rowCount() == 1) { return $this->getAndCacheProject($dar->getRow()); } return false; }
/** * Returns a project from its name * * @param String $projectName * * @return Integer */ function getProjectIdByName($projectName) { $dao = new ProjectDao(CodendiDataAccess::instance()); $res = $dao->searchByUnixGroupName($projectName); $groupId = $res->getRow(); return $groupId['group_id']; }