Code

Updated workstation - Startup
[gosa.git] / plugins / admin / systems / class_servGeneric.inc
index f136a1c16c66706210948358ef3a4ec29bce2936..b46e85b29ceb61d2f4b63dd497a77d7c9dbf97de 100644 (file)
@@ -40,10 +40,11 @@ class servgeneric extends plugin
   var $fai_activated  =FALSE;
   var $view_logged = FALSE;
 
-  function servgeneric ($config, $dn= NULL, $parent= NULL)
+  function servgeneric (&$config, $dn= NULL, $parent= NULL)
   {
     /* Check if FAI is activated */
-    $tmp = search_config($config->data,"faiManagement","CLASS");
+    $tmp = $config->search("faiManagement", "CLASS",array('menu','tabs'));
+    
     if(!empty($tmp)){
       $this->fai_activated = TRUE;
     }
@@ -62,7 +63,7 @@ class servgeneric extends plugin
     } else {
       $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,/", "", $this->dn);
     }
-    $this->netConfigDNS = new termDNS($this->config,$this->dn,$this->objectclasses);
+    $this->netConfigDNS = new termDNS($this->config,$this,$this->objectclasses);
     $this->netConfigDNS->set_acl_category("server");
     $this->netConfigDNS->set_acl_base($this->base);
        
@@ -96,7 +97,7 @@ class servgeneric extends plugin
     }
 
     /* Do we represent a valid server? */
-    if (!$this->is_account && $this->parent == NULL){
+    if (!$this->is_account && $this->parent === NULL){
       $display= "<img alt=\"\" src=\"images/stop.png\" align=middle>&nbsp;<b>".
         _("This 'dn' has no server features.")."</b>";
       return($display);
@@ -104,7 +105,7 @@ class servgeneric extends plugin
 
     /* Check for action */
     if (isset($_POST['action']) && $this->acl_is_writeable("FAIstate")){
-      $cmd= search_config($this->config->data['TABS'], "workgeneric", "ACTIONCMD");
+      $cmd = $this->config->search("workgeneric", "ACTIONCMD",array('tabs'));
       if ($cmd == ""){
         print_red(_("No ACTIONCMD definition found in your gosa.conf"));
       } else {
@@ -223,7 +224,12 @@ class servgeneric extends plugin
 
     /* Show main page */
     $smarty->assign("fai_activated",$this->fai_activated);
-    $smarty->assign("netconfig", $this->netConfigDNS->execute());
+
+    $str = $this->netConfigDNS->execute();
+    if(is_object($this->netConfigDNS->dialog)){
+      return($str);
+    }
+    $smarty->assign("netconfig", $str);
     $smarty->assign("modes", $this->modes);
 
     return($smarty->fetch (get_template_path('server.tpl', TRUE)));
@@ -290,6 +296,11 @@ class servgeneric extends plugin
       $message[]= _("The required field 'Server name' is not set.");
     }
     
+    /* Check if given name is a valid host/dns name */
+    if(!is_dns_name($this->cn)){
+      $message[] = _("Please specify a valid name for this object.");
+    }
+
     if ($this->orig_dn != $this->dn){
       $ldap= $this->config->get_ldap_link();
       $ldap->cd ($this->base);
@@ -297,7 +308,7 @@ class servgeneric extends plugin
       if ($ldap->count() != 0){
         while ($attrs= $ldap->fetch()){
           if ($attrs['dn'] != $this->orig_dn){
-            if(!preg_match("/,ou=incoming,/",$attrs['dn']) && preg_match("/,ou=servers,ou=systems,/",$attrs['dn'])){
+            if(!preg_match("/cn=dhcp,/",$attrs['dn']) && !preg_match("/,ou=incoming,/",$attrs['dn']) && preg_match("/,ou=servers,ou=systems,/",$attrs['dn'])){
               $message[]= sprintf (_("There is already an entry '%s' in the base choosen by you"), $this->cn);
               break;
             }
@@ -360,7 +371,7 @@ class servgeneric extends plugin
     }
     show_ldap_error($ldap->get_error(), sprintf(_("Saving of system server/generic with dn '%s' failed."),$this->dn)); 
     $this->netConfigDNS->cn = $this->cn;
-    $this->netConfigDNS->save($this->dn);
+    $this->netConfigDNS->save();
 
     /* Optionally execute a command after we're done */
     if(!$this->didAction){