29 const NAME =
"scheduleAgentAjax";
34 function __construct()
36 parent::__construct(self::NAME, array(
37 self::TITLE => _(
"Private: schedule a agent scan from post"),
41 $this->uploadDao = $this->
getObject(
'dao.upload');
48 protected function handle(Request $request)
53 $userId = $_SESSION[
'UserId'];
54 $groupId = $_SESSION[
'GroupId'];
55 $uploadId = intval($_POST[
'uploadId']);
56 $agentName = $_POST[
'agentName'];
59 $upload = $this->uploadDao->getUpload($uploadId);
60 $uploadName = $upload->getFilename();
64 if ($jobqueueId == 0) {
65 $jobId = JobAddJob($userId, $groupId, $uploadName, $uploadId);
66 $jobqueueId = $ourPlugin->AgentAdd($jobId, $uploadId, $errorMessage, array());
69 $errorMessage =
"bad request";
74 $headers = array(
'Content-type' =>
'text/json');
75 if (empty($errorMessage) && ($jobqueueId > 0)) {
76 return new Response(json_encode(array(
"jqid" => $jobqueueId)), Response::HTTP_OK, $headers);
78 return new Response(json_encode(array(
"error" => $errorMessage)), Response::HTTP_INTERNAL_SERVER_ERROR, $headers);
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.
ReportCachePurgeAll()
Purge all records from the report cache.