FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
agent-keyword.php
1 <?php
2 /***********************************************************
3  Copyright (C) 2018, Siemens AG
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License
7  version 2 as published by the Free Software Foundation.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License along
15  with this program; if not, write to the Free Software Foundation, Inc.,
16  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 ***********************************************************/
18 
20 
22 {
23  public function __construct() {
24  $this->Name = "agent_keyword";
25  $this->Title = _("Keyword Analysis");
26  $this->AgentName = "keyword";
27 
28  parent::__construct();
29  }
30 
35  function AgentHasResults($uploadId=0)
36  {
37  return CheckARS($uploadId, $this->AgentName, "keyword scanner", "keyword_ars");
38  }
39 
40 
45  public function AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=array(), $arguments=null)
46  {
47  $unpackArgs = intval(@$_POST['scm']) == 1 ? '-I' : '';
48  if ($this->AgentHasResults($uploadId) == 1) {
49  return 0;
50  }
51 
52  $jobQueueId = \IsAlreadyScheduled($jobId, $this->AgentName, $uploadId);
53  if ($jobQueueId != 0) {
54  return $jobQueueId;
55  }
56 
57  $args = $unpackArgs;
58  if (!empty($unpackArgs)) {
59  return $this->doAgentAdd($jobId, $uploadId, $errorMsg, array("agent_mimetype"),$uploadId,$args);
60  } else {
61  return $this->doAgentAdd($jobId, $uploadId, $errorMsg, array("agent_adj2nest"), $uploadId);
62  }
63  }
64 
71  protected function isAgentIncluded($dependencies, $agentName)
72  {
73  foreach ($dependencies as $dependency) {
74  if ($dependency == $agentName) {
75  return true;
76  }
77  if (is_array($dependency) && $agentName == $dependency['name']) {
78  return true;
79  }
80  }
81  return false;
82  }
83 }
84 
85 register_plugin(new KeywordAgentPlugin());
IsAlreadyScheduled($job_pk, $AgentName, $upload_pk)
Check if an agent is already scheduled in a job.
Definition: common-job.php:380
AgentHasResults($uploadId=0)
CheckARS($upload_pk, $AgentName, $AgentDesc, $AgentARSTableName)
Check the ARS table to see if an agent has successfully scanned an upload.
isAgentIncluded($dependencies, $agentName)
AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=array(), $arguments=null)
doAgentAdd($jobId, $uploadId, &$errorMsg, $dependencies, $jqargs="", $jq_cmd_args=null)