Code

Removed show_ldap_error() calls
[gosa.git] / gosa-plugins / goto / admin / systems / goto / class_terminalGeneric.inc
index 9a1b6d40175df37a4fa5e529f2b8c224d9349920..7928972f7d3260bdbaa9749405be9e00a9cc511f 100644 (file)
@@ -2,11 +2,6 @@
 
 class termgeneric extends plugin
 {
-  /* CLI vars */
-  var $cli_summary= "Manage terminal base objects";
-  var $cli_description= "Some longer text\nfor help";
-  var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
   /* Generic terminal attributes */
   var $gotoMode= "locked";
   var $gotoTerminalPath= "";
@@ -28,9 +23,11 @@ class termgeneric extends plugin
   var $ghSoundAdapter= "-";
   var $gotoLastUser= "-";
   var $netConfigDNS;
+  
   /* Needed values and lists */
   var $base= "";
   var $cn= "";
+  var $description= "";
   var $orig_dn= "";
 
   var $inheritTimeServer = true;
@@ -43,15 +40,11 @@ class termgeneric extends plugin
   var $attributes= array("gotoMode", "gotoTerminalPath", 
       "gotoSwapServer", "gotoSyslogServer", "gotoNtpServer",
       "gotoFloppyEnable", "gotoCdromEnable", "cn", "gotoSndModule",
-      "ghCpuType", "ghMemSize","ghUsbSupport",
+      "ghCpuType", "ghMemSize","ghUsbSupport", "description",
       "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;
@@ -166,8 +159,28 @@ class termgeneric extends plugin
       $this->is_account= !$this->is_account;
     }
 
-    if (isset($_POST['action']) && $this->acl_is_writeable("FAIstate") && isset($this->mapActions[$_POST['saction']])){
-           gosaSupportDaemon::send("gosa_trigger_action_".$_POST['saction'], $this->netConfigDNS->macAddress, array("macAddress" => $this->netConfigDNS->macAddress));
+    if (isset($_POST['action']) && $this->acl_is_writeable("FAIstate") && isset($this->validActions[$_POST['saction']])){
+      $action = $_POST['saction'];
+
+      /* Check if we have an DaemonEvent for this action */
+      if(class_available("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);
+          $o_queue = new gosaSupportDaemon();
+          if(!$o_queue->append($tmp)){
+            msg_dialog::display(_("Daemon"),sprintf(_("Something went wrong while talking to the daemon: %s."),
+                  $o_queue->get_error()),ERROR_DIALOG);
+          }
+        }
+      }else{
+        msg_dialog::display(_("Event error"),
+                    sprintf(_("Event '%s' is not available!"),$action),ERROR_DIALOG);
+      }
+
     }
 
     /* Base select dialog */
@@ -228,6 +241,7 @@ class termgeneric extends plugin
     }
 
     $smarty->assign("cn", $this->cn);
+    $smarty->assign("description", $this->description);
     $smarty->assign("staticAddress", "");
 
     $smarty->assign("bases", $this->get_allowed_bases());
@@ -236,11 +250,7 @@ class termgeneric extends plugin
     $smarty->assign("inheritTimeServer",$this->inheritTimeServer);
 
     /* Check if terminal is online */
-    $query= "fping -q -r 1 -t 500 ".$this->cn;
-    exec ($query, $dummy, $retval);
-
-    /* Offline */
-    if ($retval == 0){
+    if (gosaSupportDaemon::ping($this->netConfigDNS->macAddress)){
       $smarty->assign("actions", array( "halt" => _("Switch off"), 
                                         "reboot" => _("Reboot"),
                                         "memcheck" => _("Memory test"),
@@ -306,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));
@@ -320,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);
+      }
     }
   }
 
@@ -473,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'){
@@ -505,10 +519,25 @@ 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 ($activate){
-      gosaSupportDaemon::send("gosa_set_activated_for_installation", $this->netConfigDNS->ipHostNumber);
+    if (!$ldap->success()){
+      msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
+    }
+
+    /* Send installation activation
+     */
+    if ($activate && class_available("DaemonEvent")){
+      $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
+      $o_queue = new gosaSupportDaemon();
+      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));
+        if(!$o_queue->append($tmp)){
+          msg_dialog::display(_("Daemon"),sprintf(_("Something went wrong while talking to the daemon: %s."),
+                $o_queue->get_error()),ERROR_DIALOG);
+        }
+      }
     }
   }
 
@@ -584,6 +613,7 @@ class termgeneric extends plugin
             "gotoNtpServer"       => _("Ntp server settings"),
             "base"                => _("Base"),
             "cn"                  => _("Name"),
+            "description"         => _("Description"),
             "gotoRootPasswd"      => _("Root password"),
             "FAIstate"            => _("Action flag"))
           ));