FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
ajax-manage-tag.php
1 <?php
2 /***********************************************************
3  Copyright (C) 2012-2013 Hewlett-Packard Development Company, L.P.
4  Copyright (C) 2015 Siemens AG
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License
8  version 2 as published by the Free Software Foundation.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 ***********************************************************/
19 
21 
22 define("TITLE_UPLOAD_TAGGING", _("Manage Upload Tagging"));
23 
25 {
26  var $Name = "upload_tagging";
27  var $Title = TITLE_UPLOAD_TAGGING;
28  var $Version = "1.0";
29  var $Dependency = array();
30  var $DBaccess = PLUGIN_DB_ADMIN;
31  var $NoHTML = 1; /* This plugin needs no HTML content help */
32 
36  function Output()
37  {
38  $upload_id = GetParm("upload",PARM_INTEGER);
39  if (empty($upload_id)) {
40  return new Response('', Response::HTTP_OK,array('content-type'=>'text/plain'));
41  }
42 
44  $sql = "select count(*) from tag_manage where upload_fk = $1 and is_disabled = true";
45  $numTags = $GLOBALS['container']->get('db.manager')->getSingleRow($sql,array($upload_id));
46  $count = $numTags['count'];
47  if (empty($count)) { // enabled
48  $text = _("Disable");
49  $V = "<input type='submit' name='manage' value='$text'>\n";
50  } else { // disabled
51  $text = _("Enable");
52  $V = "<input type='submit' name='manage' value='$text'>\n";
53  }
54 
55  return new Response($V, Response::HTTP_OK,array('content-type'=>'text/plain'));
56  }
57 }
58 
59 $NewPlugin = new upload_tagging;
60 $NewPlugin->Initialize();
#define PLUGIN_DB_ADMIN
Plugin requires admin level permission on DB.
Definition: libfossology.h:51
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
This is the Plugin class. All plugins should:
Definition: FO_Plugin.php:67
Output()
Display the loaded menu and plugins.