3 /**************************************************************************
4 ** (c) Copyright 2003, Andromeda Technology & Automation
5 ** This is free software; you can redistribute it and/or modify it under the
6 ** terms of the GNU General Public License, see the file COPYING.
7 ***************************************************************************
8 ** MODULE INFORMATION *
9 ***********************
10 ** FILE NAME : classes.php
11 ** SYSTEM NAME : Gnucomo - Gnu Computer Monitoring
12 ** VERSION NUMBER : $Revision: 1.1 $
14 ** DESCRIPTION : Parameter classes Administration page.
15 ** Input parameters: action (POST) : empty, 'Create'
16 ** classname (POST) : short name of the class to create or remove
21 ***************************************************************************
22 ** ADMINISTRATIVE INFORMATION *
23 ********************************
24 ** ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
25 ** CREATION DATE : Aug 04, 2003
26 ** LAST UPDATE : Aug 28, 2003
28 **************************************************************************/
30 /*****************************
32 Revision 1.1 2005-06-04 07:22:40 arjen
33 New page: Parameter classes administration.
36 ******************************/
38 // RCSID = "$Id: classes.php,v 1.1 2005-06-04 07:22:40 arjen Exp $";
40 ini_set('include_path', '.:./classes:../phpclasses');
42 require_once('page.class.php');
44 function clientscripts()
49 <script language='JavaScript'>
51 function CheckCreate(f)
53 if (f.classname.value == "")
55 alert("You must supply a class name");
59 if (f.propname.value == "")
61 alert("You must supply a property name");
67 function CheckRemove(f)
69 var message = "Are you sure you want to remove property ";
70 message += f.propname.value;
71 message += " of class ";
72 message += f.classname.value;
75 return confirm(message);
83 class class_page extends page
91 if (isset($_POST['action']) && $_POST['action'] == 'Create'
92 && !empty($_POST['classname']) && !empty($_POST['propname']))
94 pg_exec($this->database, "INSERT INTO parameter_class
95 (name, property_name, property_type, notify) VALUES ('"
96 . $_POST['classname'] . "','" . $_POST['propname'] . "','STATIC', 'true')");
99 if (isset($_POST['action']) && $_POST['action'] == 'Remove'
100 && !empty($_POST['classname']) && !empty($_POST['propname']))
102 pg_exec($this->database, "DELETE FROM parameter_class WHERE name='"
103 . $_POST['classname'] . "' AND property_name='" . $_POST['propname'] . "'");
106 if (isset($_GET['classname']) && isset($_GET['propname']))
108 echo "<h1>Detailed information for property " . $_GET['propname']
109 . " of class " . $_GET['classname'] . "</h1><br>\n";
111 if (isset($_POST['action']) && $_POST['action'] == 'Save Changes')
114 if (!empty($_POST['notify']) && $_POST['notify'] == 'on')
118 $qry = "UPDATE parameter_class SET description='" . $_POST['description'] . "'";
119 $qry .= ", property_type='" . $_POST['proptype'] . "'";
120 $qry .= ", notify='" . $notify . "'";
121 if (isset($_POST['min']))
123 $qry .= ", min='" . $_POST['min'] . "'";
125 if (isset($_POST['max']))
127 $qry .= ", max='" . $_POST['max'] . "'";
129 $qry .= " WHERE name='" . $_GET['classname'] . "'";
130 $qry .= " AND property_name='" . $_GET['propname'] . "'";
133 pg_exec($this->database, $qry);
134 echo pg_errormessage($this->database) . "<br>";
138 $res = pg_exec($this->database, "SELECT * FROM parameter_class
139 WHERE name='" . $_GET['classname']
140 . "' AND property_name='" . $_GET['propname'] . "'");
141 $cls = pg_fetch_object($res, 0);
143 echo "<form action='classes.php?classname=" . $cls->name . "&propname=" . $cls->property_name . "' method='POST'>";
146 echo "<tr><td>Description</td><td><input name='description' type='text' value='";
147 echo $cls->description . "'></td></tr>";
149 echo "<tr><td>Property type</td><td><input name='proptype' type='radio' value='STATIC'";
150 if ($cls->property_type == "STATIC")
152 echo " checked='true'";
154 echo ">STATIC<br><input name='proptype' type='radio' value='DYNAMIC'";
155 if ($cls->property_type == "DYNAMIC")
157 echo " checked='true'";
159 echo ">DYNAMIC</td></tr>";
161 echo "<tr><td>Notify Changes</td><td><input type='checkbox' name='notify'";
162 if ($cls->notify == 't')
164 echo " checked='true'";
167 if ($cls->property_type == "DYNAMIC")
169 echo "<tr><td>Default minimum</td><td><input type='text' name='min' value='";
172 echo "<tr><td>Default maximum</td><td><input type='text' name='max' value='";
177 echo "<input type='submit' name='action' value='Save Changes'>";
182 echo "<h1>Parameter Classes Administration</h1><hr>";
184 $res = pg_exec($this->database, "SELECT name, property_name, description FROM parameter_class
185 ORDER BY name, property_name");
188 echo "<tr><th>Class</th><th>Property</th><th>Description</th><tr>";
190 while ($cls < pg_numrows($res))
192 $u = pg_fetch_object($res, $cls);
194 <tr><td align='center'><a href='classes.php?classname=<?php echo $u->name?>&propname=<?php echo $u->property_name ?>'><img src='change.png'></a><br>
195 <b><?php echo $u->name ?></b>
197 <?php echo $u->property_name ?>
199 <?php echo $u->description ?>
201 <form action='classes.php' method='post' onSubmit='return CheckRemove(this)'>
202 <input type='hidden' name='classname' value='<?php echo $u->name ?>'>
203 <input type='hidden' name='propname' value='<?php echo $u->property_name ?>'>
204 <input type='submit' name='action' value='Remove'>
214 <h2>Create new parameter class property:</h2>
217 <form action='classes.php' method='post' onSubmit='return CheckCreate(this)'>
218 Class name: <input name='classname' type='text'>
219 Property name: <input name='propname' type='text'>
221 <input type='submit' name='action' value='Create'>
230 $page = new class_page("Gnucomo Parameter Classes Administration");