19 define(
"TITLE_ACME_REVIEW", _(
"ACME Review"));
30 function proj_cmp($rowa, $rowb)
32 $key1 = $rowb[
'count'] - $rowa[
'count'];
38 return (strnatcasecmp($rowa[
'project_name'], $rowb[
'project_name']));
43 var $Name =
"acme_review";
44 var $Title = TITLE_ACME_REVIEW;
48 var $Dependency = array(
"browse",
"view");
61 $text = _(
"ACME High Level Review");
65 $text = _(
"ACME Low Level Review");
74 $text2 = _(
"ACME Review");
92 $sql =
"select acme_project_fk from acme_pfile where pfile_fk='$uploadtreeRow[pfile_fk]' limit 1";
93 $result = pg_query($PG_CONN, $sql);
95 if (pg_num_rows($result) > 0) {
97 $acme_pfileRow = pg_fetch_assoc($result);
100 $sql =
"select * from acme_project where acme_project_pk='$acme_pfileRow[acme_project_fk]'";
101 $projresult = pg_query($PG_CONN, $sql);
103 if (pg_num_rows($projresult) > 0) {
104 $acme_project_array[$acme_pfileRow[
'acme_project_fk']] = pg_fetch_assoc(
106 $acme_project_array[$acme_pfileRow[
'acme_project_fk']][
'count'] = (($uploadtreeRow[
'rgt'] -
107 $uploadtreeRow[
'lft']) + 1) / 2;
112 $sql =
"select uploadtree_pk, pfile_fk, lft, rgt from uploadtree where parent= $uploadtreeRow[uploadtree_pk]";
113 $childrenResult = pg_query($PG_CONN, $sql);
115 while ($child = pg_fetch_assoc($childrenResult)) {
118 pg_free_result($childrenResult);
120 pg_free_result($result);
135 $acme_project_array = array();
137 $sql =
"select uploadtree_pk, pfile_fk, lft, rgt from uploadtree where upload_fk='$upload_pk' and parent is null";
138 $result = pg_query($PG_CONN, $sql);
140 $row = pg_fetch_assoc($result);
142 pg_free_result($result);
144 return $acme_project_array;
157 $acme_project_array = array();
160 $sql =
"select distinct(acme_project_fk) as acme_project_fk, count(acme_project_fk) as filecount from acme_pfile 161 right join uploadtree on uploadtree.pfile_fk=acme_pfile.pfile_fk where upload_fk=$upload_pk 162 group by acme_project_fk order by filecount desc";
163 $result = pg_query($PG_CONN, $sql);
165 while ($row = pg_fetch_assoc($result)) {
166 if ($row[
'filecount'] < $MinCount) {
171 $sql =
"select * from acme_project where acme_project_pk='$row[acme_project_fk]'";
172 $projresult = pg_query($PG_CONN, $sql);
174 if (pg_num_rows($projresult) > 0) {
175 $acme_project_array[$idx] = pg_fetch_assoc($projresult);
176 $acme_project_array[$idx][
'count'] = $row[
'filecount'];
181 return($acme_project_array);
194 $uploadtreeRec =
GetSingleRec(
"uploadtree",
"where upload_fk=$upload_pk and parent is null");
195 $Outbuf .=
Dir2Browse($this->Name,$uploadtreeRec[
'uploadtree_pk'], NULL, 1,
"acme");
198 $URI =
"?mod=" . $this->Name .
Traceback_parm_keep(array(
"page",
"upload",
"folic",
"detail"));
199 $Outbuf .=
"<form action='" . $URI .
"' method='POST'>\n";
201 $Outbuf .=
"<table border=1>";
203 $text = _(
'Include');
204 $Outbuf .=
"<th>$text</th>";
205 $text = _(
'Project');
206 $Outbuf .=
"<th>$text</th>";
208 $Outbuf .=
"<th>$text</th>";
210 $Outbuf .=
"<th>$text</th>";
211 $text = _(
'Description');
212 $Outbuf .=
"<th>$text</th>";
213 $text = _(
'License');
214 $Outbuf .=
"<th>$text</th>";
215 $text = _(
'Version');
216 $Outbuf .=
"<th>$text</th>";
220 $RowStyle1 =
"style='background-color:lavender'";
221 $RowStyle2 =
"style='background-color:lightyellow'";
225 foreach ($acme_project_array as $project) {
230 $RowStyle = (($RowNum ++ % (2 * $ColorSpanRows)) < $ColorSpanRows) ? $RowStyle1 : $RowStyle2;
232 $Outbuf .=
"<tr $RowStyle>";
233 $Checked = $project[
'include'] ==
't' ?
"checked=\"checked\"" :
'';
234 $Outbuf .=
"<td><input type='checkbox' name='includeproj[$project[acme_project_pk]]' $Checked></td>\n";
235 $Outbuf .=
"<td>$project[project_name]</td>";
237 "&acme_project=$project[acme_project_pk]&upload=$upload_pk";
238 $Outbuf .=
"<td><a href='$ProjectListURL'>$project[count]</a></td>";
239 $Outbuf .=
"<td><a href='$project[url]'>$project[url]</a></td>";
240 $Outbuf .=
"<td>" . htmlentities($project[
'description']) .
"</td>";
241 $Outbuf .=
"<td>$project[licenses]</td>";
242 $Outbuf .=
"<td>$project[version]</td>";
245 $Outbuf .=
"</table>";
247 $Outbuf .=
"$RowNum rows found<br>";
249 $text = _(
"Save and Generate SPDX file");
250 $Outbuf .=
"<p><input type='submit' value='$text' name='spdxbtn'>\n";
252 $Outbuf .=
" <input type='submit' value='$text' name='savebtn'>\n";
253 $Outbuf .=
"</form>\n";
271 foreach ($acme_project_array as $project) {
272 $sql =
"insert into acme_upload (upload_fk, acme_project_fk, include, detail, count) values ($upload_pk, $project[acme_project_pk], true, $detail, $project[count])";
273 $result = pg_query($PG_CONN, $sql);
275 pg_free_result($result);
289 $spdx =
'<?xml version="1.0" encoding="UTF-8" ?>' .
"\n";
290 $spdx .=
'<rdf:RDF' .
"\n";
291 $spdx .=
' xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"' .
"\n";
292 $spdx .=
' xmlns="http://spdx.org/rdf/terms#"' .
"\n";
293 $spdx .=
' xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">' .
"\n";
294 $spdx .=
' <SpdxDocument rdf:about="http://www.spdx.org/tools#SPDXANALYSIS">' .
"\n";
295 $spdx .=
' <specVersion>SPDX-1.1</specVersion>' .
"\n";
296 $spdx .=
' <dataLicense rdf:about="http://spdx.org/licenses/PDDL-1.0" />' .
"\n";
297 $spdx .=
' <CreationInfo>' .
"\n";
298 $spdx .=
" <creator>Tool: FOSSology v " . $SysConf[
'BUILD'][
'VERSION']
299 .
" svn " . $SysConf[
'BUILD'][
'COMMIT_HASH'] .
"</creator>\n";
300 $spdx .=
"<created>" . date(
'c') .
"</created>\n";
301 $spdx .=
'</CreationInfo>' .
"\n";
303 $in_encoding = iconv_get_encoding(
"input_encoding");
304 foreach ($acme_project_array as $project) {
306 $spdx .=
"<Package>\n";
307 $spdx .=
'<name>' . str_replace(
"&",
" and ", strip_tags($project[
'project_name'])) .
'</name>' .
"\n";
308 $spdx .=
"<versionInfo>$project[version]</versionInfo>\n";
309 $spdx .=
"<licenseDeclared>$project[licenses]</licenseDeclared>\n";
310 $spdx .=
"<sourceInfo>ProjectURL: $project[url]</sourceInfo>\n";
311 $spdx .=
'<description>' . str_replace(
"&",
" and ",
312 strip_tags($project[
'description'])) .
'</description>' .
"\n";
313 $spdx .=
"</Package>\n";
329 $spdx .=
" </SpdxDocument> </rdf:RDF>\n";
347 $detail = empty($detail) ? 0 : 1;
353 if (empty($agent_pk)) {
354 echo
"Missing fossology license data. Run a license scan on this upload.<br>";
360 $acme_uploadRec =
GetSingleRec(
"acme_upload",
"where upload_fk=$upload_pk ");
361 if (empty($acme_uploadRec)) {
373 $sql =
"select * from acme_upload, acme_project " 374 .
"where acme_project_pk=acme_project_fk and detail=$detail and upload_fk=$upload_pk";
375 $result = pg_query($PG_CONN, $sql);
377 $acme_project_array = pg_fetch_all($result);
378 $acme_project_array_orig = $acme_project_array;
381 if (!empty($savebtn) or !empty($spdxbtn)) {
383 foreach ($acme_project_array as &$project) {
384 $project[
'include'] =
'f';
387 if (array_key_exists(
'includeproj', $_POST)) {
388 $includeArray = $_POST[
'includeproj'];
389 foreach ($acme_project_array as &$project) {
390 if (array_key_exists($project[
'acme_project_fk'], $includeArray)) {
391 $project[
'include'] =
"t";
397 $NumRecs = count($acme_project_array);
398 for ($i = 0; $i < $NumRecs; $i ++) {
399 $project = $acme_project_array[$i];
400 $project_orig = $acme_project_array_orig[$i];
401 if ($project[
'include'] != $project_orig[
'include']) {
402 $include = $project[
'include'] ?
"true" :
"false";
403 $sql =
"update acme_upload set include='$include' where acme_upload_pk='$project[acme_upload_pk]'";
404 $result = pg_query($PG_CONN, $sql);
406 pg_free_result($result);
413 foreach ($acme_project_array as &$project) {
414 $sql =
"select uploadtree_pk from acme_pfile, uploadtree where acme_project_fk=$project[acme_project_fk] 415 and acme_pfile.pfile_fk=uploadtree.pfile_fk and uploadtree.upload_fk=$upload_pk";
416 $result = pg_query($PG_CONN, $sql);
419 $ItemLicArray = array();
420 while ($acme_pfileRow = pg_fetch_assoc($result)) {
422 $acme_pfileRow[
'uploadtree_pk'], $uploadtree_tablename);
423 foreach ($LicArray as $key => $license) {
424 $ItemLicArray[$key] = $license;
427 $project[
'licenses'] =
'';
428 foreach ($ItemLicArray as $license) {
429 if ($license ==
"No_license_found") {
432 if (! empty($project[
'licenses'])) {
433 $project[
'licenses'] .=
", ";
435 $project[
'licenses'] .= $license;
441 usort($acme_project_array,
'proj_cmp');
444 if (! empty($spdxbtn)) {
452 switch ($this->OutputType) {
458 $V .= $this->
HTMLForm($acme_project_array, $upload_pk);
465 if (! $this->OutputToStdout) {
475 $NewPlugin->Initialize();
FUNCTION char * GetUploadtreeTableName(PGconn *pgConn, int upload_pk)
Get the uploadtree table name for this upload_pk If upload_pk does not exist, return "uploadtree"...
Output()
Display the loaded menu and plugins.
Dir2Browse($Mod, $UploadtreePk, $LinkLast=NULL, $ShowBox=1, $ShowMicro=NULL, $Enumerate=-1, $PreText='', $PostText='', $uploadtree_tablename="uploadtree")
Get an html linked string of a file browse path.
Traceback_uri()
Get the URI without query to this location.
DownloadString2File($text, $name, $contentType)
Send a string to a user as a download file.
FindACMEProjects($uploadtreeRow, &$acme_project_array)
Find all the acme projects in a hierarchy, starting with $uploadtree_pk. Once you get an acme hit...
GetSingleRec($Table, $Where="")
Retrieve a single database record.
Populate_acme_upload($acme_project_array, $upload_pk, $detail)
Populate the acme_upload table for this upload.
#define PLUGIN_DB_READ
Plugin requires read permission on DB.
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
LatestAgentpk($upload_pk, $arsTableName, $arsSuccess=false)
Given an upload_pk, find the latest enabled agent_pk with results.
GetProjectArray1($upload_pk, $nomosAgentpk, $MinCount=1)
Given an upload , return all the unique projects found.
HTMLForm($acme_project_array, $upload_pk)
create the HTML to display the form showing the found projects
This is the Plugin class. All plugins should:
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN
OutputOpen()
This function is called when user output is requested. This function is responsible for assigning hea...
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
Traceback_parm_keep($List)
Create a new URI, keeping only these items.
GetFileLicenses($agent, $pfile_pk, $uploadtree_pk, $uploadtree_tablename='uploadtree', $duplicate="")
get all the licenses for a single file or uploadtree
GenerateSPDX($acme_project_array)
Write and return the SPDX file as a string.
GetProjectArray0($upload_pk, $nomosAgentpk, $MinCount=1)
Given an upload , return all the unique projects found.
RegisterMenus()
Customize submenus.