downtime_edit.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 downtime_edit extends formWebObj
00029 {
00030   var $downtime_record = array(
00031                                'start'       => '',
00032                                'endtime'     => '',
00033                                'description' => ''
00034                                );
00035   
00036   function init()
00037     {
00038       $this->addSVar('mode', 'hidden');  // add | edit | hidden
00039       $this->addSVar('downtime_id', UNDEFINED);
00040     }
00041 
00042   function on_save($event_args)
00043     {
00044       //(double)check that only a site admin can save changes
00045       $site_id = WebApp::getSVar('site->id');
00046       if (!is_site_admin($site_id))
00047         {
00048           WebApp::message(T_("Only a site admin can do this!"));
00049           return;
00050         }
00051 
00052       $mode = $this->getSVar('mode');
00053       
00054       if ($mode=='add')
00055         {
00056           //add the new downtime
00057           WebApp::execDBCmd('add_downtime', $event_args);
00058 
00059           //set the new id
00060           $this->setSVar('downtime_id', $event_args['downtime_id']);
00061         }
00062       elseif ($mode=='edit')
00063         {
00064           WebApp::execDBCmd('update_downtime', $event_args);
00065         }
00066 
00067       //switch the editing mode to hidden
00068       $this->setSVar('mode', 'hidden');
00069     }
00070 
00071   function onRender()
00072     {
00073       $mode = $this->getSVar('mode');
00074       if ($mode=='add')
00075         {
00076           WebApp::addVars($this->downtime_record);
00077         }
00078       elseif ($mode=='edit')
00079         {
00080           $rs = WebApp::openRS('get_downtime');
00081           WebApp::addVars($rs->Fields());
00082         }
00083     }
00084 }
00085 ?>

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