Code

Fixed handling for new systems.
[gosa.git] / plugins / admin / systems / class_systemManagement.inc
index 25b8bd30daa089122b8ffc09382c2e13d1f5261b..77c6eb364a81306ab70508cbad81cafd843834d2 100644 (file)
@@ -24,6 +24,7 @@ require "tabs_phone.inc";
 require "tabs_server.inc";
 require "tabs_component.inc";
 require "tabs_winstation.inc";
+require "tabs_arpnewdevice.inc";
 
 
 class systems extends plugin
@@ -189,9 +190,9 @@ class systems extends plugin
 
       /* Find out more about the object type */
       $ldap= $this->config->get_ldap_link();
-      $ldap->cat($this->dn, array('objectClass'));
+      $ldap->cat($this->dn, array('objectClass','gotoMode'));
       $attrs= $ldap->fetch();
-      $type= $this->get_system_type($attrs['objectClass']);
+      $type= $this->get_system_type($attrs);
 
       /* Lock the current entry, so everyone will get the
          above dialog */
@@ -205,7 +206,9 @@ class systems extends plugin
           "component"   => array("CLASS"=>"COMPONENTTABS","TABCLASS" =>"componenttabs"));
 
 
-      if($type == "NewDevice"){
+      if($type == "ArpNewDevice"){
+        $this->systab = new ArpNewDeviceTabs($this->config,$this->config->data['TABS']['ARPNEWDEVICETABS'],$this->dn);
+      }elseif($type == "NewDevice"){
         $this->systab = new SelectDeviceType($this->config,$this->dn) ;
       }elseif(isset($tabs[$type])){
 
@@ -263,7 +266,7 @@ class systems extends plugin
                   <pre>';
 
         /* Open process handle and check if it is a valid process */
-        $process= proc_open($command, $dsc, $pipes);
+        $process= proc_open($command." '".$this->dn."'", $dsc, $pipes);
         if (is_resource($process)) {
           fclose($pipes[0]);
 
@@ -421,9 +424,9 @@ class systems extends plugin
 
         /* Find out more about the object type */
         $ldap= $this->config->get_ldap_link();
-        $ldap->cat($this->dn, array('objectClass'));
+        $ldap->cat($this->dn, array('objectClass','gotoMode'));
         $attrs= $ldap->fetch();
-        $type= $this->get_system_type($attrs['objectClass']);
+        $type= $this->get_system_type($attrs);
 
         $tabs = array(
             "terminal"    => array("CLASS"=>"TERMTABS",     "TABCLASS" =>"termtabs"),
@@ -497,28 +500,13 @@ class systems extends plugin
           }
         }   
         if(!$found){
-          print_red(sprintf(_("Can't set gotoMode to status 'avtice', the current object couldn't be identified.")));
+          print_red(sprintf(_("Can't set gotoMode to status 'active', the current object couldn't be identified.")));
         }
 
       }
       /* Save, or display error message? */
       if (count($message) == 0){
 
-        /* Save terminal data to ldap */
-        if(isset($_SESSION['SelectedSystemType']['ogroup']) && $_SESSION['SelectedSystemType']['ogroup'] != 'none'){
-          foreach (array("workservice", "termservice") as $cls){
-            if (isset($this->systab->by_object[$cls])){
-              $this->systab->by_object[$cls]->gotoXMouseport= "";
-              $this->systab->by_object[$cls]->gotoXMouseType= "";
-              $this->systab->by_object[$cls]->gotoXResolution= "";
-              $this->systab->by_object[$cls]->gotoXColordepth= "";
-            }
-          }
-        }
-
-        $this->systab->save();
-        gosa_log ("System object'".$this->dn."' has been saved");
-
         /* Incoming behavior; you can select a system type and an ogroup membership. 
          * If this object is an Incoming object, $_SESSION['SelectedSystemType'] isset.
          * Check if we must add the new object to an object group.
@@ -537,6 +525,24 @@ class systems extends plugin
               $og->save();
             }
           }
+        }
+
+        /* Save terminal data to ldap */
+        if(isset($_SESSION['SelectedSystemType']['ogroup']) && $_SESSION['SelectedSystemType']['ogroup'] != 'none'){
+          foreach (array("workservice", "termservice") as $cls){
+            if (isset($this->systab->by_object[$cls])){
+              $this->systab->by_object[$cls]->gotoXMouseport= "";
+              $this->systab->by_object[$cls]->gotoXMouseType= "";
+              $this->systab->by_object[$cls]->gotoXResolution= "";
+              $this->systab->by_object[$cls]->gotoXColordepth= "";
+            }
+          }
+        }
+
+        $this->systab->save();
+        gosa_log ("System object'".$this->dn."' has been saved");
+
+        if(isset($_SESSION['SelectedSystemType'])){
           if(!isset($ldap)){
             $ldap = $this->config->get_ldap_link();
           }
@@ -549,6 +555,7 @@ class systems extends plugin
           $ldap->cd($this->config->current['BASE']);
         }
 
+
         /* Terminal has been saved successfully, remove lock from
            LDAP. */
         if ($this->dn != "new"){
@@ -656,7 +663,7 @@ class systems extends plugin
     $responsible= array();
     foreach ($this->config->departments as $key => $value){
       if (get_module_permission(get_permissions ($value, $this->ui->subtreeACL),
-            "terminal", $value) == "#all#"){
+            "systems", $value) != ""){
         $responsible[$key]= $value;
       }
     }
@@ -698,16 +705,16 @@ class systems extends plugin
       if($this->DivListSystem->$checkBox){
         if($this->DivListSystem->SubSearch){
           if($oc['CLASS'] != ""){
-            $filter = "(|(&".$userregex."(objectClass=".$oc['CLASS'].")(cn=".$this->DivListSystem->Regex.")))";
+            $filter = "(&".$userregex."(objectClass=".$oc['CLASS'].")(cn=".$this->DivListSystem->Regex."))";
             $res = array_merge($res,get_list($filter,$this->ui->subtreeACL, $base,
-                  array("cn", "description", "macAddress", "objectClass", "sambaDomainName", "FAIstate"), GL_NONE | GL_SUBSEARCH | GL_SIZELIMIT));
+                  array("cn", "description", "macAddress", "objectClass", "sambaDomainName", "FAIstate","gotoMode"), GL_NONE | GL_SUBSEARCH | GL_SIZELIMIT));
           }
         }else{
           /* User filter? */
           if($oc['CLASS'] != ""){
-            $filter = "(|(&".$userregex."(objectClass=".$oc['CLASS'].")(cn=".$this->DivListSystem->Regex.")))";
+            $filter = "(&".$userregex."(objectClass=".$oc['CLASS'].")(cn=".$this->DivListSystem->Regex."))";
             $res = array_merge($res,get_list($filter,$this->ui->subtreeACL, $oc['TREE'].$base,
-                  array("cn", "description", "macAddress", "objectClass", "sambaDomainName", "FAIstate"), GL_NONE | GL_SIZELIMIT));
+                  array("cn", "description", "macAddress", "objectClass", "sambaDomainName", "FAIstate", "gotoMode"), GL_NONE | GL_SIZELIMIT));
           }
         }
       } 
@@ -716,7 +723,7 @@ class systems extends plugin
     /* Search for incoming objects */ 
     $filter = "(|(&".$userregex."(objectClass=goHard)(cn=".$this->DivListSystem->Regex.")))";
     $res = array_merge($res,get_list($filter,$this->ui->subtreeACL, "ou=incoming,".$base,
-          array("cn", "description", "macAddress", "objectClass", "sambaDomainName"), GL_NONE | GL_SIZELIMIT));
+          array("cn", "description", "macAddress", "objectClass", "sambaDomainName","gotoMode"), GL_NONE | GL_SIZELIMIT));
 
     /* Get all gotoTerminal's */
     foreach ($res as $value){
@@ -737,6 +744,8 @@ class systems extends plugin
           $add= "- "._("New terminal");
         }elseif (in_array_ics('gotoWorkstation', $value['objectClass'])){
           $add= "- "._("New workstation");
+        }elseif (in_array_ics('GOhard', $value['objectClass']) && !isset($value['gotoMode'])){
+          $add= "- "._("Unknown device");
         }elseif (in_array_ics('GOhard', $value['objectClass'])){
           $add= "- "._("New Device");
         }
@@ -830,8 +839,11 @@ class systems extends plugin
   }
 
 
-  function get_system_type($classes)
+  function get_system_type($attrs)
   {
+    $enable_arp_device_handling = preg_match("/ArpNewDevice/i",search_config($this->config->data['TABS'], "ArpNewDevice", "CLASS"));
+    $classes = $attrs['objectClass'];
+
     $type= "";
     if (in_array_ics('ieee802Device', $classes)){
       $type= "component";
@@ -845,6 +857,8 @@ class systems extends plugin
       $type= "phone";
     }elseif (in_array_ics('goServer', $classes)){
       $type= "server";
+    }elseif (in_array_ics('GOhard', $classes) && !isset($attrs['gotoMode']) && $enable_arp_device_handling){
+      $type= "ArpNewDevice";
     }elseif (in_array_ics('GOhard', $classes)){
       $type= "NewDevice";
     }elseif (in_array_ics('sambaAccount', $classes) ||
@@ -900,12 +914,9 @@ class systems extends plugin
                 $type= 'R'.$type;
                 break;
       case 'install':
-                $type= 'Y'.$type;
-                break;
       case 'sysinfo':
-                $type= 'Y'.$type;
-                break;
       case 'softupdate':
+      case 'scheduledupdate':
                 $type= 'Y'.$type;
                 break;
     }