FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
ajax-filebucket.php
Go to the documentation of this file.
1 <?php
2 /***********************************************************
3  Copyright (C) 2010-2011 Hewlett-Packard Development Company, L.P.
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License
7  version 2 as published by the Free Software Foundation.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License along
15  with this program; if not, write to the Free Software Foundation, Inc.,
16  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 ***********************************************************/
18 
32 define("TITLE_ajax_filebucket", _("List Uploads as Options"));
33 
35 {
36  function __construct()
37  {
38  $this->Name = "ajax_filebucket";
39  $this->Title = TITLE_ajax_filebucket;
40  $this->DBaccess = PLUGIN_DB_READ;
41  $this->LoginFlag = 0;
42  parent::__construct();
43  }
44 
51  function Output()
52  {
53  global $PG_CONN;
54 
55  if ($this->State != PLUGIN_STATE_READY) {
56  return;
57  }
58  if (!$PG_CONN) {
59  return "NO DB connection";
60  }
61 
62  $bucket_pk = GetParm("bucket_pk",PARM_RAW);
63  $uploadtree_pk = GetParm("item",PARM_INTEGER);
64 
65  /* Get the uploadtree table name */
66  $uploadtree_rec = GetSingleRec("uploadtree", "where uploadtree_pk='$uploadtree_pk'");
67  $uploadtree_tablename = GetUploadtreeTableName($uploadtree_rec['upload_fk']);
68 
69  /* Get all the non-artifact children */
70  $children = GetNonArtifactChildren($uploadtree_pk, $uploadtree_tablename);
71 
72  /* Loop through children and create a list of those that contain $bucket_pk */
73  $outstr = $bucket_pk;
74  foreach ($children as $child)
75  {
76  if (BucketInTree($bucket_pk, $child['uploadtree_pk']))
77  {
78  $outstr .= ",$child[uploadtree_pk]";
79  }
80  }
81 
82  return $outstr;
83  }
84 
85 }
86 $NewPlugin = new ajax_filebucket;
87 $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"...
Definition: libfossagent.c:421
const PARM_RAW
Definition: common-parm.php:33
Output()
Display the loaded menu and plugins.
GetSingleRec($Table, $Where="")
Retrieve a single database record.
Definition: common-db.php:102
#define PLUGIN_DB_READ
Plugin requires read permission on DB.
Definition: libfossology.h:49
Definition: state.hpp:26
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
Definition: common-parm.php:57
const PARM_INTEGER
Definition: common-parm.php:25
BucketInTree($bucket_pk, $uploadtree_pk)
Check if a bucket_pk is found in a tree for a given nomos and bucket agent.
This is the Plugin class. All plugins should:
Definition: FO_Plugin.php:67
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN