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 {
18  private $copyrightDesc = "Performs file scanning to find text fragments that could be relevant to copyrights, emails, and URLs";
19 
20  public function __construct()
21  {
22  $this->Name = "agent_copyright";
23  $this->Title = _("Copyright/Email/URL/Author Analysis <img src=\"images/info_16.png\" data-toggle=\"tooltip\" title=\"".$this->copyrightDesc."\" class=\"info-bullet\"/>");
24  $this->AgentName = "copyright";
25 
26  parent::__construct();
27  }
28 
33  function AgentHasResults($uploadId=0)
34  {
35  return CheckARS($uploadId, $this->AgentName, "copyright scanner", "copyright_ars");
36  }
37 
42  public function AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=[],
43  $arguments=null, $request=null, $unpackArgs=null)
44  {
45  if ($request != null && !is_array($request)) {
46  $unpackArgs = intval($request->get('scm', 0)) == 1 ? '-I' : '';
47  } else {
48  $unpackArgs = intval(@$_POST['scm']) == 1 ? '-I' : '';
49  }
50  if ($this->AgentHasResults($uploadId) == 1) {
51  return 0;
52  }
53 
54  $jobQueueId = \IsAlreadyScheduled($jobId, $this->AgentName, $uploadId);
55  if ($jobQueueId != 0) {
56  return $jobQueueId;
57  }
58 
59  $args = $unpackArgs;
60  if (!empty($unpackArgs)) {
61  return $this->doAgentAdd($jobId, $uploadId, $errorMsg, array("agent_mimetype"),$uploadId,$args,$request);
62  } else {
63  return $this->doAgentAdd($jobId, $uploadId, $errorMsg, array("agent_adj2nest"), $uploadId, null, $request);
64  }
65  }
66 
73  protected function isAgentIncluded($dependencies, $agentName)
74  {
75  foreach ($dependencies as $dependency) {
76  if ($dependency == $agentName) {
77  return true;
78  }
79  if (is_array($dependency) && $agentName == $dependency['name']) {
80  return true;
81  }
82  }
83  return false;
84  }
85 }
86 
87 register_plugin(new CopyrightAgentPlugin());
Create UI plugin for copyright agent.
AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=[], $arguments=null, $request=null, $unpackArgs=null)
AgentHasResults($uploadId=0)
isAgentIncluded($dependencies, $agentName)
doAgentAdd($jobId, $uploadId, &$errorMsg, $dependencies, $jqargs="", $jq_cmd_args=null, $request=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