Logo Search packages:      
Sourcecode: nagat version File versions  Download package

hostgroupedit.php

<?php
# $Id: hostgroupedit.php,v 1.8 2002/06/22 06:29:25 kemuri Exp $

/*
 * Copyright (c) 2002 Ypsilon.Net AG, Germany
 *
 * This file is part of Nagat.
 * 
 * Nagat is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * Nagat is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Nagat; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

# Page variables
define("PAGE_ID","hostgroupedit");
define("PAGE_TITLE","Hostgroup object");
define("OBJECTTYPE","hostgroup");

require_once("local.inc");

$action = @strtolower($action);
$message = '';
$errmsg = '';
$object = NULL;
$cntinh = 0;

# Actions before output is send
switch($action) {
      case 'save':
            $saveobject['members'] = @implode(",",$saveobject['members']);
            $saveobject['contact_groups'] = 
                  @implode(",",$saveobject['contact_groups']);

            $objectid = PluginSaveObject($objectid,$saveobject,OBJECTTYPE);
            header("Location: hostgroups.php");
            exit();
            break;

      case 'delete':
            $objectid = PluginDeleteObject($objectid,OBJECTTYPE);
            header("Location: hostgroups.php");
            break;
}

include_once(NGT_LIB."head.inc");

if( is_array($object) == FALSE) {
      $object = PluginGetObject($objectid,OBJECTTYPE);
}


$hostgroupname = !empty($object["name"]) ? $object['name'] : ''; 

# If this is a template: get its iheriters
if( !empty($object['name']) ) {
      $cntinh = NagiosCountInherited($nagios_objects,OBJECTTYPE,
            $hostgroupname);
}

if( !empty($object['use']) ) {
      $inhobject = PluginGetObjectByName($object['use'],OBJECTTYPE);
      foreach($inhobject as $key => $value) {
            $object['++'.$key] = $value;
      }
}

# Get a default cfg file if object is new
if( $object['__cfgfile'] == "") {
  $objects = PluginGetObjects(OBJECTTYPE);
  $firstobject = reset($objects);
  $object['__cfgfile'] = $firstobject['__cfgfile'];
}

foreach( $confobjects[OBJECTTYPE] as $key => $propconf ) {

      $required = 'label';
      $value = !empty($object[$key]) ? $object[$key] : '';
      $inhhtml = "";
      
      if( isset($object["++".$key]) ) {
         $inhhtml = "  <td>".$object["++".$key]."</td>";
           $reqclass = 'requiredok';
      } else {
         $reqclass = 'required';
      }
      
      $show = NagiosObjPropEdit(OBJECTTYPE,$key,"saveobject[$key]",$value);

      if( empty($object['name']) ) {
            $required = $propconf[2] == TRUE ? $reqclass : 'label';
      }

      $rows[$key] = <<<HTML
<tr>
  <td class="label">$key</td>
  <td class="$required" with="3">&nbsp;</td>
  <td class="value">
  $show
  </td>
  $inhhtml
</tr>
HTML;
}

?>
<form method="post">
<input type="hidden" name="objectid" value="<?=$object['__objectid']?>">
<input type="hidden" name="saveobject[__cfgfile]" value="<?=$object['__cfgfile']?>">
<input type="hidden" name="saveobject[__type]" value="<?=$object['__type']?>">

<table cellpadding="3" border="0">
<tr>
  <td colspan="3" align="left">
  <?=ErrorMsg($errmsg)?>
  <b><?=$message?>&nbsp;</b>
  </td>
</tr>
<tr>
  <td colspan="3" align="right">
  <input type="submit" name="action" value="Save">
  <input type="submit" name="action" value="Delete">
  </td>
</tr>
<tr class="rowsep">
  <td colspan="3">Properties</td>
<?php
if( !empty($object['use']) ) {
      $parent = PluginGetObjectByName($object['use'],OBJECTTYPE);
  print <<<HTML
  <td>
  Inherits from 
  <a href="hostgroupedit.php?objectid={$parent['__objectid']}"><b>{$parent['name']}</b></a>
  </td>
HTML;
}
?>
</tr>
<?=implode("\n", $rows)?>
<?

if ( $cntinh > 0 ) {
      print ObjectInheritance($hostgroupname,OBJECTTYPE);
}

$userobjs = NagiosObjectUsage($hostgroupname,OBJECTTYPE);
if ( $userobjs != NULL ) {
      print ObjectUsage($hostgroupname,OBJECTTYPE,$userobjs);
}

?>

</table>
</form>

<?php
include_once(NGT_LIB."tail.inc");
?>

Generated by  Doxygen 1.6.0   Back to index