FOSSology  4.4.0
Open Source License Compliance by Open Source Software
agent-monk.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2008-2013 Hewlett-Packard Development Company, L.P.
4  SPDX-FileCopyrightText: © 2014-2015 Siemens AG
5 
6  SPDX-License-Identifier: GPL-2.0-only
7 */
8 
10 
12 {
13  public function __construct()
14  {
15  $this->Name = "agent_monk";
16  $this->Title = _("Monk License Analysis, scanning for licenses performing a text comparison");
17  $this->AgentName = "monk";
18 
19  parent::__construct();
20  }
21 
22  function AgentHasResults($uploadId=0)
23  {
24  return CheckARS($uploadId, $this->AgentName, "monk agent", "monk_ars");
25  }
26 
31  public function AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=array(), $arguments=null)
32  {
33  $unpackArgs = intval(@$_POST['scm']) == 1 ? '-I' : '';
34  if ($this->AgentHasResults($uploadId) == 1) {
35  return 0;
36  }
37 
38  $jobQueueId = \IsAlreadyScheduled($jobId, $this->AgentName, $uploadId);
39  if ($jobQueueId != 0) {
40  return $jobQueueId;
41  }
42 
43  $args = $unpackArgs;
44  if (!empty($unpackArgs)) {
45  return $this->doAgentAdd($jobId, $uploadId, $errorMsg, array("agent_mimetype"),$uploadId,$args);
46  } else {
47  return $this->doAgentAdd($jobId, $uploadId, $errorMsg, array("agent_adj2nest"), $uploadId);
48  }
49  }
50 
57  protected function isAgentIncluded($dependencies, $agentName)
58  {
59  foreach ($dependencies as $dependency) {
60  if ($dependency == $agentName) {
61  return true;
62  }
63  if (is_array($dependency) && $agentName == $dependency['name']) {
64  return true;
65  }
66  }
67  return false;
68  }
69 }
70 
71 register_plugin(new MonkAgentPlugin());
doAgentAdd($jobId, $uploadId, &$errorMsg, $dependencies, $jqargs="", $jq_cmd_args=null)
isAgentIncluded($dependencies, $agentName)
Definition: agent-monk.php:57
AgentHasResults($uploadId=0)
Definition: agent-monk.php:22
AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=array(), $arguments=null)
Definition: agent-monk.php:31
CheckARS($upload_pk, $AgentName, $AgentDesc, $AgentARSTableName)
Check the ARS table to see if an agent has successfully scanned an upload.
IsAlreadyScheduled($job_pk, $AgentName, $upload_pk)
Check if an agent is already scheduled in a job.
Definition: common-job.php:378