info.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003 This file  is part  of HGSM.   HGSM is a  web application  for keeping
00004 information about a hierarchical structure (in this case a grid).
00005 
00006 Copyright 2005, 2006 Dashamir Hoxha, dashohoxha@users.sourceforge.net
00007 
00008 HGSM is free software; you  can redistribute it and/or modify it under
00009 the terms of  the GNU General Public License as  published by the Free
00010 Software  Foundation; either  version 2  of the  License, or  (at your
00011 option) any later version.
00012 
00013 HGSM is  distributed in the hope  that it will be  useful, but WITHOUT
00014 ANY WARRANTY; without even  the implied warranty of MERCHANTABILITY or
00015 FITNESS FOR A PARTICULAR PURPOSE.   See the GNU General Public License
00016 for more details.
00017 
00018 You  should have received  a copy  of the  GNU General  Public License
00019 along with HGSM; if not,  write to the Free Software Foundation, Inc.,
00020 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00021 */
00022 
00023 include_once FORM_PATH.'formWebObj.php';
00024 
00028 class info extends formWebObj
00029 {
00030   function on_save($event_args)
00031     {
00032       //(double)check that only a site admin can save changes
00033       $site_id = WebApp::getSVar('site->id');
00034       if (!is_site_admin($site_id))
00035         {
00036           WebApp::message(T_("Only a site admin can do this!"));
00037           return;
00038         }
00039       
00040       $site_info = $event_args;
00041       $site_info['timestamp'] = time();
00042       $this->update_record($site_info, 'sites', 'site_id');
00043     }
00044 
00045   function on_change_id($event_args)
00046     {
00047       //(double)check that only a country admin can do this
00048       $rs = WebApp::openRS('get_country_id');
00049       $country_id = $rs->Field('country_id');
00050       if (!is_country_admin($country_id))
00051         {
00052           WebApp::message(T_("Only a country admin can do this!"));
00053           return;
00054         }
00055 
00056       $new_id = $event_args['site_id'];
00057 
00058       //make sure that this id does not already exist
00059       $rs = WebApp::openRS('get_site_id', array('site_id'=>$new_id));
00060       if (!$rs->EOF())
00061         {
00062           WebApp::message(T_("Another site with this id already exists!"));
00063           return;
00064         }
00065 
00066       //change the site id in the DB
00067       $args = array('site_id'=>$new_id, 'timestamp'=>time());
00068       WebApp::execDBCmd('set_site_id', $args);
00069 
00070       //change the state variable site->id
00071       $old_id = WebApp::getSVar('site->id');
00072       WebApp::setSVar('site->id', $new_id);
00073 
00074       //change it also in 'site_nodes', 'site_contacts' and 'site_downtimes'
00075       $args = array('new_site_id'=>$new_id, 'old_site_id'=>$old_id);
00076       WebApp::execDBCmd('update_nodes_site_id', $args);
00077       WebApp::execDBCmd('update_contacts_site_id', $args);
00078       WebApp::execDBCmd('update_downtimes_site_id', $args);
00079     }
00080 
00081   function on_set_admin($event_args)
00082     {
00083       //(double)check that only a country admin can do this
00084       $rs = WebApp::openRS('get_country_id');
00085       $country_id = $rs->Field('country_id');
00086       if (!is_country_admin($country_id))
00087         {
00088           WebApp::message(T_("Only a country admin can do this!"));
00089           return;
00090         }
00091 
00092       $event_args['timestamp'] = time();
00093       WebApp::execDBCmd('set_admin', $event_args);
00094     }
00095 
00096   function onRender()
00097     {
00098       $rs = WebApp::openRS('get_site');
00099       $vars = $rs->Fields();
00100       $vars['timestamp'] = date('d/m/Y', $vars['timestamp']);
00101       WebApp::addVars($vars);
00102     }
00103 }
00104 ?>

Generated on Fri Jan 20 10:34:52 2006 for HGSM by  doxygen 1.4.5