public function doAction()
{
$db = $this->getContext()->getDB();
$request = $this->getContext()->getRequest();
$jobID = $request->getInt('job_id');
$wipeType = $request->getVal('type');
if (!$jobID || !$wipeType) {
$this->setError('missing-parameters');
return;
}
if (!in_array($wipeType, array('delete', 'reset'))) {
$this->setError('invalid-input', 'Invalid wipeType');
return;
}
$projectID = $db->getOne(str_queryf('SELECT
project_id
FROM jobs
WHERE id = %u;', $jobID));
if (!$projectID) {
$this->setError('invalid-input', 'Job not found');
return;
}
// Check authentication
if (!$this->doRequireAuth($projectID)) {
return;
}
$this->doWipeJobs($wipeType, [$jobID]);
$this->setData(array('jobID' => $jobID, 'type' => $wipeType, 'result' => 'ok'));
}