Code

Fixed Translation Strings.
[gosa.git] / plugins / admin / systems / class_servKolab.inc
index 4145f5525dd6e45a2e3ff96cc222b105d795b362..bb40188ccb0474a347d4b38a69f6613904983776 100644 (file)
@@ -26,9 +26,6 @@ class servkolab extends plugin {
   var $proftpd_ftp                      = "TRUE";
   var $apache_http                      = "TRUE";
   var $kolabHost                        = array();
-  var $is_in_there                      = false;
-  var $exactName                        = false;
-
   var $orig_cn                          = "";
 
   var $attributes =  array("postfix_mydomain", "postfix_mydestination", "proftpd_ftp", "k",
@@ -38,6 +35,11 @@ class servkolab extends plugin {
       "cyrus_quotawarn");
   var $objectclasses = array("top", "kolab");
 
+  /* Serverservice vars */
+  var $conflicts    = array("goImapServer","goMailServer");
+  var $DisplayName  = "Kolab mail service";
+  var $StatusFlag   = "";
+
   function servkolab($config, $dn = NULL) 
   {
     /* Setting the hostname and tell this Plugin that we are the kolab extension*/
@@ -64,38 +66,15 @@ class servkolab extends plugin {
       $this->kolabHost= $this->attrs['kolabHost'];
       unset($this->kolabHost['count']);
     }
-    $this->is_in_there           = false;
     $this->is_account            = false;
     $this->initially_was_account = false;
     foreach($this->kolabHost as $host){
-      if(preg_match("/".$this->hostname.".*/i",$host)){
+      if($this->hostname == $host){
         $this->is_account            = true;
-        $this->is_in_there           = true;
         $this->initially_was_account = true;
       }
     } 
 
-
-    /* Mhh */ 
-    if(in_array($this->hostname, $this->kolabHost)) {
-      $this->exactName=true;
-    } else {   
-      $this->exactName=false;    
-    } 
-
-    /* Parse mynetworks */
-    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="";
-    }
   }
 
 
@@ -327,26 +306,15 @@ class servkolab extends plugin {
             $tmp[] = $host;
           }
         }
+        $this->kolabHost = $tmp;
       }
-      $this->kolabHost = $tmp;
     }
-    
+
     /* Add ourselves to the list of kolabHost's if needed */
-    if (!in_array($this->cn,$this->kolabHost)){
+    if (!in_array_ics($this->cn,$this->kolabHost)){
       $this->kolabHost[]= $this->cn;
     }
 
-    /* Create mynetworks array by splitting the string with ; */
-    $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();
 
@@ -370,10 +338,6 @@ 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);
     $this->cleanup();;
@@ -389,6 +353,69 @@ class servkolab extends plugin {
       $this->handle_post_events("add");
     }
   }
+
+
+  function getListEntry()
+  {
+    $this->updateStatusState();
+    $flag = $this->StatusFlag;
+    if(empty($flag)){
+      $fields['Status']       = "";
+    }else{
+      $fields['Status']       = $this->$flag;
+    }
+    $fields['Message']      = _("Kolab mail service");
+    $fields['AllowStart']   = true;
+    $fields['AllowStop']    = true;
+    $fields['AllowRestart'] = true;
+    $fields['AllowRemove']  = true;
+    $fields['AllowEdit']    = true;
+    return($fields);
+  }
+
+    /* Directly save new status flag */
+  function setStatus($value)
+  { 
+    return;
+  
+    if($value == "none") return;
+    if(!$this->initially_was_account) return;
+    $ldap = $this->config->get_ldap_link();
+    $ldap->cd($this->dn);
+    $ldap->cat($this->dn,array("objectClass"));
+    if($ldap->count()){
+
+      $tmp = $ldap->fetch();
+      for($i = 0; $i < $tmp['objectClass']['count']; $i ++){
+        $attrs['objectClass'][] = $tmp['objectClass'][$i];
+      }
+      $flag = $this->StatusFlag;
+      $attrs[$flag] = $value;
+      $this->$flag = $value;
+      $ldap->modify($attrs);
+      show_ldap_error($ldap->get_error());
+      $this->action_hook();
+    }
+  }
+
+
+  /* Get updates for status flag */
+  function updateStatusState()
+  {
+    if(empty($this->StatusFlag)) return;
+
+    $attrs = array();
+    $flag = $this->StatusFlag;
+    $ldap = $this->config->get_ldap_link();
+    $ldap->cd($this->cn);
+    $ldap->cat($this->dn,array($flag));
+    if($ldap->count()){
+      $attrs = $ldap->fetch();
+    }
+    if(isset($attrs[$flag][0])){
+      $this->$flag = $attrs[$flag][0];
+    }
+  }
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: