30 function GetFileLicenses($agent, $pfile_pk, $uploadtree_pk, $uploadtree_tablename=
'uploadtree', $duplicate=
"")
35 Fatal(
"Missing parameter: agent", __FILE__, __LINE__);
40 $sql =
"SELECT lft, rgt, upload_fk FROM $uploadtree_tablename
41 WHERE uploadtree_pk = $uploadtree_pk";
44 $row = pg_fetch_assoc($result);
47 $upload_pk = $row[
"upload_fk"];
48 pg_free_result($result);
50 $agentIdCondition = $agent !=
"any" ?
"and agent_fk=$agent" :
"";
53 if (($uploadtree_tablename ==
"uploadtree_a") ||
54 ($uploadtree_tablename ==
"uploadtree")) {
55 $UploadClause =
"upload_fk=$upload_pk and ";
61 $sql =
"SELECT distinct(rf_shortname) as rf_shortname, rf_pk as rf_fk, fl_pk
62 from license_file_ref,
63 (SELECT distinct(pfile_fk) as PF from $uploadtree_tablename
64 where $UploadClause lft BETWEEN $lft and $rgt) as SS
65 where PF=pfile_fk $agentIdCondition
66 order by rf_shortname asc";
70 Fatal(
"Missing function inputs", __FILE__, __LINE__);
76 while ($row = pg_fetch_assoc($result)) {
77 $LicArray[$row[
'fl_pk']] = $row[
'rf_shortname'];
80 while ($row = pg_fetch_assoc($result)) {
81 $LicArray[$row[
'rf_fk']] = $row[
'rf_shortname'];
84 pg_free_result($result);
101 $LicArray =
GetFileLicenses($agent_pk, $pfile_pk, $uploadtree_pk, $uploadtree_tablename);
102 return implode(
', ', $LicArray);
125 $PkgsOnly=
false, $offset=0, $limit=
"ALL",
126 $order=
"", $tag_pk=
null, $uploadtree_tablename=
"uploadtree")
131 $sql =
"SELECT lft, rgt, upload_fk FROM $uploadtree_tablename WHERE uploadtree_pk = $uploadtree_pk";
134 $row = pg_fetch_assoc($result);
137 $upload_pk = $row[
"upload_fk"];
138 pg_free_result($result);
141 $pg_shortname = pg_escape_string($rf_shortname);
142 $sql =
"SELECT rf_pk FROM license_ref WHERE rf_shortname='$pg_shortname'";
145 $row = pg_fetch_assoc($result);
146 $rf_pk = $row[
"rf_pk"];
147 while ($row = pg_fetch_assoc($result)) {
148 $rf_pk .=
"," . $row[
"rf_pk"];
150 pg_free_result($result);
157 if (empty($tag_pk)) {
161 $TagTable =
"tag_file,";
162 $TagClause =
"and PF=tag_file.pfile_fk and tag_fk=$tag_pk";
165 $agentCondition =
'';
166 if (is_array($agent_pk)) {
167 $agentCondition =
' AND agent_fk IN (' . implode(
',', $agent_pk) .
')';
168 }
else if ($agent_pk !=
"any") {
169 $agentCondition =
"and agent_fk=$agent_pk";
173 if (($uploadtree_tablename ==
"uploadtree_a") || ($uploadtree_tablename ==
"uploadtree")) {
174 $UploadClause =
"upload_fk=$upload_pk and ";
178 $theLimit = ($limit==
'ALL') ?
'' :
"LIMIT $limit";
179 $sql =
"select uploadtree_pk, license_file.pfile_fk, ufile_name, agent_name, max(agent_pk) agent_pk
180 from license_file, agent, $TagTable
181 (SELECT pfile_fk as PF, uploadtree_pk, ufile_name from $uploadtree_tablename
183 lft BETWEEN $lft and $rgt
184 and ufile_mode & (3<<28) = 0 ) as SS
185 where PF=license_file.pfile_fk $agentCondition and rf_fk in ($rf_pk)
186 AND agent_pk=agent_fk
188 GROUP BY uploadtree_pk, license_file.pfile_fk, ufile_name, agent_name
189 $order $theLimit offset $offset";
215 function Level1WithLicense($agent_pk, $rf_shortname, $uploadtree_pk, $PkgsOnly=
false, $uploadtree_tablename=
"uploadtree")
219 $Children = GetNonArtifactChildren($uploadtree_pk, $uploadtree_tablename);
227 foreach ($Children as $row) {
230 $PkgsOnly, $offset, $limit, $order, $tag_pk, $uploadtree_tablename);
234 if (pg_num_rows($result) > 0) {
235 $pkarray[$row[
'uploadtree_pk']] = $row[
'ufile_name'];
239 pg_free_result($result);
273 function FileListLinks($upload_fk, $uploadtree_pk, $napk, $pfile_pk, $Recurse=True, &$UniqueTagArray = array(), $uploadtree_tablename =
"uploadtree", $wantTags=
true)
281 $text2 = _(
"Download");
283 $LinkStr .=
"[<a href='" .
Traceback_uri() .
"?mod=view-license&upload=$upload_fk&item=$uploadtree_pk&napk=$napk' >$text</a>]";
284 $LinkStr .=
"[<a href='" .
Traceback_uri() .
"?mod=view_info&upload=$upload_fk&item=$uploadtree_pk&show=detail' >$text1</a>]";
285 if ($_SESSION[
'UserLevel'] >= $SysConf[
'SYSCONFIG'][
'SourceCodeDownloadRights']) {
286 $LinkStr .=
"[<a href='" .
Traceback_uri() .
"?mod=download&upload=$upload_fk&item=$uploadtree_pk' >$text2</a>]";
292 if ($wantTags && TagStatus($upload_fk)) {
293 $TagArray =
GetAllTags($uploadtree_pk, $Recurse, $uploadtree_tablename);
295 foreach ($TagArray as $TagPair) {
297 if (! empty($TagStr)) {
300 $TagStr .=
" " . $TagPair[
'tag_name'];
304 foreach ($UniqueTagArray as $UTA_key => $UTA_row) {
305 if ($TagPair[
'tag_pk'] == $UTA_row[
'tag_pk']) {
311 $UniqueTagArray[] = $TagPair;
316 $LinkStr .=
"[<a href='" .
Traceback_uri() .
"?mod=tag&upload=$upload_fk&item=$uploadtree_pk' >$text3</a>";
318 $LinkStr .=
"<span style='color:#2897B7'>";
320 $LinkStr .=
"</span>";
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
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).
FileListLinks($upload_fk, $uploadtree_pk, $napk, $pfile_pk, $Recurse=True, &$UniqueTagArray=array(), $uploadtree_tablename="uploadtree", $wantTags=true)
Get list of links: [View][Info][Download]
GetFileLicenses_string($agent_pk, $pfile_pk, $uploadtree_pk, $uploadtree_tablename='uploadtree')
Same as GetFileLicenses() but returns license list as a single string.
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 lic...
GetFileLicenses($agent, $pfile_pk, $uploadtree_pk, $uploadtree_tablename='uploadtree', $duplicate="")
get all the licenses for a single file or uploadtree
Traceback_uri()
Get the URI without query to this location.
Fatal($msg, $filenm, $lineno)
Write message to stdout and die.
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN