Code

Updated DEBUG infos for default mail mehtod
[gosa.git] / gosa-plugins / mail / personal / mail / class_mail-methods.inc
index 3d5698a947041a7f81bbc4530ff7bf6ba5d8fa8d..768515c52deed79fe9399d1bf37230367921634c 100644 (file)
@@ -4,7 +4,10 @@
 class mailMethod{
 
   /* Allow modification of account_ids for existing mail accounts */
-  protected $modifyableMail = TRUE;
+  protected $modifyableMail   = TRUE;
+
+  /* Allow modification of the mail server attribute existing mail accounts */
+  protected $modifyableServer = TRUE;
 
   /* Enforces same value for 'mail' as used for 'cn' */
   protected $mailEqualsCN   = FALSE; 
@@ -43,6 +46,17 @@ class mailMethod{
   protected $error              = "";
   protected $parent             = NULL;   
   protected $MailServer         = "";
+
+  protected $acl_map = array(
+      "lrsw"     => "read",
+      "lrswp"    => "post",
+      "p"        => "external post",
+      "lrswip"   => "append",
+      "lrswipcd" => "write",
+      "lrswipcda"=> "admin",
+      " "         => "none");
+
+  protected $acl_mapping = array();
  
 
   /*! \brief  Constructs the mail class 
@@ -79,9 +93,9 @@ class mailMethod{
      */
     if ($this->config->get_cfg_value("cyrusUseSlashes") == "true"){
       $this->cyrusUseSlashes = TRUE;
-      @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "cyrusUseSlashes: <b>Enabled</b>","");
+      @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "","<b>MAIL:</b> cyrusUseSlashes: <b>Enabled</b>");
     }else{
-      @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "cyrusUseSlashes: <b>Disabled</b>","");
+      @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "","<b>MAIL:</b> cyrusUseSlashes: <b>Disabled</b>");
     }
 
     /* Check if the mail account identification attribute
@@ -93,11 +107,17 @@ class mailMethod{
         $this->uattrib = $new_uattrib;
       }else{
         @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "<b>".$new_uattrib."</b>",
-            "Unsupported 'mailAttribute' in gosa configuration specified");
+          "<b>MAIL:</b> Unsupported 'mailAttribute' in gosa configuration specified");
         msg_dialog::display(_("Configuration error"), 
             sprintf(_("The configured mail attribute '%s' is unsupported!"), $new_uattrib), ERROR_DIALOG);
       }
     }
+
+    /* Create ACL map */
+    foreach($this->acl_map as $acl => $name){
+      $this->acl_mapping[$acl] = _($name);
+    }
+
     $this->build_account_id();
     $this->initial_account_id = $this->account_id;
   }
@@ -173,8 +193,8 @@ class mailMethod{
   public function connect()
   {
     $this->reset_error();
-    @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,"<b>Connect method</b>: ".get_class($this),"");
-    @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,"<b>Current server</b>: ".$this->MailServer,"");
+    @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,"","<b>MAIL: Connect method</b>: ".get_class($this));
+    @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,"","<b>MAIL: Current server</b>: ".$this->MailServer);
  
     $this->connected = TRUE;
     return(TRUE);
@@ -197,7 +217,7 @@ class mailMethod{
   {
     $this->reset_error();
     if($this->is_connected()){
-      @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,"<b>Disconnect method</b>: ".get_class($this),"");
+      @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,"","<b>MAIL: Disconnect method</b>: ".get_class($this));
       $this->connected =FALSE; 
     }
   }
@@ -228,6 +248,12 @@ class mailMethod{
   }
 
 
+  public function isModifyableServer()
+  {
+    return($this->modifyableServer);
+  }
+
+
   /*! \brief  Returns TRUE if the action caused an error.
       @return Boolean TRUE on error else FALSE
    */
@@ -272,7 +298,7 @@ class mailMethod{
 
     if($this->account_id != $str){
       $this->account_id = $str;
-      @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "accountID generated: <b>".$str."</b>","");
+      @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,"", "<b>MAIL:</b> AccountID generated: <b>".$str."</b>");
     }
   }
 
@@ -334,13 +360,13 @@ class mailMethod{
       $method= $this->config->get_cfg_value("mailmethod");
       $cls = get_correct_class_name("mailMethod$method");
       if(isset($methods[$cls])){
-        @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "Selected mailMethod: <b>".$cls."</b>","");
+        @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__,"", "<b>MAIL:</b> Selected mailMethod: <b>".$cls."</b>");
         $tmp = new $cls($this->config,$this->parent,$this->type);
         $tmp->init();
         return($tmp);
       }else{
-        @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "Invalid mailMethod defined <b>".$cls.
-            "</b> falling back to <b>".get_class($this)."</b>","");
+        @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "","<b>MAIL: Invalid mailMethod defined: <b>".$cls.
+            "</b> falling back to <b>".get_class($this)."</b>");
 
         /* Print out configuration errors directly, we can't catch them everywhere. 
          */
@@ -391,28 +417,8 @@ class mailMethod{
     $this->reset_error();
 
     @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "<b>".$this->account_id."</b>" ,
-        "<b>Remove account</b> from server :".$this->MailServer);
-
-    return(TRUE);
+        "<b>MAIL: Remove account</b> from server :".$this->MailServer);
 
-    /* No imap actions here, just updated shared folder membership 
-     */
-    $ldap = $this->config->get_ldap_link();
-    $ldap->cd($this->config->current['BASE']);
-    $ldap->search("(&(objectClass=posixGroup)(objectClass=gosaMailAccount)(memberUid=".$account."))",array('dn','cn'));
-    if(class_exists("grouptabs")){
-      while($attrs = $ldap->fetch()){
-        $tmp = new grouptabs($this->config, $this->config->data['TABS']['GROUPTABS'], $attrs['dn']);
-        if(isset($tmp->by_object['mailgroup'])){
-          $tmp->by_object['mailgroup']->members= $tmp->by_object['group']->memberUid;
-          if(!$this->is_account){
-            $tmp->by_object['mailgroup']->removeUserAcl($account);
-            $tmp->by_object['mailgroup']->removeUserAcl($this->mail);
-          }
-          $tmp->by_object['mailgroup']->save();
-        }
-      }
-    }
     return(TRUE);
   }
 
@@ -591,13 +597,8 @@ class mailMethod{
   public function getAvailableFolderTypes()
   {
     $ret = array();
-    $ret['CAT']['mail'] = _("Mail"); 
-    $ret['CAT']['peter']= _("User"); 
-    $ret['SUB_CAT']['mail']['a'] = "a";
-    $ret['SUB_CAT']['mail']['b'] = "b";
-    $ret['SUB_CAT']['peter']['tt'] = "tt";
-    $ret['SUB_CAT']['peter']['dd'] = "dd";
-    $ret['SUB_CAT']['peter']['did'] = "did";
+    $ret['CAT'][''] = _("None"); 
+    $ret['SUB_CAT'][''][''] = _("None");
     return($ret);
   }
 
@@ -608,12 +609,7 @@ class mailMethod{
    */
   public function getFolderType($default)
   {
-    if($this->enableFolderTypes && $this->parent->attrs['kolabFolderType'][0]){
-      list($cat,$sub) = split("\.",$this->parent->attrs['kolabFolderType'][0]);
-      return(array("CAT" => $cat, "SUB_CAT" => $sub));
-    }else{
-      return($default);
-    }
+    return($default);
   }
 
  
@@ -623,10 +619,7 @@ class mailMethod{
    */
   public function setFolderType($type)
   {
-    $ldap = $this->config->get_ldap_link();
-    $ldap->cd ($this->parent->dn);
-    $ldap->modify(array("kolabFolderType" => $type['CAT'].".".$type['SUB_CAT']));
-    echo "Move me to KOLAB";
+    return(TRUE) ;   
   }
 
 
@@ -634,6 +627,15 @@ class mailMethod{
    */
   public function  getFolderACLs($folder_acls)
   {
+    /* Merge given ACL with acl mapping 
+       This ensures that no ACL will accidentally overwritten by gosa.
+     */
+    foreach($folder_acls as $user => $acl){
+      if(!isset($this->acl_mapping[$acl])){
+        $this->acl_mapping[$acl] = $acl;
+      }
+    }
+
     return($folder_acls);
   }
 
@@ -651,14 +653,7 @@ class mailMethod{
   */
   public function getAclTypes()
   {
-    $acls["lrsw"]     = _("read");
-    $acls["lrswp"]    = _("post");
-    $acls["p"]        = _("external post");
-    $acls["lrswip"]   = _("append");
-    $acls["lrswipcd"] = _("write");
-    $acls["lrswipcda"]= _("admin");
-    $acls[" "]= _("none");
-    return($acls);
+    return( $this->acl_mapping);
   }
 
   public function folderTypesEnabled()
@@ -670,6 +665,24 @@ class mailMethod{
   {
     return(TRUE);
   }
+
+
+  /*! \brief  Returns the configured mailMethod
+      @return String  the configured mail method or ""
+   */
+  static public function get_current_method($config)
+  {
+    global $class_mapping;
+    $method= $config->get_cfg_value("mailmethod");
+    $cls = get_correct_class_name("mailMethod$method");
+    foreach($class_mapping as $class => $path){
+      if($class == $cls){
+        return($class);
+      }
+    }
+    return("");
+  }
+
 }