Code

Updated work startup
[gosa.git] / gosa-plugins / goto / admin / systems / goto / class_terminalStartup.inc
index 2e7675e2fc0e261e7578147280e1055a02070077..3a9a237e50e3e14edb183b42e6c9c0fb355108a1 100644 (file)
@@ -1,15 +1,9 @@
 <?php
 class termstartup extends plugin
 {
-  /* CLI vars */
-  var $cli_summary= "Manage terminal startup options";
-  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 $bootmode= "G";
   var $goLdapServerList= array();
-  var $gotoBootKernel= "default-inherit";
+  var $gotoBootKernel= "default";
   var $gotoKernelParameters= "";
   var $gotoLdapServer= "";
   var $gotoModules= array();
@@ -42,7 +36,7 @@ class termstartup extends plugin
   {
     plugin::plugin ($config, $dn, $parent);
 
-    $this->gotoBootKernels = array("default-inherit"=>"["._("inherited")."]");
+    $this->gotoBootKernels = array("default"=> ("default"));
 
     /* Get arrays */
     foreach (array("gotoModules") as $val){
@@ -58,16 +52,6 @@ class termstartup extends plugin
       $this->$val= array_unique($this->$val);
     }
 
-    /* Parse Kernel Parameters to decide what boot mode is enabled */
-    if (preg_match("/ splash=silent/", $this->gotoKernelParameters)){
-      $this->bootmode= "G";
-    } elseif (preg_match("/ debug/", $this->gotoKernelParameters)){
-      $this->bootmode= "D";
-    } elseif ($this->gotoKernelParameters == "") {
-      $this->bootmode= "G";
-    } else {
-      $this->bootmode= "T";
-    }
     if (preg_match("/ o /", $this->gotoKernelParameters)){
       $this->customParameters= preg_replace ("/^.* o /", "", $this->gotoKernelParameters);
     } else {
@@ -141,15 +125,17 @@ class termstartup extends plugin
     $ldap->cd($this->config->current['BASE']);
     $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".LDAP::prepare4filter($this->dn)."))");
     if ($ldap->count() == 1){
-      $map= array("gotoLdapServer");
+      $map= array("gotoLdapServer","gotoBootKernel");
       $attrs= $ldap->fetch();
 
       foreach ($map as $name){
         if (!isset($attrs[$name][0])){
           continue;
         }
-
         switch ($name){
+          case 'gotoBootKernel':
+            $this->gotoBootKernels["default"] = "["._("inherited")."]"; 
+          break;
           case 'gotoLdapServer':
             $this->goLdapServerList= array_merge(array('default-inherit' => _("inherited").' ['.$attrs[$name][0].']' ), $this->goLdapServerList);
             break;
@@ -176,7 +162,7 @@ class termstartup extends plugin
     /* Do we represent a valid terminal? */
     if (!$this->is_account && $this->parent === NULL){
       $display= "<img alt=\"\" src=\"images/stop.png\" align=middle>&nbsp;<b>".
-        _("This 'dn' has no terminal features.")."</b>";
+        msgPool::noValidExtension(_("terminal"))."</b>";
       return ($display);
     }
 
@@ -218,7 +204,7 @@ class termstartup extends plugin
     if(isset($_POST['gotoShareAdd']) && $this->acl_is_writeable("gotoShare")){
       /* We assign a share to this user, if we don't know where to mount the share */
       if((!isset($_POST['gotoShareMountPoint']))||(empty($_POST['gotoShareMountPoint']))||(preg_match("/[\|]/i",$_POST['gotoShareMountPoint']))){
-        print_red(_("You must specify a valid mount point."));
+        msg_dialog(_("Error"), msgPool::invalid(_("Mount point")), WARNING_DIALOG);
       }else{
         $a_share = $this->gotoAvailableShares[$_POST['gotoShareSelection']];
         $s_mount = $_POST['gotoShareMountPoint'];
@@ -326,23 +312,6 @@ class termstartup extends plugin
       $smarty->assign($val, $this->$val);
     }
 
-    /* Radio button group */
-    if (preg_match("/G/", $this->bootmode)) {
-      $smarty->assign("graphicalbootup", "checked");
-    } else {
-      $smarty->assign("graphicalbootup", "");
-    }
-    if (preg_match("/T/", $this->bootmode)) {
-      $smarty->assign("textbootup", "checked");
-    } else {
-      $smarty->assign("textbootup", "");
-    }
-    if (preg_match("/D/", $this->bootmode)) {
-      $smarty->assign("debugbootup", "checked");
-    } else {
-      $smarty->assign("debugbootup", "");
-    }
-
     /* Show main page */
     return($smarty->fetch (get_template_path('terminalStartup.tpl', TRUE,dirname(__FILE__))));
   }
@@ -368,11 +337,6 @@ class termstartup extends plugin
         $this->gotoLdap_inherit = FALSE;
       }
 
-      /* Save group radio buttons */
-      if ($this->acl_is_writeable("bootmode") && isset($_POST["bootmode"])){
-        $this->bootmode= $_POST["bootmode"];
-      }
-
       /* Save kernel parameters */
       if ($this->acl_is_writeable("gotoKernelParameters") && isset($_POST["customParameters"])){
         $this->customParameters= $_POST["customParameters"];
@@ -421,14 +385,6 @@ class termstartup extends plugin
       ",ro,hard,nolock,fg,rsize=8192 ".
       "ip=::::::dhcp ldap=".base64_encode($this->gotoLdapServer);
 
-    switch ($this->bootmode){
-      case "D":
-        $this->gotoKernelParameters.= " debug";
-      break;
-      case "G":
-        $this->gotoKernelParameters.= " splash=silent";
-      break;
-    }
     if ($this->customParameters != ""){
       $this->gotoKernelParameters.= " o ".$this->customParameters;
     }
@@ -456,9 +412,12 @@ class termstartup extends plugin
       }
     }
 
+    /* Check if LDAP server has changed */
+    $ldap_changed= ($this->attrs['gotoLdapServer'] != $this->saved_attributes['gotoLdapServer']);
+
     /* Strip out 'default' values */
     foreach(array("gotoBootKernel") as $value){
-      if (!isset($this->attrs[$value]) || $this->attrs[$value] == "default-inherit"){
+      if (!isset($this->attrs[$value]) || $this->attrs[$value] == "default"){
         $this->attrs[$value] = array();
       } 
     }
@@ -481,8 +440,26 @@ class termstartup extends plugin
 
     new log("modify","terminal/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
 
-    show_ldap_error($ldap->get_error(), sprintf(_("Saving of system terminal/startup with dn '%s' failed."),$this->dn));
+    if (!$ldap->success()){
+      msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
+    }
     $this->handle_post_events("modify");
+
+    /* Send ldap configuration update
+     */
+    if ($ldap_changed && class_available("DaemonEvent")){
+      $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENTS);
+      $o_queue = new gosaSupportDaemon();
+      if(isset($events['TRIGGERED']['DaemonEvent_reload_ldap_config'])){
+        $evt = $events['TRIGGERED']['DaemonEvent_reload_ldap_config'];
+        $tmp = new $evt['CLASS_NAME']($this->config);
+        $tmp->set_type(TRIGGERED_EVENT);
+        $tmp->add_targets(array($this->parent->by_object['termgeneric']->netConfigDNS->macAddress));
+        if(!$o_queue->append($tmp)){
+          msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
+        }
+      }
+    }
   }
 
   /* Add value to array, check if unique */
@@ -529,7 +506,7 @@ class termstartup extends plugin
 
     $source_o = new termstartup ($this->config, $source['dn']);
 
-    foreach(array("gotoModules", "gotoKernelParameters","gotoShares","customParameters","bootmode","gotoTerminalPath","gotoShares","goLdapServerList","gotoBootKernel","gotoLdapServer","gotoBootKernels") as $attr){
+    foreach(array("gotoModules", "gotoKernelParameters","gotoShares","customParameters","gotoTerminalPath","gotoShares","goLdapServerList","gotoBootKernel","gotoLdapServer","gotoBootKernels") as $attr){
       $this->$attr = $source_o->$attr;
     }
   }