From: hickert Date: Fri, 20 Jan 2006 09:36:16 +0000 (+0000) Subject: Added check to avoid deleting dropdown_catrige types which are still in use X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=de731515aed5001d612e30707c55a1ee0b03d69e;p=gosa.git Added check to avoid deleting dropdown_catrige types which are still in use git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2534 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/include/class_glpi.inc b/include/class_glpi.inc index 544fd7463..2148dd2f0 100644 --- a/include/class_glpi.inc +++ b/include/class_glpi.inc @@ -1637,6 +1637,20 @@ class glpiDB{ } } + function getUsedDropdownTypes($id=false) + { + if($this->is_connected){ + if($id){ + $qry = "SELECT distinct(type) FROM glpi_cartridges_type WHERE type = ".$id.";"; + }else{ + $qry = "SELECT distinct(type) FROM glpi_cartridges_type;"; + } + return($this->query($qry)); + }else{ + echo "not connected"; + return(false); + } + } } //$s = new glpiDB("vserver-01","glpi","tester","glpi"); diff --git a/plugins/admin/systems/class_glpiPrinterCartridgesEdit.inc b/plugins/admin/systems/class_glpiPrinterCartridgesEdit.inc index 5607b5127..ff8d42751 100644 --- a/plugins/admin/systems/class_glpiPrinterCartridgesEdit.inc +++ b/plugins/admin/systems/class_glpiPrinterCartridgesEdit.inc @@ -111,7 +111,12 @@ class glpiPrinterCartridgesEdit extends plugin /* Remove selected type from our printer types list */ if((isset($_POST['del_cartridge_type']))&&(!empty($_POST['select_type_cartridge']))){ - $this->parent->handle->removeCartridgeDropdownType($_POST['select_type_cartridge']); + $used = $this->parent->handle->getUsedDropdownTypes($_POST['select_type_cartridge']); + if(!count($used)){ + $this->parent->handle->removeCartridgeDropdownType($_POST['select_type_cartridge']); + }else{ + print_red(_("Can't delete this entry, it is still in use.")); + } } /* Rename selected printer type to given string