FOSSology  4.4.0
Open Source License Compliance by Open Source Software
ajax-filebucket.php
Go to the documentation of this file.
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2010-2011 Hewlett-Packard Development Company, L.P.
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
21 define("TITLE_ajax_filebucket", _("List Uploads as Options"));
22 
24 {
25  function __construct()
26  {
27  $this->Name = "ajax_filebucket";
28  $this->Title = TITLE_ajax_filebucket;
29  $this->DBaccess = PLUGIN_DB_READ;
30  $this->LoginFlag = 0;
31  parent::__construct();
32  }
33 
40  function Output()
41  {
42  global $PG_CONN;
43 
44  if ($this->State != PLUGIN_STATE_READY) {
45  return;
46  }
47  if (!$PG_CONN) {
48  return "NO DB connection";
49  }
50 
51  $bucket_pk = GetParm("bucket_pk",PARM_RAW);
52  $uploadtree_pk = GetParm("item",PARM_INTEGER);
53 
54  /* Get the uploadtree table name */
55  $uploadtree_rec = GetSingleRec("uploadtree", "where uploadtree_pk='$uploadtree_pk'");
56  $uploadtree_tablename = GetUploadtreeTableName($uploadtree_rec['upload_fk']);
57 
58  /* Get all the non-artifact children */
59  $children = GetNonArtifactChildren($uploadtree_pk, $uploadtree_tablename);
60 
61  /* Loop through children and create a list of those that contain $bucket_pk */
62  $outstr = $bucket_pk;
63  foreach ($children as $child)
64  {
65  if (BucketInTree($bucket_pk, $child['uploadtree_pk']))
66  {
67  $outstr .= ",$child[uploadtree_pk]";
68  }
69  }
70 
71  return $outstr;
72  }
73 
74 }
75 $NewPlugin = new ajax_filebucket;
76 $NewPlugin->Initialize();
This is the Plugin class. All plugins should:
Definition: FO_Plugin.php:57
Definition: state.hpp:16
Output()
Display the loaded menu and plugins.
__construct()
base constructor. Most plugins will just use this
BucketInTree($bucket_pk, $uploadtree_pk)
Check if a bucket_pk is found in a tree for a given nomos and bucket agent.
GetSingleRec($Table, $Where="")
Retrieve a single database record.
Definition: common-db.php:91
const PARM_INTEGER
Definition: common-parm.php:14
const PARM_RAW
Definition: common-parm.php:22
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
Definition: common-parm.php:46
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".
Definition: libfossagent.c:414
#define PLUGIN_DB_READ
Plugin requires read permission on DB.
Definition: libfossology.h:37
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN