Code

Updated DEBUG infos for default mail mehtod
[gosa.git] / gosa-plugins / mail / personal / mail / class_mail-methods.inc
index b22c042683cb4041fa0b6949cb5f98cbd2fe3e92..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; 
@@ -90,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
@@ -104,7 +107,7 @@ 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);
       }
@@ -190,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);
@@ -214,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; 
     }
   }
@@ -245,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
    */
@@ -289,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>");
     }
   }
 
@@ -351,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. 
          */
@@ -408,29 +417,9 @@ class mailMethod{
     $this->reset_error();
 
     @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, "<b>".$this->account_id."</b>" ,
-        "<b>Remove account</b> from server :".$this->MailServer);
+        "<b>MAIL: Remove account</b> from server :".$this->MailServer);
 
     return(TRUE);
-
-    /* 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);
   }
 
   
@@ -676,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("");
+  }
+
 }