Code

Apply fix for #4271
[gosa.git] / trunk / gosa-plugins / systems / admin / systems / class_systemManagement.inc
index 722af8e4c6e196be3de32a2c4ca77929452a257e..3d9fa94b5dddbd667ceaa34a196c9d2fb2f9f8c5 100644 (file)
@@ -149,6 +149,10 @@ class systems extends plugin
       $s_entry  = preg_replace("/^newsystem_/","",$_POST['menu_action']);
     }
 
+    if (isset($_POST['edit_continue'])) {
+      $s_action = "select_ogroup_finished";
+    }
+
     /* handle C&P from layers menu */
     if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){
       $s_action = "copy_multiple";
@@ -409,14 +413,13 @@ class systems extends plugin
                 }
 
                 /*******
-                 * Set default system specific attributes 
+                 * Enable inheritance
                  */
-                foreach (array("workservice", "termservice") as $cls){
+                foreach (array("workgeneric", "termgeneric") 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->by_object[$cls]->member_of_ogroup = true;
+                    $this->systab->by_object[$cls]->set_everything_to_inherited();
+                    $this->systab->by_object[$cls]->save();
                   }
                 }
 
@@ -426,11 +429,6 @@ class systems extends plugin
                     $this->systab->by_object[$cls]->auto_activate= TRUE;
                   }
                 }
-
-                // Enable sending of LDAP events
-                if (isset($this->systab->by_object["workstartup"])){
-                  $this->systab->by_object["workstartup"]->gotoLdap_inherit= TRUE;
-                }
               }
 
               /* Don't save directly if there is no objectGroup selected.
@@ -464,8 +462,34 @@ class systems extends plugin
     }
 
 
+    if ($s_action=="select_ogroup_finished") {
+      $this->systab->save_object();
+
+      if (count($this->systab->check())!=0) {
+        foreach($this->systab->check() as $msg){
+          msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
+        }
+      }elseif(isset($this->systab->objectClass) && isset($this->systab->sw)) {
+        $this->dn = "new";
+        $sw = $this->systab->sw;
+        $tabs = $this->get_tab_defs();
+        $class    = $tabs[$sw]["CLASS"];
+        $tabname  = $tabs[$sw]["TABNAME"];
+        $tabclass = $tabs[$sw]["TABCLASS"];
+        $acl_cat  = $tabs[$sw]["ACLC"];
+        $ogroup = $this->systab->save();
+        if (class_exists($tabclass)) {
+            $this->systab= new $tabclass($this->config, $this->config->data['TABS'][$class], $this->dn,$sw);
+            $this->systab->set_acl_base($this->DivListSystem->selectedBase);
+            $this->systab->by_object[$tabname]->base = $this->DivListSystem->selectedBase;
+            $this->systab->by_object[$tabname]->ogroup = $ogroup;
+            $this->systab->base = $this->DivListSystem->selectedBase;
+        }
+      }
+    }
+
     if (isset($_POST['create_system'])||$s_action=="newsystem") {
-    
+
       $this->last_action = "";
   
       /* If the current entry is an incoming object 
@@ -476,6 +500,7 @@ class systems extends plugin
       }else{
         $sw = $s_entry;
       }
+
       $this->dn= "new";
 
       $tabs = $this->get_tab_defs();
@@ -491,14 +516,18 @@ class systems extends plugin
         $ui       = get_userinfo();
         $tabacl   = $ui->get_permissions($this->DivListSystem->selectedBase,$acl_cat."/".$tabname);
         if(preg_match("/c/",$tabacl)){
-
-          if(!class_available($tabclass)){
-            msg_dialog::display(_("Error"), msgPool::class_not_found($tabclass), ERROR_DIALOG);
-          }else{
-            $this->systab= new $tabclass($this->config, $this->config->data['TABS'][$class], $this->dn,$sw);
+          if ($tabclass == 'worktabs') {
+            $this->systab = new askObjectGroup($this->config, $this->dn, $ui, $tabclass, $sw);
+          }
+          else {
+            if(!class_available($tabclass)){
+              msg_dialog::display(_("Error"), msgPool::class_not_found($tabclass), ERROR_DIALOG);
+            }else{
+              $this->systab= new $tabclass($this->config, $this->config->data['TABS'][$class], $this->dn,$sw);
             $this->systab->set_acl_base($this->DivListSystem->selectedBase);
             $this->systab->by_object[$tabname]->base = $this->DivListSystem->selectedBase;
             $this->systab->base = $this->DivListSystem->selectedBase;
+            }
           }
         }else{
           msg_dialog::display(_("Error"), msgPool::permCreate(), ERROR_DIALOG);
@@ -819,12 +848,8 @@ class systems extends plugin
        */
       if(isset($_POST['save_event_dialog']) || $this->systab->get_type() == TRIGGERED_EVENT){
         $o_queue = new gosaSupportDaemon();
-        $o_queue->append($this->systab);
-        if($o_queue->is_error()){
-          msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
-        }else{
-          $this->systab = FALSE;
-        }
+        $this->systab = DaemonEvent::save_event_dialog($this->systab, NULL, $o_queue, $this->config);
+
       }
       if(isset($_POST['abort_event_dialog'])){
         $this->systab = FALSE;
@@ -924,6 +949,7 @@ class systems extends plugin
             if(in_array($type,array("ArpNewDevice","NewDevice")) && class_available("termgeneric")){
               $this->systab= new termgeneric($this->config, $dn);
               $this->systab->set_acl_base($dn);
+              $this->systab->set_acl_category("terminal");
               $this->systab->remove_from_parent();
             }elseif($tabtype=="phonetabs"){
               $this->systab= new $tabtype($this->config, $this->config->data['TABS'][$tabobj], $dn,$type);
@@ -1103,6 +1129,7 @@ class systems extends plugin
         $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
         $display.= "</p>";
       }
+
       return ($display);
     }
 
@@ -1257,7 +1284,14 @@ class systems extends plugin
         }else{
           /* User filter? */
           if($oc['CLASS'] != ""){
-            $filter = "(&".$userregex."(objectClass=".$oc['CLASS'].")(cn=".$this->DivListSystem->Regex."))";
+            $filter = "(&".$userregex."(objectClass=".$oc['CLASS'].")";
+            /* Decide weither to search in description and CN or only in the CN */
+            if ($this->DivListSystem->DescSearch) {
+              $filter = $filter . "(|(cn=".$this->DivListSystem->Regex.")(description=".$this->DivListSystem->Regex.")))";
+            }
+            else {
+              $filter = $filter . "(cn=".$this->DivListSystem->Regex."))";
+            }
             $res = array_merge($res,get_list($filter,$sys_categories,$oc['TREE'].$base, $sys_attrs,  GL_SIZELIMIT));
           }
         }
@@ -1265,8 +1299,14 @@ class systems extends plugin
     }
 
     /* Search for incoming objects */ 
-    $filter = "(|(&".$userregex."(objectClass=goHard)(cn=".$this->DivListSystem->Regex.")))";
-    $res = array_merge($res,get_list($filter,$sys_categories, get_ou('systemIncomingRDN').$base,$sys_attrs, GL_SIZELIMIT));
+    $filter = "(|(&".$userregex."(objectClass=goHard)";
+    if ($this->DivListSystem->DescSearch) {
+      $filter = $filter . "(|(cn=".$this->DivListSystem->Regex.")(description=".$this->DivListSystem->Regex.")))";
+    }
+    else {
+      $filter = $filter . "(cn=".$this->DivListSystem->Regex.")))";
+    }
+    $res = array_merge($res,get_list($filter,$sys_categories, get_ou('systemIncomingRDN').$this->config->get_cfg_value('base'),$sys_attrs, GL_SIZELIMIT));
 
     /* Append opsi systems, the opsi extension have to installed.
         (Only, if we are allowed to view opsi hosts)