function create_web_api_token($projectid) { $token = generate_web_api_key(); $expTime = gmdate(FMT_DATETIME, time() + 3600); //hard-coding 1 hour for now pdo_query("INSERT INTO apitoken (projectid,token,expiration_date) VALUES ({$projectid},'{$token}','{$expTime}')"); clean_outdated_api_tokens(); return $token; }
/** Fill in all the information from the database */ function Fill() { if (!$this->Id) { echo "Project Fill(): Id not set"; } $project = pdo_query("SELECT * FROM project WHERE id=" . $this->Id); if (!$project) { add_last_sql_error("Project Fill", $this->Id); return; } if ($project_array = pdo_fetch_array($project)) { $this->Name = $project_array['name']; $this->Description = $project_array['description']; $this->HomeUrl = $project_array['homeurl']; $this->CvsUrl = $project_array['cvsurl']; $this->DocumentationUrl = $project_array['documentationurl']; $this->BugTrackerUrl = $project_array['bugtrackerurl']; $this->BugTrackerFileUrl = $project_array['bugtrackerfileurl']; $this->ImageId = $project_array['imageid']; $this->Public = $project_array['public']; $this->CoverageThreshold = $project_array['coveragethreshold']; $this->TestingDataUrl = $project_array['testingdataurl']; $this->NightlyTime = $project_array['nightlytime']; $this->GoogleTracker = $project_array['googletracker']; $this->EmailLowCoverage = $project_array['emaillowcoverage']; $this->EmailTestTimingChanged = $project_array['emailtesttimingchanged']; $this->EmailBrokenSubmission = $project_array['emailbrokensubmission']; $this->EmailRedundantFailures = $project_array['emailredundantfailures']; $this->EmailAdministrator = $project_array['emailadministrator']; $this->ShowIPAddresses = $project_array['showipaddresses']; $this->DisplayLabels = $project_array['displaylabels']; $this->ShowCoverageCode = $project_array['showcoveragecode']; $this->AutoremoveTimeframe = $project_array['autoremovetimeframe']; $this->AutoremoveMaxBuilds = $project_array['autoremovemaxbuilds']; $this->UploadQuota = $project_array['uploadquota']; $this->CvsViewerType = $project_array['cvsviewertype']; $this->TestTimeStd = $project_array['testtimestd']; $this->TestTimeStdThreshold = $project_array['testtimestdthreshold']; $this->ShowTestTime = $project_array['showtesttime']; $this->TestTimeMaxStatus = $project_array['testtimemaxstatus']; $this->EmailMaxItems = $project_array['emailmaxitems']; $this->EmailMaxChars = $project_array['emailmaxchars']; $this->WebApiKey = $project_array['webapikey']; if ($this->WebApiKey == '') { // If no web API key exists, we add one include_once 'cdash/common.php'; $newKey = generate_web_api_key(); pdo_query("UPDATE project SET webapikey='{$newKey}' WHERE id=" . $this->Id); $this->WebApiKey = $newKey; } } // Check if we have a robot $robot = pdo_query("SELECT * FROM projectrobot WHERE projectid=" . $this->Id); if (!$robot) { add_last_sql_error("Project Fill", $this->Id); return; } if ($robot_array = pdo_fetch_array($robot)) { $this->RobotName = $robot_array['robotname']; $this->RobotRegex = $robot_array['authorregex']; } // Check if we have a ctest script $script = pdo_query("SELECT script FROM projectjobscript WHERE projectid=" . $this->Id); if (!$script) { add_last_sql_error("Project Fill", $this->Id); return; } if ($script_array = pdo_fetch_array($script)) { $this->CTestTemplateScript = $script_array['script']; } }