FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
agent-copyright.php
1 <?php
2 /***********************************************************
3  Copyright (C) 2010-2013 Hewlett-Packard Development Company, L.P.
4  Copyright (C) 2014-2015, Siemens AG
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License
8  version 2 as published by the Free Software Foundation.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 ***********************************************************/
19 
21 
27 {
28  public function __construct() {
29  $this->Name = "agent_copyright";
30  $this->Title = _("Copyright/Email/URL/Author Analysis");
31  $this->AgentName = "copyright";
32 
33  parent::__construct();
34  }
35 
40  function AgentHasResults($uploadId=0)
41  {
42  return CheckARS($uploadId, $this->AgentName, "copyright scanner", "copyright_ars");
43  }
44 
49  public function AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=array(), $arguments=null)
50  {
51  $unpackArgs = intval(@$_POST['scm']) == 1 ? '-I' : '';
52  if ($this->AgentHasResults($uploadId) == 1) {
53  return 0;
54  }
55 
56  $jobQueueId = \IsAlreadyScheduled($jobId, $this->AgentName, $uploadId);
57  if ($jobQueueId != 0) {
58  return $jobQueueId;
59  }
60 
61  $args = $unpackArgs;
62  if (!empty($unpackArgs)) {
63  return $this->doAgentAdd($jobId, $uploadId, $errorMsg, array("agent_mimetype"),$uploadId,$args);
64  } else {
65  return $this->doAgentAdd($jobId, $uploadId, $errorMsg, array("agent_adj2nest"), $uploadId);
66  }
67  }
68 
75  protected function isAgentIncluded($dependencies, $agentName)
76  {
77  foreach ($dependencies as $dependency) {
78  if ($dependency == $agentName) {
79  return true;
80  }
81  if (is_array($dependency) && $agentName == $dependency['name']) {
82  return true;
83  }
84  }
85  return false;
86  }
87 }
88 
89 register_plugin(new CopyrightAgentPlugin());
IsAlreadyScheduled($job_pk, $AgentName, $upload_pk)
Check if an agent is already scheduled in a job.
Definition: common-job.php:380
AgentAdd($jobId, $uploadId, &$errorMsg, $dependencies=array(), $arguments=null)
Create UI plugin for copyright agent.
isAgentIncluded($dependencies, $agentName)
CheckARS($upload_pk, $AgentName, $AgentDesc, $AgentARSTableName)
Check the ARS table to see if an agent has successfully scanned an upload.
AgentHasResults($uploadId=0)
doAgentAdd($jobId, $uploadId, &$errorMsg, $dependencies, $jqargs="", $jq_cmd_args=null)