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 {
14  private $monkDesc = "Scan files for licenses using text comparison method";
15 
16  public function __construct()
17  {
18  $this->Name = "agent_monk";
19  $this->Title = _("Monk License Analysis <img src=\"images/info_16.png\" data-toggle=\"tooltip\" title=\"".$this->monkDesc."\" class=\"info-bullet\"/>");
20  $this->AgentName = "monk";
21 
22  parent::__construct();
23  }
24 
25  function AgentHasResults($uploadId=0)
26  {
27  return CheckARS($uploadId, $this->AgentName, "monk agent", "monk_ars");
28  }
29 
34  public function AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=[],
35  $arguments=null, $request=null, $unpackArgs=null)
36  {
37  if ($request != null && !is_array($request)) {
38  $unpackArgs = intval($request->get('scm', 0)) == 1 ? '-I' : '';
39  } else {
40  $unpackArgs = intval(@$_POST['scm']) == 1 ? '-I' : '';
41  }
42  if ($this->AgentHasResults($uploadId) == 1) {
43  return 0;
44  }
45 
46  $jobQueueId = \IsAlreadyScheduled($jobId, $this->AgentName, $uploadId);
47  if ($jobQueueId != 0) {
48  return $jobQueueId;
49  }
50 
51  $args = $unpackArgs;
52  if (!empty($unpackArgs)) {
53  return $this->doAgentAdd($jobId, $uploadId, $errorMsg, array("agent_mimetype"),$uploadId,$args,$request);
54  } else {
55  return $this->doAgentAdd($jobId, $uploadId, $errorMsg, array("agent_adj2nest"), $uploadId, null, $request);
56  }
57  }
58 
65  protected function isAgentIncluded($dependencies, $agentName)
66  {
67  foreach ($dependencies as $dependency) {
68  if ($dependency == $agentName) {
69  return true;
70  }
71  if (is_array($dependency) && $agentName == $dependency['name']) {
72  return true;
73  }
74  }
75  return false;
76  }
77 }
78 
79 register_plugin(new MonkAgentPlugin());
doAgentAdd($jobId, $uploadId, &$errorMsg, $dependencies, $jqargs="", $jq_cmd_args=null, $request=null)
isAgentIncluded($dependencies, $agentName)
Definition: agent-monk.php:65
AgentHasResults($uploadId=0)
Definition: agent-monk.php:25
AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=[], $arguments=null, $request=null, $unpackArgs=null)
Definition: agent-monk.php:34
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