Code

Removed show_ldap_error() calls
[gosa.git] / gosa-plugins / goto / admin / systems / goto / class_terminalGeneric.inc
index a09bff8595941cf3c74566ab9430dae6729f31ab..7928972f7d3260bdbaa9749405be9e00a9cc511f 100644 (file)
@@ -44,11 +44,7 @@ class termgeneric extends plugin
       "ghGfxAdapter", "ghSoundAdapter", "gotoLastUser");
   var $objectclasses= array("top", "gotoTerminal", "GOhard");
 
-  var $mapActions   = array("reboot"          => "",
-                            "rescan"          => "",
-                            "wake"            => "",
-                            "memcheck"        => "memcheck",
-                            "sysinfo"         => "sysinfo");
+  var $validActions   = array("reboot" => "", "rescan" => "", "wake" => "", "memcheck" => "", "sysinfo" => "");
 
   var $fai_activated = FALSE;
   var $view_logged = FALSE;
@@ -163,23 +159,14 @@ class termgeneric extends plugin
       $this->is_account= !$this->is_account;
     }
 
-    if (isset($_POST['action']) && $this->acl_is_writeable("FAIstate") && isset($this->mapActions[$_POST['saction']])){
-
-
-
-     /* Check given action */
-      $mapEvent = array("wake"           => "wakeup",
-                        "instant_update" => "update");
+    if (isset($_POST['action']) && $this->acl_is_writeable("FAIstate") && isset($this->validActions[$_POST['saction']])){
       $action = $_POST['saction'];
-      if(isset($mapEvent[$action])){
-        $action = $mapEvent[$action];
-      }
 
       /* Check if we have an DaemonEvent for this action */
       if(class_available("DaemonEvent_".$action)){
-        $events = DaemonEvent::get_event_types(SYSTEM_EVENT);
-        if(isset($events['BY_CLASS']["DaemonEvent_".$action])){
-          $evt = $events['BY_CLASS']["DaemonEvent_".$action];
+        $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
+        if(isset($events['TRIGGERED']["DaemonEvent_".$action])){
+          $evt = $events['TRIGGERED']["DaemonEvent_".$action];
           $tmp = new $evt['CLASS_NAME']($this->config);
           $tmp->add_targets(array($this->netConfigDNS->macAddress));
           $tmp->set_type(TRIGGERED_EVENT);
@@ -190,22 +177,10 @@ class termgeneric extends plugin
           }
         }
       }else{
-
-        msg_dialog::display(_("Missing Daemon Event"),
-                    sprintf(_("The requested action does not exists '%s' Sending event manually."),"DaemonEvent_".$action),ERROR_DIALOG);
-
-        /* No event found, send action manually.
-         */
-        $method= "gosa";
-        $action= $_POST['saction'];
-        if ($action == "reinstall" || $action == "update" || $action == "instant_update"){
-          $method= "job";
-        }
-
-        gosaSupportDaemon::send("${method}_trigger_action_".$action,
-            $this->netConfigDNS->macAddress,
-            array("macAddress" => $this->netConfigDNS->macAddress));
+        msg_dialog::display(_("Event error"),
+                    sprintf(_("Event '%s' is not available!"),$action),ERROR_DIALOG);
       }
+
     }
 
     /* Base select dialog */
@@ -341,7 +316,9 @@ class termgeneric extends plugin
   
         new log("remove","terminal/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
   
-        show_ldap_error($ldap->get_error(), sprintf(_("Removing of object system terminal/generic with dn '%s' failed."),$this->dn));
+        if (!$ldap->success()){
+          msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_DEL, get_class()));
+        }
 
         /* Optionally execute a command after we're done */
         $this->handle_post_events("remove",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
@@ -355,6 +332,13 @@ class termgeneric extends plugin
           $og->save ();
         }
       }
+
+      /* Clean queue form entries with this mac 
+       */
+      if(class_available("gosaSupportDaemon") && tests::is_mac($this->netConfigDNS->orig_macAddress)){
+        $q = new gosaSupportDaemon();
+        $q->clean_queue_from_mac($this->netConfigDNS->orig_macAddress);
+      }
     }
   }
 
@@ -508,11 +492,6 @@ class termgeneric extends plugin
       }
     }
 
-    /* Append gosaAdministrativeUnitTag to objectClass if gosaUnitTag isset */
-    if(($this->gosaUnitTag) && (!in_array_ics("gosaAdministrativeUnitTag",$this->attrs['objectClass']))){
-      $this->attrs['objectClass'][] = "gosaAdministrativeUnitTag";
-    }
-
     /* Write back to ldap */
     $ldap= $this->config->get_ldap_link();
     if ($this->orig_dn == 'new'){
@@ -540,15 +519,17 @@ class termgeneric extends plugin
 
     $this->netConfigDNS->cn = $this->cn;
     $this->netConfigDNS->save();
-    show_ldap_error($ldap->get_error(), sprintf(_("Saving of object system terminal/generic with dn '%s' failed."),$this->dn));
+    if (!$ldap->success()){
+      msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
+    }
 
     /* Send installation activation
      */
-    if ($activate){
-      $events = DaemonEvent::get_event_types(SYSTEM_EVENT);
+    if ($activate && class_available("DaemonEvent")){
+      $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
       $o_queue = new gosaSupportDaemon();
-      if(isset($events['BY_CLASS']['DaemonEvent_installation_activation'])){
-        $evt = $events['BY_CLASS']['DaemonEvent_installation_activation'];
+      if(isset($events['TRIGGERED']['DaemonEvent_installation_activation'])){
+        $evt = $events['TRIGGERED']['DaemonEvent_installation_activation'];
         $tmp = new $evt['CLASS_NAME']($this->config);
         $tmp->set_type(TRIGGERED_EVENT);
         $tmp->add_targets(array($this->netConfigDNS->macAddress));