/** * List all files for a given project * @param project the name of the project * @param key the web API key for that project * @param [match] regular expression that files must match * @param [mostrecent] include this if you only want the most recent match */ public function ListFiles() { include_once 'include/common.php'; include_once 'models/project.php'; global $CDASH_DOWNLOAD_RELATIVE_URL; if (!isset($this->Parameters['project'])) { return array('status' => false, 'message' => 'You must specify a project parameter.'); } $projectid = get_project_id($this->Parameters['project']); if (!is_numeric($projectid) || $projectid <= 0) { return array('status' => false, 'message' => 'Project not found.'); } $Project = new Project(); $Project->Id = $projectid; $files = $Project->GetUploadedFilesOrUrls(); if (!$files) { return array('status' => false, 'message' => 'Error in Project::GetUploadedFilesOrUrls'); } $filteredList = array(); foreach ($files as $file) { if ($file['isurl']) { continue; // skip if filename is a URL } if (isset($this->Parameters['match']) && !preg_match('/' . $this->Parameters['match'] . '/', $file['filename'])) { continue; //skip if it doesn't match regex } $filteredList[] = array_merge($file, array('url' => $CDASH_DOWNLOAD_RELATIVE_URL . '/' . $file['sha1sum'] . '/' . $file['filename'])); if (isset($this->Parameters['mostrecent'])) { break; //user requested only the most recent file } } return array('status' => true, 'files' => $filteredList); }