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

# Page variables
define("PAGE_ID","deleteobject");
define("PAGE_TITLE","Delete $objecttype ?");

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

$action = @strtolower($action);
$object = NULL;
$cntinh = 0;
$objectid = (isset($objectid)) ? $objectid : NULL;

# Actions before output is send
switch($action) {
	case 'yes':

		$objectid = $Plugin->DeleteObject($objectid, $objecttype);
		if (isset($all))	{
			if ($all == "1")	{
				# Function to remove all Objects references
			}
		}
	
		echo "<BODY onLoad='opener.location.reload(); parent.close()'>";
		break;
}

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

if ($objectid != "") {

	$object = $Plugin->GetObjectById($objectid, $objecttype);
}


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

# If this is a template: get its iheriters
if( !empty($object['name']) ) {

	$cntinh = NagiosCountInherited($objecttype, $name);
}

?>
<br>
<div align="center">
<table cellpadding="3" border="0">
<tr class="data">
 <th class="data">
  <?
  switch ($objecttype)	{
  	case "host":
   		echo "Name";
		break;
  	case "hostgroup":
   		echo "Contact Group Name";
		break;
  	case "contact":
		echo "Contact Name";
		break;
  	case "service":
		echo "Service Description";
		break;
  	case "serviceescalation":
		echo "Service Escalation";
		break;
  	case "command":
		echo "Command Name";
		break;
  }
  ?>
  </th>
  <th class="data">
  <?
  switch ($objecttype)	{
  	case "host":
   		echo "Alias";
		break;
  	case "hostgroup":
   		echo "Alias";
		break;
  	case "contact":
		echo "Alias";
		break;
  	case "service":
		echo "Host";
		break;
  	case "serviceescalation":
		echo "&nbsp;";
		break;
  	case "command":
		echo "Command Line";
		break;
  }
  ?>
  </th>
  <th class="data">Inheritance</th>
</tr>
<tr>
  <td class="dataOdd">
  <?
	if (($objecttype == "service") || ($objecttype == "serviceescalation"))	{
   
   		echo $object["service_description"];
 
	} elseif ($objecttype == "hostextinfo")	{
  	
		echo $object["host_name"];
 	
	} elseif ($objecttype == "serviceextinfo")	{
  	
		echo "Hostname: ".$object["host_name"]."<br>\n";
		echo "Service Name: ".$object["service_name"];
 
	} else	{
  		echo $object[$objecttype."_name"];
	}
  ?>
  </td>

  <td class="dataOdd">
  <?
  switch ($objecttype)	{
  	case "hostgroup": 
		echo @$object["hostgroup_name"];
		break;
  	case "service": 
		echo @$object["host_name"];
		break;
  	case "serviceescalation": 
		#echo $object["host_name"];
		echo "&nbsp;";
		break;
	case "command":
		echo @$object["command_line"];
		break;
	default:
		echo @$object["alias"];
   }
  ?>
  </td>

<?
if ($cntinh != 0)	{
  
	echo "<td class=\"dataError\">";
} else	{

	echo "<td class=\"dataOdd\">";
}
?>
  used by <?=$cntinh?> objects
  </td>
</tr>
</table>
</div>
<form name="deleteform" method="post">
<input type="hidden" name="objectid" value="<?=$objectid?>">
<div align="center">
<table width="100%" cellpadding="3" border="0">
<tr>
  <td colspan="2" align="center">Do you want to delete this <?=$objecttype?>?</td>
</tr>
<tr>
  <td width="50%" align="right"> <input type="submit" name="action" value="Yes"> </td>
  <td width="50%" align="left"> <input type="submit" name="action" value="No" onclick="parent.close()"> </td>
</tr>
<!--
<tr>
  <td colspan="2" align="center"><input type="checkbox" name="all" value="1"> remove also all references to this <?=$objecttype?>. </td>
</tr>
-->
</table>
</form>
</div>
<?

if (DEBUG == "1")	{
	PrintArray($object);
	echo "objecttype: $objecttype<br>";
	echo "name: $name<br>";
	PrintArray($cntinh);
}
?>
</body>
</html>
Return current item: NaWui