Code

Fixed wrong existance check
[gosa.git] / gosa-plugins / systems / admin / systems / class_systemManagement.inc
index 722af8e4c6e196be3de32a2c4ca77929452a257e..844e9f629ef24a9ed2fa44844db9291c63700453 100644 (file)
@@ -222,14 +222,14 @@ class systems extends plugin
     if ($s_action=="gen_cd"){
       $this->dn= $this->terminals[$s_entry]['dn'];
       set_object_info($this->dn);
-      return ($smarty->fetch(get_template_path('gencd.tpl', TRUE)));
+      return ($smarty->fetch(get_template_path('goto/gencd.tpl', TRUE)));
     }
 
 
     /* Start CD-Creation */
     if ((isset($_POST["cd_create"])) && !empty($this->dn)){
       $smarty->assign("src", "?plug=".$_GET['plug']."&PerformIsoCreation");
-      return ($smarty->fetch(get_template_path('gencd_frame.tpl', TRUE)));
+      return ($smarty->fetch(get_template_path('goto/gencd_frame.tpl', TRUE)));
     }
 
 
@@ -316,7 +316,28 @@ class systems extends plugin
         If no object group was selected, then we keep the "edit" dialog of 
          the target system opened to allow to edit the objects attributes.
      */
-  
+    
+    if($this->systab instanceOf ArpNewDeviceTabs && 
+       isset($_POST['edit_finish']) && 
+       isset($_POST['gotoIntegration'])){
+      
+      $this->systab->save_object();
+
+      if($this->systab->by_object['ArpNewDevice']->gotoIntegration){
+
+        /* Check tabs, will feed message array */
+        $message = $this->systab->check();
+        if(count($message)){
+          msg_dialog::displayChecks($message);
+        }else{
+          $s_action = "SelectedSystemType";
+          $this->systab->save();
+          $this->systab = null;
+          unset($_POST['edit_finish']);
+        }
+      }
+    }
     if($s_action == "SelectedSystemType"){
 
       /* Possible destination system types 
@@ -325,7 +346,11 @@ class systems extends plugin
 
       /* Remember dialog selection.
        */
-      $selected_group = $_POST['ObjectGroup'];
+      
+      $selected_group = "none";
+      if(isset($_POST['ObjectGroup'])){
+        $selected_group = $_POST['ObjectGroup'];
+      }
       $selected_system = $_POST['SystemType'];
 
       $this->systab = NULL;
@@ -360,10 +385,15 @@ class systems extends plugin
 
             /* We are allowed to create the requested system type */
             if(preg_match("/c/",$tabacl)){
-              $this->systab= new $tabclass($this->config, $this->config->data['TABS'][$class], $this->dn,$selected_system);
+              $this->systab= new $tabclass($this->config, $this->config->data['TABS'][$class], $this->dn, $selected_system);
               $this->systab->set_acl_base($this->DivListSystem->selectedBase);
-              $this->systab->by_object[$tabname]->base = $this->DivListSystem->selectedBase;
-              $this->systab->base = $this->DivListSystem->selectedBase;
+              if($selected_group != "none"){
+                $this->systab->base = preg_replace("/^[^,]+,".get_ou('ogroupRDN')."/", "", $selected_group);
+                $this->systab->by_object[$tabname]->base = $this->systab->base;
+              } else {
+                $this->systab->by_object[$tabname]->base = $this->DivListSystem->selectedBase;
+                $this->systab->base = $this->DivListSystem->selectedBase;
+              }
 
               /* This will be used when the object is saved, to set FAIstate to 'install'
                   and to preset maybe other attributes.
@@ -554,6 +584,7 @@ class systems extends plugin
           msg_dialog::display(_("Error"), msgPool::class_not_found("ArpNewDevice"), ERROR_DIALOG);
         }else{
           add_lock ($this->dn, $this->ui->dn);
+          $this->system_activation_object= array($this->dn);
           $this->systab = new ArpNewDeviceTabs($this->config,$this->config->data['TABS']['ARPNEWDEVICETABS'],$this->dn);
         }
       }elseif($type == "NewDevice"){
@@ -1005,7 +1036,7 @@ class systems extends plugin
             target opsi -> Remove source.
             target gosa -> Activate system.
          */
-        if($this->systab instanceOf opsi_tabs && $this->systab->was_activated){
+        if($this->systab instanceOf opsi_tabs){
           $ldap = $this->config->get_ldap_link();
           $ldap->cd($this->config->current['BASE']);
           $ldap->rmdir ($this->systab->dn);
@@ -1269,9 +1300,12 @@ class systems extends plugin
     $res = array_merge($res,get_list($filter,$sys_categories, get_ou('systemIncomingRDN').$base,$sys_attrs, GL_SIZELIMIT));
 
     /* Append opsi systems, the opsi extension have to installed.
-        (Only, if we are allowed to view opsi hosts)
+        (Only, if we are allowed to view opsi hosts and if we're on the ldap root)
      */
-    if($this->opsi instanceof opsi && $this->opsi->enabled() && $this->DivListSystem->ShowOpsiHosts){
+    if($this->DivListSystem->selectedBase == $this->config->current['BASE'] && 
+        $this->opsi instanceof opsi && 
+        $this->opsi->enabled() && 
+        $this->DivListSystem->ShowOpsiHosts){
       $o_acl = $this->ui->get_permissions($base,"opsi/opsiGeneric","");
       if(preg_match("/r/",$o_acl)){
         $opsi_clients = $this->opsi->get_hosts_for_system_management();
@@ -1436,8 +1470,9 @@ class systems extends plugin
        If there is a samba host, then merge it with the opsi host,
         to avoid duplicate entries.
      */
+    $oRex = preg_replace("/\*/",".*",$this->DivListSystem->Regex);
     foreach($opsi_clients as $entry){
-      if(isset($opsi_map[$entry['cn'][0]])){
+      if(isset($opsi_map[$entry['cn'][0]]) || !preg_match("/".($oRex)."/", $entry['cn'][0])){
         continue;
       }
       $terminal             = $entry;
@@ -1461,10 +1496,11 @@ class systems extends plugin
 
   function remove_lock()
   {
-    if (isset($this->systab->dn)){
-      del_lock ($this->systab->dn);
-    }elseif(isset($this->dn) && !empty($this->dn) && $this->dn != "new"){
+     
+    if(isset($this->dn) && !empty($this->dn) && $this->dn != "new"){
       del_lock($this->dn);
+    }elseif (isset($this->systab->dn)){
+      del_lock ($this->systab->dn);
     }
     if(isset($this->dns) && is_array($this->dns) && count($this->dns)){
       del_lock($this->dns);