FOSSology  4.4.0
Open Source License Compliance by Open Source Software
agent-copyright.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2010-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 
16 {
17  public function __construct()
18  {
19  $this->Name = "agent_copyright";
20  $this->Title = _("Copyright/Email/URL/Author Analysis");
21  $this->AgentName = "copyright";
22 
23  parent::__construct();
24  }
25 
30  function AgentHasResults($uploadId=0)
31  {
32  return CheckARS($uploadId, $this->AgentName, "copyright scanner", "copyright_ars");
33  }
34 
39  public function AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=array(), $arguments=null)
40  {
41  $unpackArgs = intval(@$_POST['scm']) == 1 ? '-I' : '';
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);
54  } else {
55  return $this->doAgentAdd($jobId, $uploadId, $errorMsg, array("agent_adj2nest"), $uploadId);
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 CopyrightAgentPlugin());
Create UI plugin for copyright agent.
AgentHasResults($uploadId=0)
isAgentIncluded($dependencies, $agentName)
AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=array(), $arguments=null)
doAgentAdd($jobId, $uploadId, &$errorMsg, $dependencies, $jqargs="", $jq_cmd_args=null)
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