Code

Added some comments and checks
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 18 Jan 2006 08:39:45 +0000 (08:39 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 18 Jan 2006 08:39:45 +0000 (08:39 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2514 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_glpiAttachmentPool.inc
plugins/admin/systems/class_glpiDeviceManagement.inc

index 2d96528ec12db25488908fdca6083d8920271392..8a2da67d74eb07e6d80477e3824b467e81b66269 100644 (file)
@@ -162,7 +162,7 @@ class glpiAttachmentPool extends plugin
      */
     if($this->edit == true){
       foreach($this->attributes as $attr){
-        $smarty->assign($attr,htmlentities($this->$attr));
+        $smarty->assign($attr,htmlentities(utf8_decode($this->$attr)));
       }
       if(!empty($this->filename)){
         if(is_readable("/etc/gosa/glpi/".$this->filename)){
index 19541ba4105371b31ea171336175492b09f85c85..e3a5497bc2f6a429ea1a62c3d565d22c170303f9 100644 (file)
@@ -72,14 +72,16 @@ class glpiDeviceManagement extends plugin
     $smarty= get_smarty();
     $display= "";
 
-    /* Check if we should create a new entry .... */
+    /* this var is used to ensure that every post is only performed once */
     $only_once = true;
+
+    /* Check Post for some actions */
     foreach($_POST as $name => $value){
       
-      /* All Post vars starts with new */
+      /* If new_ then we should create an new device */
       if((preg_match("/^new_/",$name))&&($only_once)){
     
-        /* do this twice */
+        /* don't do this twice */
         $only_once = false;
 
         /*extract device device_type */
@@ -100,7 +102,7 @@ class glpiDeviceManagement extends plugin
       }
     }
 
-    /* Open entry for editing if requested */
+    /* delete was requested ... show dialog   */
     if((isset($_GET['act']))&&($_GET['act']=="del_device")){
       $id = base64_decode($_GET['id']);
       $tmp = $this->devices[$id];
@@ -118,10 +120,14 @@ class glpiDeviceManagement extends plugin
       return($smarty->fetch(get_template_path('remove_glpi.tpl', TRUE)));
     }
 
-
+    /* Delete entry, but check if this device is in currently in use */
     if(isset($_POST['delete_glpi_confirm'])){
-      $this->parent->handle->deleteDevice($this->delete);
-      $this->reload();
+      if($this->parent->handle->is_deviceUsed($this->delete)){
+        print_red(_("Can't delete this device, it is actually in use by some glpi accounts. Remove this relation first."));
+      }else{
+        $this->parent->handle->deleteDevice($this->delete);
+        $this->reload();
+      }
     }
 
     /* Open entry for editing if requested */
@@ -314,11 +320,11 @@ class glpiDeviceManagement extends plugin
 
   /* This function cehck all created devices if you wan't to create device specific check 
       use >>if($attr['device_type']=="moboard")<< to create a device type depending check
-  */
+   */
   function check($attr)
   {
     $message = array();
-    
+
     if(isset($attr['designation'])){
       $str2 = "designation";
     }else{
@@ -331,6 +337,9 @@ class glpiDeviceManagement extends plugin
     /* Avoid same name twice */
     $devices = ($this->parent->handle->getDevices());
     foreach($devices as $dev){
+
+      /* Some devices use designation some name for name
+       */
       if(isset($dev['designation'])){
         $str = "designation";
       }else{
@@ -338,7 +347,7 @@ class glpiDeviceManagement extends plugin
       }
 
       if($dev[$str]==$attr[$str2]){
-
+        
         /* Entries with ['ID'] already exists, and are only edited, if ID is missing we are currently creating a new entry */
         if(isset($attr['ID'])){
           if(!(($dev['ID'] == $attr['ID'])&&($dev['device_type']==$attr['device_type']))){
@@ -362,7 +371,7 @@ class glpiDeviceManagement extends plugin
 
     /* Transfer given data to smarty */
     foreach($this->EditEntry as $name => $value){
-      $smarty->assign($name,htmlentities($value));
+      $smarty->assign($name,htmlentities(utf8_decode($value)));
     }
   
     /* Set default select boxes, manufacturers ... */