13 use Symfony\Component\HttpFoundation\Request;
14 use Symfony\Component\HttpFoundation\Response;
18 const NAME =
"scheduleAgentAjax";
23 function __construct()
25 parent::__construct(self::NAME, array(
26 self::TITLE => _(
"Private: schedule a agent scan from post"),
30 $this->uploadDao = $this->
getObject(
'dao.upload');
37 protected function handle(Request $request)
42 $userId = $_SESSION[
'UserId'];
43 $groupId = $_SESSION[
'GroupId'];
44 $uploadId = intval($_POST[
'uploadId']);
45 $agentName = $_POST[
'agentName'];
48 $upload = $this->uploadDao->getUpload($uploadId);
49 $uploadName = $upload->getFilename();
51 if ($ourPlugin ===
null) {
52 return new Response(json_encode([
"error" =>
"Unable to find $agentName"]),
53 Response::HTTP_INTERNAL_SERVER_ERROR, [
"Content-type" =>
"text/json"]);
57 if ($jobqueueId == 0) {
58 $jobId = JobAddJob($userId, $groupId, $uploadName, $uploadId);
59 $jobqueueId = $ourPlugin->AgentAdd($jobId, $uploadId, $errorMessage, array());
62 $errorMessage =
"bad request";
67 $headers = array(
'Content-type' =>
'text/json');
68 if (empty($errorMessage) && ($jobqueueId > 0)) {
69 return new Response(json_encode(array(
"jqid" => $jobqueueId)), Response::HTTP_OK, $headers);
71 return new Response(json_encode(array(
"error" => $errorMessage)), Response::HTTP_INTERNAL_SERVER_ERROR, $headers);
76 register_plugin(
new ScheduleAgent());
Contains the constants and helpers for authentication of user.
ReportCachePurgeAll()
Purge all records from the report cache.
isAlreadyRunning($agentName, $upload_pk)
Check if an agent is already running in a job.
plugin_find($pluginName)
Given the official name of a plugin, return the $Plugins object.