FOSSology  4.4.0
Open Source License Compliance by Open Source Software
common-license-file.php File Reference

This file contains common functions for the license_file and license_ref tables. More...

Go to the source code of this file.

Functions

 GetFileLicenses ($agent, $pfile_pk, $uploadtree_pk, $uploadtree_tablename='uploadtree', $duplicate="")
 get all the licenses for a single file or uploadtree More...
 
 GetFileLicenses_string ($agent_pk, $pfile_pk, $uploadtree_pk, $uploadtree_tablename='uploadtree')
 Same as GetFileLicenses() but returns license list as a single string. More...
 
 GetFilesWithLicense ($agent_pk, $rf_shortname, $uploadtree_pk, $PkgsOnly=false, $offset=0, $limit="ALL", $order="", $tag_pk=null, $uploadtree_tablename="uploadtree")
 Get files with a given license (shortname). More...
 
 Level1WithLicense ($agent_pk, $rf_shortname, $uploadtree_pk, $PkgsOnly=false, $uploadtree_tablename="uploadtree")
 Given an uploadtree_pk, find all the non-artifact, immediate children (uploadtree_pk's) that have license $rf_shortname. More...
 
 FileListLinks ($upload_fk, $uploadtree_pk, $napk, $pfile_pk, $Recurse=True, &$UniqueTagArray=array(), $uploadtree_tablename="uploadtree", $wantTags=true)
 Get list of links: [View][Info][Download] More...
 

Detailed Description

This file contains common functions for the license_file and license_ref tables.

Definition in file common-license-file.php.

Function Documentation

◆ FileListLinks()

FileListLinks (   $upload_fk,
  $uploadtree_pk,
  $napk,
  $pfile_pk,
  $Recurse = True,
$UniqueTagArray = array(),
  $uploadtree_tablename = "uploadtree",
  $wantTags = true 
)

Get list of links: [View][Info][Download]

Parameters
int$upload_fkUpload id
int$uploadtree_pkUploadtree id
int$napkNomos agent pk
int$pfile_pk
bool$Recursetrue if links should propapagate recursion. Currently, this means that the displayed tags will be displayed for directory contents.
array&$UniqueTagArrayCumulative array of unique tags
string$uploadtree_tablename
bool$wantTags

If true add [Tag] ...

For example:

Array
  (
    [0] => Array
      (
          [tag_pk] => 5
          [tag_name] => GPL false positive
      )
  )
Returns
String containing the links [View][Info][Download][Tag {tags}]

Definition at line 273 of file common-license-file.php.

◆ GetFileLicenses()

GetFileLicenses (   $agent,
  $pfile_pk,
  $uploadtree_pk,
  $uploadtree_tablename = 'uploadtree',
  $duplicate = "" 
)

get all the licenses for a single file or uploadtree

Parameters
int$agent_pkAgent id
int$pfile_pkPfile id, (if empty, $uploadtree_pk must be given)
int$uploadtree_pk(used only if $pfile_pk is empty)
string$uploadtree_tablenameUpload tree table to use
bool$duplicateGet duplicated licenses or not, if NULL: No, or Yes
Returns
Array of file licenses
LicArray[fl_pk] = rf_shortname if $duplicate is Not NULL
LicArray[rf_pk] = rf_shortname if $duplicate is NULL
FATAL if neither pfile_pk or uploadtree_pk were passed in

Definition at line 30 of file common-license-file.php.

◆ GetFileLicenses_string()

GetFileLicenses_string (   $agent_pk,
  $pfile_pk,
  $uploadtree_pk,
  $uploadtree_tablename = 'uploadtree' 
)

Same as GetFileLicenses() but returns license list as a single string.

Parameters
int$agent_pkAgent id
int$pfile_pkPfile id, (if empty, $uploadtree_pk must be given)
int$uploadtree_pk(used only if $pfile_pk is empty)
string$uploadtree_tablename
Returns
Licenses string for specified file
See also
GetFileLicenses()

Definition at line 98 of file common-license-file.php.

◆ GetFilesWithLicense()

GetFilesWithLicense (   $agent_pk,
  $rf_shortname,
  $uploadtree_pk,
  $PkgsOnly = false,
  $offset = 0,
  $limit = "ALL",
  $order = "",
  $tag_pk = null,
  $uploadtree_tablename = "uploadtree" 
)

Get files with a given license (shortname).

Parameters
int$agent_pkAgent id
string$rf_shortnameShort name of one license, like GPL, APSL, MIT, ...
int$uploadtree_pkSets scope of request
bool$PkgsOnlyIf true, only list packages, default is false (all files are listed). For now, $PkgsOnly is not yet implemented.
int$offsetSelect offset, default is 0
string$limitSelect limit (num rows returned), default is no limit
string$orderSQL order by clause, default is blank e.g. "order by ufile_name asc"
int$tag_pkOptional tag_pk. Restrict results to files that have this tag.
string$uploadtree_tablename
Returns
pg_query result. See $sql for fields returned.
Note
Caller should use pg_free_result to free.

Definition at line 124 of file common-license-file.php.

◆ Level1WithLicense()

Level1WithLicense (   $agent_pk,
  $rf_shortname,
  $uploadtree_pk,
  $PkgsOnly = false,
  $uploadtree_tablename = "uploadtree" 
)

Given an uploadtree_pk, find all the non-artifact, immediate children (uploadtree_pk's) that have license $rf_shortname.

By "immediate" I mean the earliest direct non-artifact.

For example:
A > B, C (A has children B and C)
If C is an artifact, descend that tree till you find the first non-artifact and consider that non-artifact an immediate child.

Parameters
int$agent_pkAgent id
string$rf_shortnameShort name of one license, like GPL, APSL, MIT, ...
int$uploadtree_pkSets scope of request
bool$PkgsOnlyIf true, only list packages, default is false (all files are listed). $PkgsOnly is not yet implemented.
string$uploadtree_tablename
Returns
Array of uploadtree_pk ==> ufile_name

Definition at line 215 of file common-license-file.php.