Location: PHPKode > projects > NaWui > nawui/serviceescalationedit.php
<?php

# Page variables
define("PAGE_ID","serviceescalationedit");
define("PAGE_TITLE","Service Escalation object");
define("OBJECTTYPE","serviceescalation");
define("OBJECTTYPE","ServiceEscalation");

require_once("includes/main.inc.php");

$rowcolor = "";
$errormsg = "";
$cntinh = 0;
$action = (isset($action)) ? @strtolower($action) : "";
$objectid = (isset($objectid)) ? $objectid :  NULL;

# Actions before output is send
switch ($action)	{

	case 'save':
		$saveobject['host_name'] = @implode(",",$saveobject['host_name']);
		$saveobject['hostgroup_name'] = @implode(",",$saveobject['hostgroup_name']);
		$saveobject['contact_groups'] = @implode(",",$saveobject['contact_groups']);
		
		$objectid = $Plugin->SaveObject($objectid, $saveobject, OBJECTTYPE);
		echo "<BODY onLoad='opener.location.reload(); parent.close()'>";
		break;
}

include_once("html_wrap/head2.inc.php");


if ($objectid != "") {

	$object = $Plugin->GetObjectById($objectid, OBJECTTYPE);
	$objectid = (isset($object['__objectid'])) ? $object['__objectid'] : "";

} elseif (!isset($object))	{

	$object = NULL;
}



# Get a default cfg file if object is new
if ($objectid == "") {

	$objects = $Plugin->GetObjects(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';
		$inhhtml = "  <td>&nbsp;</td>";
	}
	
  	$show = NagiosObjPropEdit(OBJECTTYPE, $key, "saveobject[$key]", $value);

	if (empty($object[$key]))
		$required = $propconf[2] == TRUE ? $reqclass : 'label';
        
	$rowcolor = ($rowcolor != "dataOdd") ? "dataOdd" : "dataEven";
	
	$key=ucfirst(str_replace("_", " ", $key));

	$rows[$key] = <<<HTML
<tr class="{$rowcolor}">
  <td>$key</td>
  <td class="$required" width="3">&nbsp;</td>
  <td>
  $show
  </td>
  $inhhtml
</tr>
HTML;
}

?>
<div align="center">
<form method="post">
<input type="hidden" name="objectid" value="<?=$objectid?>">

<table cellpadding="3" border="0">
<tr>
  <td colspan="4" align="left">
   <?=ErrorMsg($errormsg)?>
  </td>
</tr>
<tr class="data">
  <th colspan="3" class="data">Properties</th>
<?

if (!empty($object['use']) )	{

	$parent = PluginGetObjectByName($object['use'],OBJECTTYPE);
  	print <<<HTML
  <th class="data">
  Inherits from <a href="serviceescalationedit.php?objectid={$parent['__objectid']}"><b>{$parent['name']}</b></a>
  </th>
HTML;

} else echo "<th class=\"data\">&nbsp;</th>";

?>
</tr>
<?=implode("\n", $rows)?>
<tr>
  <td colspan="4" align="center">
   <hr>
  </td>
</tr>
<tr>
  <td colspan="4" align="center">
   <input type="submit" name="action" value="Save">
   <input type="submit" name="action" value="Cancel" onclick="parent.close('')">
</td>
</tr>
</table>
</form>
</div>
<?

include_once("html_wrap/tail2.inc.php");

?>
Return current item: NaWui