Checks before removing objects

master
Thomas Hooge 2 years ago
parent 8c61638485
commit 02980bbad5
  1. 7
      assetclass.php
  2. 7
      assetclassgroup.php
  3. 7
      location.php
  4. 2
      tpl/style.css
  5. 2
      tpl/vlanview.tpl
  6. 6
      vlan.php
  7. 7
      zone.php

@ -60,6 +60,13 @@ switch ($submit = form_get_action()) {
break;
case 'delete':
$sth = $dbh->prepare("SELECT COUNT(*) FROM asset WHERE assetclass_id=?");
$sth->execute([$id]);
if ($sth->fetchColumn() > 0) {
$g_warning->Add("Objektklasse kann nicht gelöscht werden, da noch zugeordnete Objekte vorhanden sind.");
$action = ACT_VIEW;
break;
}
$sth = $dbh->prepare("DELETE FROM assetclass WHERE assetclass_id=?");
try {
$sth->execute([$id]);

@ -59,6 +59,13 @@ switch ($submit = form_get_action()) {
break;
case 'delete':
$sth = $dbh->prepare("SELECT COUNT(*) FROM assetclass WHERE assetclassgroup_id=?");
$sth->execute([$id]);
if ($sth->fetchColumn() > 0) {
$g_warning->Add("Objektklassengruppe kann nicht gelöscht werden, da noch zugeordnete Objektklassen vorhanden sind.");
$action = ACT_VIEW;
break;
}
$sth = $dbh->prepare("DELETE FROM assetclassgroup WHERE assetclassgroup_id=?");
try {
$sth->execute([$id]);

@ -118,7 +118,14 @@ switch ($submit = form_get_action()) {
break;
case 'delete':
$sth = $dbh->prepare("DELETE FROM subnetlocation WHERE location_id=?");
$sth->execute([$id]);
$n = $sth->rowCount();
if ($n > 0) {
$g_message->Add("$n Subnetzzuordnungen wurden entfernt.");
}
$sth = $dbh->prepare("DELETE FROM location WHERE location_id=?");
$g_message->Add("Standort wurde gelöscht.");
$sth->execute([$id]);
$action = ACT_DEFAULT;
break;

@ -210,7 +210,7 @@ div.error, div.warning, div.info, div.note {
margin: 1em 0 0 0;
border-radius: 12px;
width: 750px;
animation: fadeout 10s 2s forwards;
animation: fadeout 2s 10s forwards;
}
div.error {
border: 1px solid #8b0000;

@ -79,7 +79,7 @@
</td>
<td class="value">
{foreach item=subnet from=$subnets}
<a href="subnet.php?f=wiew&id={$subnet.subnet_id}">{$subnet.subnet_address}/{$subnet.subnet_mask}</a>
<a href="subnet.php?f=view&id={$subnet.subnet_id}">{$subnet.subnet_address}/{$subnet.subnet_mask}</a>
{$subnet.subnet_info}
<br>
{/foreach}

@ -88,6 +88,12 @@ switch ($submit = form_get_action()) {
break;
case 'delete':
$sth = $dbh->prepare("DELETE FROM subnetvlan WHERE vlan_id=?");
$sth->execute([$id]);
$n = $sth->rowCount();
if ($n > 0) {
$g_message->Add("$n vlan to subnet references were removed.");
}
$sth = $dbh->prepare("DELETE FROM vlan WHERE vlan_id=?");
$sth->execute([$id]);
$g_message->Add(_("VLAN deleted."));

@ -83,6 +83,13 @@ switch ($submit = form_get_action()) {
break;
case 'delete':
$sth = $dbh->prepare("SELECT COUNT(*) FROM node WHERE zone_id=?");
$sth->execute([$id]);
if ($sth->fetchColumn() > 0) {
$g_warning->Add("Zone can not be removed. There are node-references.");
$action = ACT_VIEW;
break;
}
$sth = $dbh->prepare("DELETE FROM zone WHERE zone_id=?");
$sth->execute([$id]);
$g_message->Add(_("Deleted zone"));