Code

Updated edit windows, 100% width ; size = 12
[gosa.git] / plugins / admin / systems / class_servKolab.inc
index 65d5a147e34a2d47cca869279177c1e4c92b6003..434ffa93f67ec5d9c0cfb13c768667921142b4b0 100644 (file)
@@ -26,7 +26,8 @@ class servkolab extends plugin {
   var $proftpd_ftp                      = "TRUE";
   var $apache_http                      = "TRUE";
   var $kolabHost                        = array();
-  
+  var $is_in_there                      = false;
+  var $exactName                        = false;
   var $attributes =  array("postfix_mydomain", "postfix_mydestination", "proftpd_ftp", "k",
         "postfix_mynetworks", "postfix_enable_virus_scan", "postfix_relayhost", "apache_http",
         "postfix_allow_unauthenticated", "cyrus_admins", "cyrus_imap","kolabFreeBusyFuture",
@@ -60,16 +61,42 @@ class servkolab extends plugin {
       $this->kolabHost= $this->attrs['kolabHost'];
       unset($this->kolabHost['count']);
     }
+  
+
+    $this->is_in_there=false;
+    $this->is_account=false;
+    foreach($this->kolabHost as $host){
+      if(preg_match("/".$this->hostname.".*/i",$host)){
+        $this->is_account=true;
+        $this->is_in_there=true;
+      }
+    } 
+  
     if(in_array($this->hostname, $this->kolabHost)) {
-      $this->is_account=true;
+      $this->exactName=true;
     } else {   
-      $this->is_account=false;    
+      $this->exactName=false;    
     } 
+    if(isset($this->attrs['postfix-mynetworks'])){
+      if(is_array($this->attrs['postfix-mynetworks'])){  
+        unset($this->attrs['postfix-mynetworks']['count']);
+        $tmp="";
+        foreach($this->attrs['postfix-mynetworks'] as $tm){
+          $tmp.=$tm.";";
+        }
+        $this->postfix_mynetworks = $tmp;
+      }
+    }else{
+      $this->postfix_mynetworks="";
+    }
   }
 
 
   function execute() 
   {
+       /* Call parent execute */
+       plugin::execute();
+
     /* Fill templating stuff */
     $smarty = get_smarty();
     $display = "";
@@ -135,6 +162,10 @@ class servkolab extends plugin {
     $ldap= $this->config->get_ldap_link();
     $this->dn = "k=kolab,".$this->config->current['BASE'];
 
+    if (count($this->kolabHost) == 0){
+      return;
+    }
+
     /* Are we alone? Remove complete entry... */
     if (count($this->kolabHost) == 1){
 
@@ -231,9 +262,22 @@ class servkolab extends plugin {
     }
 
     /* Add ourselves to the list of kolabHost's if needed */
-    if (!in_array($this->cn, $this->kolabHost)){
+    if ((!$this->is_in_there)){
       $this->kolabHost[]= $this->cn;
     }
+    
+  
+    $tmp = split(";",$this->postfix_mynetworks);
+    $this->postfix_mynetworks = array();
+    foreach($tmp as $tm){
+      trim($tm);
+      if(!empty($tm)){
+        $this->postfix_mynetworks[]=$tm;
+      }
+    }
+  
+    $this->attrs['postfix_mynetworks']=$this->postfix_mynetworks;
 
     /* Call parents save to prepare $this->attrs */
     plugin::save();
@@ -258,6 +302,10 @@ class servkolab extends plugin {
 
     /* Add kolab hosts */
     $this->attrs['kolabHost']= $this->kolabHost;
+  
+    if(($this->is_in_there)&&(!$this->exactName)){
+      unset($this->attrs['kolabHost']);
+    }
 
     /* Perform LDAP action */
     $ldap->cd($this->dn);