From 03f2e4106be808874b96dbc6b0fa0e6e5ebf35f2 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 18 Jan 2006 10:28:19 +0000 Subject: [PATCH] Added check which test if a device can be deleted, or if it is still in use git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2519 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/class_glpi.inc | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/include/class_glpi.inc b/include/class_glpi.inc index fc8dd37f6..f3de29b24 100644 --- a/include/class_glpi.inc +++ b/include/class_glpi.inc @@ -578,6 +578,33 @@ class glpiDB{ return(false); } + + /* Check if given device is used by some accounts + * (helpfull to avoid removement of used devices) + */ + function is_deviceUsed($item) + { + + $deviceMappingGOsaGlpi = array_flip($this->deviceMappingGOsaGlpi); + $deviceMappingTableNameID = $this->deviceMappingTableNameID; + if($this->is_connected){ + $tablename = $deviceMappingGOsaGlpi[$item['device_type']]; + $type = $item['device_type']; + + if($type=="monitor"){ + $str = "SELECT * FROM glpi_connect_wire WHERE end1=".$item['ID']." AND type=4;"; + }else{ + $str = "SELECT * FROM glpi_computer_device WHERE device_type=".$deviceMappingTableNameID[$type]." AND FK_device=".$item['ID'].";"; + } + return(count($this->query($str))); + }else{ + echo "not connected"; + return(false); + } + + } + + /* This functions deletes a specified entry * from our device tables */ @@ -978,7 +1005,7 @@ class glpiDB{ } } - + /* Monitor handling */ function getMonitors() -- 2.30.2