41 function GetFileLicenses($agent, $pfile_pk, $uploadtree_pk, $uploadtree_tablename=
'uploadtree', $duplicate=
"")
46 Fatal(
"Missing parameter: agent", __FILE__, __LINE__);
51 $sql =
"SELECT lft, rgt, upload_fk FROM $uploadtree_tablename 52 WHERE uploadtree_pk = $uploadtree_pk";
53 $result = pg_query($PG_CONN, $sql);
55 $row = pg_fetch_assoc($result);
58 $upload_pk = $row[
"upload_fk"];
59 pg_free_result($result);
61 $agentIdCondition = $agent !=
"any" ?
"and agent_fk=$agent" :
"";
64 if (($uploadtree_tablename ==
"uploadtree_a") ||
65 ($uploadtree_tablename ==
"uploadtree")) {
66 $UploadClause =
"upload_fk=$upload_pk and ";
72 $sql =
"SELECT distinct(rf_shortname) as rf_shortname, rf_pk as rf_fk, fl_pk 73 from license_file_ref, 74 (SELECT distinct(pfile_fk) as PF from $uploadtree_tablename 75 where $UploadClause lft BETWEEN $lft and $rgt) as SS 76 where PF=pfile_fk $agentIdCondition 77 order by rf_shortname asc";
78 $result = pg_query($PG_CONN, $sql);
81 Fatal(
"Missing function inputs", __FILE__, __LINE__);
87 while ($row = pg_fetch_assoc($result)) {
88 $LicArray[$row[
'fl_pk']] = $row[
'rf_shortname'];
91 while ($row = pg_fetch_assoc($result)) {
92 $LicArray[$row[
'rf_fk']] = $row[
'rf_shortname'];
95 pg_free_result($result);
112 $LicArray =
GetFileLicenses($agent_pk, $pfile_pk, $uploadtree_pk, $uploadtree_tablename);
113 return implode($LicArray,
', ');
136 $PkgsOnly=
false, $offset=0, $limit=
"ALL",
137 $order=
"", $tag_pk=null, $uploadtree_tablename)
142 $sql =
"SELECT lft, rgt, upload_fk FROM $uploadtree_tablename WHERE uploadtree_pk = $uploadtree_pk";
143 $result = pg_query($PG_CONN, $sql);
145 $row = pg_fetch_assoc($result);
148 $upload_pk = $row[
"upload_fk"];
149 pg_free_result($result);
152 $sql =
"SELECT rf_pk FROM license_ref WHERE rf_shortname='$rf_shortname'";
153 $result = pg_query($PG_CONN, $sql);
155 $row = pg_fetch_assoc($result);
156 $rf_pk = $row[
"rf_pk"];
157 while ($row = pg_fetch_assoc($result)) {
158 $rf_pk .=
"," . $row[
"rf_pk"];
160 pg_free_result($result);
166 $shortname = pg_escape_string($rf_shortname);
169 if (empty($tag_pk)) {
173 $TagTable =
"tag_file,";
174 $TagClause =
"and PF=tag_file.pfile_fk and tag_fk=$tag_pk";
177 $agentCondition =
'';
178 if (is_array($agent_pk)) {
179 $agentCondition =
' AND agent_fk IN (' . implode(
',', $agent_pk) .
')';
180 }
else if ($agent_pk !=
"any") {
181 $agentCondition =
"and agent_fk=$agent_pk";
185 if (($uploadtree_tablename ==
"uploadtree_a") || ($uploadtree_tablename ==
"uploadtree")) {
186 $UploadClause =
"upload_fk=$upload_pk and ";
190 $theLimit = ($limit==
'ALL') ?
'' :
"LIMIT $limit";
191 $sql =
"select uploadtree_pk, license_file.pfile_fk, ufile_name, agent_name, max(agent_pk) agent_pk 192 from license_file, agent, $TagTable 193 (SELECT pfile_fk as PF, uploadtree_pk, ufile_name from $uploadtree_tablename 195 lft BETWEEN $lft and $rgt 196 and ufile_mode & (3<<28) = 0 ) as SS 197 where PF=license_file.pfile_fk $agentCondition and rf_fk in ($rf_pk) 198 AND agent_pk=agent_fk 200 GROUP BY uploadtree_pk, license_file.pfile_fk, ufile_name, agent_name 201 $order $theLimit offset $offset";
202 $result = pg_query($PG_CONN, $sql);
227 function Level1WithLicense($agent_pk, $rf_shortname, $uploadtree_pk, $PkgsOnly=
false, $uploadtree_tablename)
231 $Children = GetNonArtifactChildren($uploadtree_pk, $uploadtree_tablename);
239 foreach ($Children as $row) {
242 $PkgsOnly, $offset, $limit, $order, $tag_pk, $uploadtree_tablename);
246 if (pg_num_rows($result) > 0) {
247 $pkarray[$row[
'uploadtree_pk']] = $row[
'ufile_name'];
251 pg_free_result($result);
285 function FileListLinks($upload_fk, $uploadtree_pk, $napk, $pfile_pk, $Recurse=True, &$UniqueTagArray = array(), $uploadtree_tablename =
"uploadtree", $wantTags=
true)
293 $text2 = _(
"Download");
295 $LinkStr .=
"[<a href='" .
Traceback_uri() .
"?mod=view-license&upload=$upload_fk&item=$uploadtree_pk&napk=$napk' >$text</a>]";
296 $LinkStr .=
"[<a href='" .
Traceback_uri() .
"?mod=view_info&upload=$upload_fk&item=$uploadtree_pk&show=detail' >$text1</a>]";
297 if ($_SESSION[
'UserLevel'] >= $SysConf[
'SYSCONFIG'][
'SourceCodeDownloadRights']) {
298 $LinkStr .=
"[<a href='" .
Traceback_uri() .
"?mod=download&upload=$upload_fk&item=$uploadtree_pk' >$text2</a>]";
304 if ($wantTags && TagStatus($upload_fk)) {
305 $TagArray =
GetAllTags($uploadtree_pk, $Recurse, $uploadtree_tablename);
307 foreach ($TagArray as $TagPair) {
309 if (! empty($TagStr)) {
312 $TagStr .=
" " . $TagPair[
'tag_name'];
316 foreach ($UniqueTagArray as $UTA_key => $UTA_row) {
317 if ($TagPair[
'tag_pk'] == $UTA_row[
'tag_pk']) {
323 $UniqueTagArray[] = $TagPair;
328 $LinkStr .=
"[<a href='" .
Traceback_uri() .
"?mod=tag&upload=$upload_fk&item=$uploadtree_pk' >$text3</a>";
330 $LinkStr .=
"<span style='color:#2897B7'>";
332 $LinkStr .=
"</span>";
Traceback_uri()
Get the URI without query to this location.
GetFileLicenses_string($agent_pk, $pfile_pk, $uploadtree_pk, $uploadtree_tablename='uploadtree')
Same as GetFileLicenses() but returns license list as a single string.
FileListLinks($upload_fk, $uploadtree_pk, $napk, $pfile_pk, $Recurse=True, &$UniqueTagArray=array(), $uploadtree_tablename="uploadtree", $wantTags=true)
Get list of links: [View][Info][Download]
Level1WithLicense($agent_pk, $rf_shortname, $uploadtree_pk, $PkgsOnly=false, $uploadtree_tablename)
Given an uploadtree_pk, find all the non-artifact, immediate children (uploadtree_pk's) that have lic...
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
GetFileLicenses($agent, $pfile_pk, $uploadtree_pk, $uploadtree_tablename='uploadtree', $duplicate="")
get all the licenses for a single file or uploadtree
Fatal($msg, $filenm, $lineno)
Write message to stdout and die.
GetFilesWithLicense($agent_pk, $rf_shortname, $uploadtree_pk, $PkgsOnly=false, $offset=0, $limit="ALL", $order="", $tag_pk=null, $uploadtree_tablename)
Get files with a given license (shortname).