From 0bf075d5effd2feb7033252968020fe7d33b07b7 Mon Sep 17 00:00:00 2001 From: arjen Date: Mon, 1 Sep 2003 06:55:00 +0000 Subject: [PATCH] Provides an interface to edit the list of services and users for an object. --- src/web/objects.php | 154 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 150 insertions(+), 4 deletions(-) diff --git a/src/web/objects.php b/src/web/objects.php index 90cdafd..536d910 100644 --- a/src/web/objects.php +++ b/src/web/objects.php @@ -9,7 +9,7 @@ *********************** ** FILE NAME : objects.php ** SYSTEM NAME : Gnucomo - Gnu Computer Monitoring -** VERSION NUMBER : $Revision: 1.8 $ +** VERSION NUMBER : $Revision: 1.9 $ ** ** DESCRIPTION : Objects Administration page. ** Input parameters: action (POST) : empty, 'Create' @@ -29,7 +29,11 @@ /***************************** $Log: objects.php,v $ - Revision 1.8 2003-08-14 10:35:07 arjen + Revision 1.9 2003-09-01 06:55:00 arjen + Provides an interface to edit the list of + services and users for an object. + + Revision 1.8 2003/08/14 10:35:07 arjen Added editing of detailed object information. Revision 1.7 2003/07/15 11:02:25 arjen @@ -55,7 +59,7 @@ ******************************/ -// RCSID = "$Id: objects.php,v 1.8 2003-08-14 10:35:07 arjen Exp $"; +// RCSID = "$Id: objects.php,v 1.9 2003-09-01 06:55:00 arjen Exp $"; ini_set('include_path', '.:./classes:../phpclasses'); @@ -165,6 +169,82 @@ class object_page extends page pg_exec($this->database, $qry); } + else if (isset($_POST['action']) && $_POST['action'] == 'Modify Service') + { + $obj_srv_res = pg_exec($this->database, "SELECT * from object_service WHERE objectid='" . $_GET['oid'] + . "' AND servicecode='" . $_POST['servcode'] . "'"); + + if (pg_numrows($obj_srv_res) == 0) + { + // Add a new service for this object + if (isset($_POST['servused'])) + { + $qry = "INSERT INTO object_service (objectid, servicecode, expected_interval) "; + $qry .= "VALUES ('" . $_GET['oid'] . "', '" . $_POST['servcode'] . "', '"; + $qry .= $_POST['expinterval'] . "')"; + + pg_exec($this->database, $qry); + } + } + else + { + // Modify or remove the service for this object + if (isset($_POST['servused'])) + { + // Service is still used; update some values. + $qry = "UPDATE object_service SET expected_interval='" . $_POST['expinterval']; + $qry .= "' WHERE objectid='" . $_GET['oid']; + $qry .= "' AND servicecode='" . $_POST['servcode'] . "'"; + pg_exec($this->database, $qry); + } + else + { + // Checkbox was turned off, remove the service + + $qry = "DELETE FROM object_service WHERE objectid='" . $_GET['oid']; + $qry .= "' AND servicecode='" . $_POST['servcode'] . "'"; + pg_exec($this->database, $qry); + } + } + } + else if (isset($_POST['action']) && $_POST['action'] == 'Modify User') + { + $obj_srv_res = pg_exec($this->database, "SELECT * from object_user WHERE objectid='" . $_GET['oid'] + . "' AND username='" . $_POST['username'] . "'"); + + if (pg_numrows($obj_srv_res) == 0) + { + // Add a new user for this object + if (isset($_POST['userused'])) + { + $qry = "INSERT INTO object_user (objectid, username, security_level) "; + $qry .= "VALUES ('" . $_GET['oid'] . "', '" . $_POST['username'] . "', '"; + $qry .= $_POST['seclevel'] . "')"; + + pg_exec($this->database, $qry); + } + } + else + { + // Modify or remove the user for this object + if (isset($_POST['userused'])) + { + // Service is still used; update some values. + $qry = "UPDATE object_user SET security_level='" . $_POST['seclevel']; + $qry .= "' WHERE objectid='" . $_GET['oid']; + $qry .= "' AND username='" . $_POST['username'] . "'"; + pg_exec($this->database, $qry); + } + else + { + // Checkbox was turned off, remove the user + + $qry = "DELETE FROM object_user WHERE objectid='" . $_GET['oid']; + $qry .= "' AND username='" . $_POST['username'] . "'"; + pg_exec($this->database, $qry); + } + } + } $res = pg_exec($this->database, "SELECT * FROM object WHERE objectid='" . $_GET['oid'] . "'"); @@ -191,6 +271,72 @@ class object_page extends page echo ""; echo ""; echo ""; + + echo "

Services on " . $obj->objectname . "


\n"; + + echo ""; + echo ""; + $srv_res = pg_exec($this->database, "SELECT servicecode, servicename FROM service + ORDER BY servicecode"); + for ($srv_row = 0; $srv_row < pg_numrows($srv_res); $srv_row++) + { + $srv = pg_fetch_object($srv_res, $srv_row); + $srv_obj_res = pg_exec($this->database, "SELECT * FROM object_service WHERE objectid='" + . $obj->objectid . "' AND servicecode='" . $srv->servicecode . "'"); + + echo ""; + echo ""; + + if (pg_numrows($srv_obj_res) == 0) + { + echo ""; + echo ""; + echo ""; + echo ""; + } + else + { + $obj_srv = pg_fetch_object($srv_obj_res, 0); + echo ""; + echo ""; + echo ""; + echo ""; + } + echo ""; + } + echo "
Service nameLast entryExpected interval
" . $srv->servicename . "  " . $srv->servicename . "" . $obj_srv->last_entry . "
"; + + echo "

Users of " . $obj->objectname . "


\n"; + + echo ""; + echo ""; + + $usr_res = pg_exec($this->database, "SELECT username, security_level FROM usr ORDER BY username"); + for ($usr_row = 0; $usr_row < pg_numrows($usr_res); $usr_row++) + { + $usr = pg_fetch_object($usr_res, $usr_row); + $usr_obj_res = pg_exec($this->database, "SELECT * FROM object_user WHERE objectid='" + . $obj->objectid . "' AND username='" . $usr->username . "'"); + + echo ""; + echo ""; + + if (pg_numrows($usr_obj_res) == 0) + { + echo ""; + echo ""; + echo ""; + } + else + { + $usr_obj = pg_fetch_object($usr_obj_res, 0); + echo ""; + echo ""; + echo ""; + } + echo ""; + } + echo "
User nameSecurity level 
" . $usr->username . " " . $usr->username . "
"; } else { @@ -226,7 +372,7 @@ class object_page extends page $count_notifications += $this->nr_notifications; $closed_notifications += $this->closed_notifications; ?> -

+

objectname ?>
object_description) ?> -- 2.11.0