Code

Updated System type & os type management, can't create existing entries, can't delete...
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 25 Jan 2006 07:12:01 +0000 (07:12 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 25 Jan 2006 07:12:01 +0000 (07:12 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2563 594d385d-05f5-0310-b6e9-bd551577e9d8

include/class_glpi.inc
plugins/admin/systems/class_glpiAccount.inc

index 08f94fad60494d4841abe2b01bd17f99e1bce7c6..3c16b9fc174e6cb27684f44ac7f60d97799cdb35 100644 (file)
@@ -128,7 +128,6 @@ class glpiDB{
        */
        function updateSystemType($name,$id)
        {
-
                if($this->is_connected){
                        $tmp = $this->query("SELECT * FROM glpi_type_computers WHERE ID=".$id.";");
                        if(isset($tmp[0])){
@@ -321,18 +320,23 @@ class glpiDB{
        /* Operating systems 
           Returns all OSs
         */
-       function getOSTypes()
+       function getOSTypes($keys = false)
        {
                if($this->is_connected){
                        $ret = array();
-                       $tmp=($this->query("SELECT * FROM glpi_dropdown_os;"));
+                       $tmp=($this->query("SELECT * FROM glpi_dropdown_os ORDER by name;"));
 
-                       foreach($tmp as $t){
-                               $ret[$t['ID']]=$t['name'];
+                       if($keys){
+                               foreach($tmp as $t){
+                                       $ret[$t['name']]=$t['ID'];
+                               }
+                       }else{
+                               foreach($tmp as $t){
+                                       $ret[$t['ID']]=$t['name'];
+                               }
                        }
-
                        return($ret);
-                               
+
                }else{
                        echo "not connected";
                        return(false);
@@ -399,7 +403,6 @@ class glpiDB{
        */
        function updateOS($name,$id)
        {
-
                if($this->is_connected){
                        $tmp = $this->query("SELECT * FROM glpi_dropdown_os WHERE ID=".$id.";");
                        if(isset($tmp[0])){
@@ -1510,6 +1513,28 @@ class glpiDB{
        }
 
 
+
+       /* check if given manufacturer ID ist still in use.
+          The problem is, that nearly every table uses manufacturers .... 
+     */
+       function is_manufacturerUsed($id)
+       {
+               $tables = array();
+               foreach($this->deviceMappingGOsaGlpi as $table => $entry){
+                       $tables[] = $entry;
+               }
+               $tables[] ="sdf";
+               print_a($tables);
+               exit();
+
+               if($this->is_connected){
+                       $ret = array();
+               }else{
+                       echo "not connected";
+                       return(false);
+               }
+       }
+
        /* Manufacturer 
           Updates already existing manufacturer
         */
index 643503a2fd6c4db528b82673baddbcfb7f20c8a2..0f11882cd646b87c9f98bce03a5db07824833a22 100644 (file)
@@ -267,7 +267,12 @@ class glpiAccount extends plugin
     /* This appends a new system to our sytem types
      */
     if((isset($_POST['add_type']))&&(!empty($_POST['type_string']))){
-      $this->handle->addSystemType($_POST['type_string']);  
+      $attr = $this->handle->getSystemTypes();
+      if(in_array(trim($_POST['type_string']),$attr)){
+        print_red(_("Adding new sytem type failed, this system type name is already used.")) ;
+      }else{
+        $this->handle->addSystemType(trim($_POST['type_string']));  
+      }
     }
 
     /* Remove selected type from our system types list
@@ -293,7 +298,12 @@ class glpiAccount extends plugin
     /* Rename selected system type to given string
      */
     if((isset($_POST['rename_type']))&&(!empty($_POST['select_type']))&&(!empty($_POST['type_string']))){
-      $this->handle->updateSystemType($_POST['type_string'],$_POST['select_type']);
+      $attr = $this->handle->getSystemTypes();
+      if(in_array(trim($_POST['type_string']),$attr)){
+        print_red(_("Rename failed, this system type name is already used.")) ;
+      }else{
+        $this->handle->updateSystemType($_POST['type_string'],trim($_POST['select_type']));
+      }
     }
 
     /* Someone wants to edit the system types ... 
@@ -323,7 +333,12 @@ class glpiAccount extends plugin
     /* Add new os to the db
      */
     if((isset($_POST['add_os']))&&(!empty($_POST['is_string']))){
-      $this->handle->addOS($_POST['is_string']);  
+      $attr = $this->handle->getOSTypes();
+      if(in_array(trim($_POST['is_string']),$attr)){
+        print_red(_("Adding new operating system failed, specifed name is already used.")) ;
+      }else{
+        $this->handle->addOS(trim($_POST['is_string']));  
+      }
     }
 
     /* Delete selected os from list and db
@@ -352,7 +367,12 @@ class glpiAccount extends plugin
     /* Rename selected os to given string
      */
     if((isset($_POST['rename_os']))&&(!empty($_POST['select_os']))&&(!empty($_POST['is_string']))){
-      $this->handle->updateOS($_POST['is_string'],$_POST['select_os']);
+      $attr = $this->handle->getOSTypes();
+      if(in_array(trim($_POST['is_string']),$attr)){
+        print_red(_("Updating operating system failed, specifed name is already used.")) ;
+      }else{
+        $this->handle->updateOS($_POST['is_string'],$_POST['select_os']);
+      }
     }
 
     /* Open dialog to edit os types