Code

Added delete icon to ppd list if ppd file is removeable
[gosa.git] / plugins / admin / systems / class_terminalGeneric.inc
index 7f07d2e8ea1d5fc612fecd3b35f5572d1f595a54..282693b3bd809aa222fadd9c7df6dbfc15ca854b 100644 (file)
@@ -56,9 +56,9 @@ class termgeneric extends plugin
                             "sysinfo"         => "sysinfo");
 
 
-  function termgeneric ($config, $dn= NULL)
+  function termgeneric ($config, $dn= NULL, $parent= NULL)
   {
-    plugin::plugin ($config, $dn);
+    plugin::plugin ($config, $dn, $parent);
     $this->netConfigDNS = new termDNS($this->config,$this->dn,$this->objectclasses);
     /* Read arrays */
     foreach (array("ghNetNic", "ghIdeDev", "ghScsiDev") as $val){
@@ -339,8 +339,10 @@ class termgeneric extends plugin
     }
 
     /* Save terminal path to parent since it is used by termstartup, too */
+    if(isset($this->parent->by_object['termstartup'])){
     $this->parent->by_object['termstartup']->gotoTerminalPath=
       $this->gotoTerminalPath;
+    }
   
     if(isset($_POST['termgeneric_posted'])){
       if(isset($_POST["inheritTimeServer"])){
@@ -357,10 +359,13 @@ class termgeneric extends plugin
   {
     /* Call common method to give check the hook */
     $message= plugin::check();
-    $message= array_merge($message, $this->netConfigDNS->check());
+
+    if($this->cn != "default"){
+      $message= array_merge($message, $this->netConfigDNS->check());
+    }
 
     /* Permissions for that base? */
-    $this->dn= "cn=".$this->cn."ou=terminals,ou=systems,".$this->base;
+    $this->dn= "cn=".$this->cn.",ou=terminals,ou=systems,".$this->base;
 
     $ui= get_userinfo();
     $acl= get_permissions ($this->dn, $ui->subtreeACL);
@@ -375,8 +380,16 @@ class termgeneric extends plugin
 
     if ($this->orig_dn == 'new'){
       $ldap= $this->config->get_ldap_link();
-      $ldap->cd ($this->base);
-      $ldap->search ("(&(objectClass=gotoTerminal)(cn=".$this->cn."))", array("cn"));
+      $ldap->cd ($this->config->current['BASE']);
+      /* It is possible to have a 'default' terminal on every base */
+      if($this->cn == "default"){
+        $ldap->cat($this->dn);
+      }else{
+        $ldap->search ("(&(objectClass=gotoTerminal)(cn=".$this->cn."))", array("cn"));
+      }
+  
+      /* Check if there are some other terminals found */
       if ($ldap->count() != 0){
         while ($attrs= $ldap->fetch()){
           if (preg_match ("/,ou=incoming,/", $ldap->getDN())){
@@ -403,12 +416,18 @@ class termgeneric extends plugin
   /* Save to LDAP */
   function save()
   {
+
+    /* Move object if requested */
+    if( $this->orig_dn != 'new' && $this->dn != $this->orig_dn){
+      $this->move($this->orig_dn, $this->dn);
+    }
     plugin::save();
 
     /* Strip out 'default' values */
     foreach (array("gotoTerminalPath", "gotoSwapServer", "gotoSyslogServer") as $val){
 
-      if ($this->attrs[$val] == "default"){
+      if (!isset($this->attrs[$val]) || $this->attrs[$val] == "default"){
         $this->attrs[$val]= array();
       }
     }
@@ -457,15 +476,17 @@ class termgeneric extends plugin
       $ldap->add($this->attrs);
       $this->handle_post_events("add");
     } else {
-      if ($this->orig_dn != $this->dn){
-        $this->move($this->orig_dn, $this->dn);
-      }
       $ldap->cd($this->dn);
       $this->cleanup();
       $ldap->modify ($this->attrs); 
-
       $this->handle_post_events("modify");
     }
+    
+    /* cn=default and macAddress=- indicates that this is a template */ 
+    if($this->cn == "default"){
+      $this->netConfigDNS->macAddress = "-";
+    }
+  
     $this->netConfigDNS->cn = $this->cn;
     $this->netConfigDNS->save($this->dn);
     show_ldap_error($ldap->get_error(), _("Saving terminal failed"));