node_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 node_edit extends formWebObj
00029 {
00030   var $node_record = array(
00031                            'type'         => '',
00032                            'machine_name' => '',
00033                            'arch'         => '',
00034                            'os'           => '',
00035                            'cpu'          => '',
00036                            'ram'          => '',
00037                            'storage'      => '',
00038                            'middleware'   => '',
00039                            'comments'     => ''
00040                            );
00041   
00042   function init()
00043     {
00044       $this->addSVar('mode', 'hidden');  // add | edit | hidden
00045       $this->addSVar('node_id', UNDEFINED);
00046     }
00047 
00048   function on_save($event_args)
00049     {
00050       //(double)check that only a site admin can save changes
00051       $site_id = WebApp::getSVar('site->id');
00052       if (!is_site_admin($site_id))
00053         {
00054           WebApp::message(T_("Only a site admin can do this!"));
00055           return;
00056         }
00057 
00058       $mode = $this->getSVar('mode');
00059       
00060       if ($mode=='add')
00061         {
00062           //add the new node
00063           WebApp::execDBCmd('add_node', $event_args);
00064 
00065           //set the new id
00066           $this->setSVar('node_id', $event_args['node_id']);
00067         }
00068       elseif ($mode=='edit')
00069         {
00070           WebApp::execDBCmd('update_node', $event_args);
00071         }
00072 
00073       //switch the editing mode to hidden
00074       $this->setSVar('mode', 'hidden');
00075     }
00076 
00077   function onRender()
00078     {
00079       $mode = $this->getSVar('mode');
00080       if ($mode=='add')
00081         {
00082           WebApp::addVars($this->node_record);
00083         }
00084       elseif ($mode=='edit')
00085         {
00086           $rs = WebApp::openRS('get_node');
00087           WebApp::addVars($rs->Fields());
00088         }
00089     }
00090 }
00091 ?>

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