FOSSology
3.2.0rc1
Open Source License Compliance by Open Source Software
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
ReportImportAgentPlugin.php
1
<?php
2
/***********************************************************
3
* Copyright (C) 2015-2017, Siemens AG
4
*
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* version 2 as published by the Free Software Foundation.
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License along
15
* with this program; if not, write to the Free Software Foundation, Inc.,
16
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
***********************************************************/
18
19
use
Fossology\Lib\Plugin\AgentPlugin
;
20
21
class
ReportImportAgentPlugin
extends
AgentPlugin
22
{
23
private
static
$keys = array(
24
'addConcludedAsDecisions'
,
25
'addLicenseInfoFromInfoInFile'
,
26
'addLicenseInfoFromConcluded'
,
27
'addConcludedAsDecisionsOverwrite'
,
28
'addConcludedAsDecisionsTBD'
,
29
'addCopyrights'
,
30
'addNewLicensesAs'
31
);
32
33
public
function
__construct() {
34
$this->Name =
"agent_reportImport"
;
35
$this->Title = _(
"Report Import"
);
36
$this->AgentName =
"reportImport"
;
37
38
parent::__construct();
39
}
40
41
function
preInstall()
42
{
43
// no AgentCheckBox
44
}
45
46
public
function
setAdditionalJqCmdArgs($request)
47
{
48
$additionalJqCmdArgs =
""
;
49
50
foreach
(self::$keys as $key) {
51
if
($request->get($key) !== NULL)
52
{
53
$additionalJqCmdArgs .=
" --"
.$key.
"="
.$request->get($key);
54
}
55
}
56
57
return
$additionalJqCmdArgs;
58
}
59
60
public
function
addReport($report)
61
{
62
if
($report &&
63
is_array($report) &&
64
array_key_exists(
'error'
,$report) &&
65
$report[
'error'
] == UPLOAD_ERR_OK)
66
{
67
if
(!file_exists($report[
'tmp_name'
]))
68
{
69
throw
new
Exception(
'Uploaded tmpfile not found'
);
70
}
71
72
global $SysConf;
73
$fileBase = $SysConf[
'FOSSOLOGY'
][
'path'
].
"/ReportImport/"
;
74
if
(!is_dir($fileBase))
75
{
76
mkdir($fileBase,0755,
true
);
77
}
78
// TODO: validate filename
79
$targetFile = time().
'_'
.rand().
'_'
.$report[
'name'
];
80
if
(move_uploaded_file($report[
'tmp_name'
], $fileBase.$targetFile))
81
{
82
return
'--report='
.$targetFile;
83
}
84
}elseif($report && is_string($report)){
85
return
'--report='
.$report;
86
}
87
return
''
;
88
}
89
}
90
91
register_plugin(
new
ReportImportAgentPlugin
());
ReportImportAgentPlugin
Definition:
ReportImportAgentPlugin.php:21
AgentPlugin
Fossology\Lib\Plugin\AgentPlugin
Definition:
AgentPlugin.php:21
src
reportImport
ui
ReportImportAgentPlugin.php
Generated on Mon Jun 29 2020 12:03:43 for FOSSology by
1.8.11