Code

Added check which test if a device can be deleted, or if it is still in use
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 18 Jan 2006 10:28:19 +0000 (10:28 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 18 Jan 2006 10:28:19 +0000 (10:28 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2519 594d385d-05f5-0310-b6e9-bd551577e9d8

include/class_glpi.inc

index fc8dd37f64f254ae84703c3da90d846da9fcbec3..f3de29b24e3dd7ccec5dcfd49992710de322426b 100644 (file)
@@ -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()