Code

Updated Mail Method kolab
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 16 Feb 2009 07:29:44 +0000 (07:29 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 16 Feb 2009 07:29:44 +0000 (07:29 +0000)
-KolabDeleteflag must be fed with all kolabHost entries

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13421 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/kolab/personal/mail/kolab/class_mail-methods-kolab.inc

index 59f34ef1a0daa6b9a23787ed709eae80f9f19f2e..79c91221c9008dfdbb8f461a3b7506e5d585f07f 100644 (file)
@@ -36,6 +36,11 @@ class mailMethodKolab extends mailMethodCyrus
   protected $userObjectClasses = array("kolabInetOrgPerson");
   protected $shareObjectClasses = array("kolabSharedFolder");
 
+  /* Handle account removal like a master/slave kolab setup.
+   * The kolabDeleteflag will be added for each server.
+   */
+  protected $masterSlave = TRUE;
+
   protected $acl_map = array(
       "lrsw"     => "read",
       "lrswp"    => "post",
@@ -44,7 +49,7 @@ class mailMethodKolab extends mailMethodCyrus
       "lrswipcd" => "write",
       "lrswipcda"=> "admin",
       "lrswipkxtecda"=> "full-admin",
-      " "         => "none");
+      " "         => "none"); 
   public function fixAttributesOnLoad()
   {
     mailMethodCyrus::fixAttributesOnLoad();
@@ -78,7 +83,19 @@ class mailMethodKolab extends mailMethodCyrus
     $this->parent->attrs['objectClass'] = array_merge( $this->parent->attrs['objectClass'],$ocs);
     $this->parent->attrs['objectClass'] = array_unique($this->parent->attrs['objectClass']);
     $this->parent->attrs['gosaSharedFolderTarget'] =array();
-    $this->parent->attrs['kolabDeleteFlag'] = $this->parent->gosaMailServer;
+
+
+    /* If the mail setup includes Master and Slave Kolab Server, then we have to remove the 
+     *  mailAccount from server, by adding a kolabDeleteflag for each server.
+     * */
+    if($this->masterSlave){
+      $this->parent->attrs['kolabDeleteflag'] = array();
+      foreach($this->getKolabHost() as $md){
+        $this->parent->attrs['kolabDeleteflag'][] = $md;
+      }
+    }else{
+      $this->parent->attrs['kolabDeleteflag'] = $this->parent->gosaMailServer;
+    }
     if($this->folderTypesEnabled()){
       $this->parent->attrs['kolabFolderType'] =array();
     }
@@ -233,6 +250,36 @@ class mailMethodKolab extends mailMethodCyrus
     }
     return(TRUE);
   }
+
+
+
+  /*! \brief   Returns all kolabHost entries from the k=kolab object.
+      @return  See \brief
+   */
+  public function getKolabHost()
+  {
+    $host = array();
+    $ldap = $this->config->get_ldap_link();
+    $ldap->cd($this->config->current['BASE']);
+    $ldap->search("(&(objectClass=kolab)(k=kolab)(kolabHost=*))",array("kolabHost"));
+
+    if($ldap->count() == 1){
+      $attrs = $ldap->fetch();
+      for($i=0; $i <$attrs['kolabHost']['count']; $i ++ ){
+        $host[] = $attrs['kolabHost'][$i];
+      }
+      @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "<b>Found: ".trim(implode($host,", "),", ")."</b>",
+          "Revceiving 'Mail hosts for kolab22'.");
+    }elseif($ldap->count() == 0){
+      @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "<b>No mailHost entries found. Check k=kolab and mailHost</b>",
+          "Revceiving 'Mail hosts for kolab22'.");
+    }else{
+      @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "<b>Found more than one kolab configuration object. Giving up.</b>",
+          "Revceiving 'Mail hosts for kolab22'.");
+    }
+
+    return($host);
+  }
 }