FOSSology  4.4.0
Open Source License Compliance by Open Source Software
agent-scanoss.php
Go to the documentation of this file.
1 <?php
2 /***********************************************************
3  *
4  * The SCANOSS Agent for Fossology tool
5  *
6  * Copyright (C) 2018-2022 SCANOSS.COM
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 2 of the License, or
11  * (at your option) any later version.
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <https://www.gnu.org/licenses/>.
18  ********************************************************************/
19 # SPDX-FileCopyrightText: © 2023 SCANOSS.COM
20 
21 # SPDX-License-Identifier: GPL-2.0-only
23 
33 {
34  public function __construct() {
35  $this->Name = "agent_scanoss";
36  $this->Title = _("SCANOSS Toolkit");
37  $this->AgentName = "scanoss";
38 
39  parent::__construct();
40  }
41 
47  public function renderContent(&$vars)
48  {
49  $renderer = $GLOBALS['container']->get('twig.environment');
50  return $renderer->load('scanoss.html.twig')->render($vars);
51  }
52 
53 
54 
59  function AgentHasResults($uploadId=0)
60  {
61  return CheckARS($uploadId, $this->AgentName, "SCANOSS Snippet and License scan", "scanoss_ars");
62  }
63 
68  function preInstall()
69  {
70  $dbManager = $GLOBALS['container']->get('db.manager');
71  $latestPkgAgent = $dbManager->getSingleRow("SELECT agent_enabled FROM agent WHERE agent_name=$1 ORDER BY agent_ts LIMIT 1",array('scanoss'));
72  if (isset($latestPkgAgent) && !$dbManager->booleanFromDb($latestPkgAgent['agent_enabled']))
73  {
74  return 0;
75  }
76  menu_insert("Agents::" . $this->Title, 0, $this->Name);
77  }
78 
79 }
80 
81 register_plugin(new ScanossAgentPlugin());
UI plugin of scanoss Agent.
AgentHasResults($uploadId=0)
renderContent(&$vars)
Render HTML from template.
CheckARS($upload_pk, $AgentName, $AgentDesc, $AgentARSTableName)
Check the ARS table to see if an agent has successfully scanned an upload.
menu_insert($Path, $LastOrder=0, $URI=NULL, $Title=NULL, $Target=NULL, $HTML=NULL)
Given a Path, order level for the last item, and optional plugin name, insert the menu item.