Code

Apply fix for #4271
[gosa.git] / trunk / gosa-plugins / systems / admin / systems / class_systemManagement.inc
index d240cece85caabbe2648ec94ab30929b96a5d0be..9f18ef5671c93ba78b721bc92e8cbe13f75e157f 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";
@@ -458,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 
@@ -470,6 +500,7 @@ class systems extends plugin
       }else{
         $sw = $s_entry;
       }
+
       $this->dn= "new";
 
       $tabs = $this->get_tab_defs();
@@ -485,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);
@@ -749,7 +784,7 @@ class systems extends plugin
       }
 
       if(count($ids) && class_available("DaemonEvent")){
-        $mac= array();
+        $targets = array();
 
         /* Collect target mac addresses */
         $ldap = $this->config->get_ldap_link();
@@ -757,12 +792,12 @@ class systems extends plugin
           $type = $this->get_system_type($this->terminals[$id]);
           if(!in_array($type,array("terminal","server","workstation","opsi_client","winstation "))) continue;
           if(isset($this->terminals[$id]['macAddress'][0])){
-            $mac[] = $this->terminals[$id]['macAddress'][0];
+            $targets[] = array( "mac" => $this->terminals[$id]['macAddress'][0], "cn" => $this->terminals[$id]['cn'][0] );
           }else{
-            $ldap->cat ($this->terminals[$id]['dn'], array("macAddress"));
+            $ldap->cat ($this->terminals[$id]['dn'], array("macAddress", "cn"));
             $attrs= $ldap->fetch();
             if (isset($attrs['macAddress'][0])){
-              $mac[]= $attrs['macAddress'][0];
+              $targets[]= array( "mac" => $attrs['macAddress'][0], "cn" => $attrs['cn'][0] );
             }
           }
         }
@@ -774,14 +809,15 @@ class systems extends plugin
          *  if this entry is currently processing.
          */
         if(preg_match("/trigger_event/",$s_action) && in_array($type,array("DaemonEvent_reinstall","DaemonEvent_update"))){
-          foreach($mac as $key => $mac_address){
+          foreach($targets as $key => $mac_address){
+            $mac_address = $mac_address[0];
             foreach($o_queue->get_entries_by_mac(array($mac_address)) as $entry){
 
               $entry['STATUS'] = strtoupper($entry['STATUS']);
               if($entry['STATUS'] == "PROCESSING" && 
                   isset($events['QUEUED'][$entry['HEADERTAG']]) && 
                   in_array($events['QUEUED'][$entry['HEADERTAG']],array("DaemonEvent_reinstall","DaemonEvent_update"))){
-                unset($mac[$key]);
+                unset($targets[$key]);
 
                 new log("security","systems/".get_class($this),"",array(),"Skip adding 'DaemonEvent::".$type."' for mac '".$mac_address."', there is already a job in progress.");
                 break;
@@ -792,10 +828,10 @@ class systems extends plugin
 
         /* Prepare event to be added 
          */
-        if(count($mac) && isset($events['BY_CLASS'][$type])){
+        if(count($targets) && isset($events['BY_CLASS'][$type])){
           $event = $events['BY_CLASS'][$type];
           $this->systab = new $event['CLASS_NAME']($this->config);
-          $this->systab->add_targets($mac);
+          $this->systab->add_targets($targets);
           if(preg_match("/trigger_event/",$s_action)){
             $this->systab->set_type(TRIGGERED_EVENT);
           }else{
@@ -813,12 +849,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;
@@ -1098,6 +1130,7 @@ class systems extends plugin
         $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
         $display.= "</p>";
       }
+
       return ($display);
     }
 
@@ -1274,7 +1307,7 @@ class systems extends plugin
     else {
       $filter = $filter . "(cn=".$this->DivListSystem->Regex.")))";
     }
-    $res = array_merge($res,get_list($filter,$sys_categories, get_ou('systemIncomingRDN').$base,$sys_attrs, GL_SIZELIMIT));
+    $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)