Code

Updated groupMail
[gosa.git] / include / class_mail-methods-kolab.inc
index cb649748d63a6d55b436fc3e4ec3a66845200395..08280c188eae6ba4b0eb8ee4c33632ccbb6f1e2d 100644 (file)
@@ -32,6 +32,18 @@ class mailMethodKolab extends mailMethodCyrus
 
   function mailMethodKolab($config)
   {
+    /* Check if the mail account identification attribute
+       is overridden in the configuration file
+     */
+    if(isset($config->current['MAIL_ATTRIB']) && !empty($config->current['MAIL_ATTRIB'])){
+      $new_uattrib= strtolower($config->current['MAIL_ATTRIB']);
+      if(in_array($new_uattrib,array("mail","uid"))){
+        $this->uattrib = $new_uattrib;
+      }else{
+        trigger_error(sprintf("Unsupported MAIL_ATTRIB in gosa configuration specified, use 'mail' or 'uid', instead of '%s'.",            $new_uattrib));
+      }
+    }
+
     $this->config= $config->data['SERVERS']['IMAP'];
   }
 
@@ -44,55 +56,6 @@ class mailMethodKolab extends mailMethodCyrus
     return (TRUE);
   }
 
-  function deleteMailbox($folder)
-  {
-    return (TRUE);
-  }
-
-  /* return all folders of the users mailbox*/
-  function getMailboxList($folder, $uid= "")
-  {
-    global $config;
-    $result = array();
-
-    /* Get domain an mail address if uid is an mail address */
-    $domain = "";
-    if(preg_match("/@/",$folder)){
-      $domain = preg_replace("/^.*@/","",$folder);
-      $folder = preg_replace("/@.*$/","",$folder);
-    }
-
-    /* Get list of mailboxes for combo box */
-    $cfg= $this->config[$this->gosaMailServer];
-    
-    /* Create search pattern
-         (user/kekse*@domain.de
-          user.kekse*@domain.de 
-          user.kekse*  )
-       depending on given folder name) */
-    $q = $folder."*@".$domain;
-    $list = imap_listmailbox($this->mbox, $cfg["connect"], $q);
-
-    /* Create list of returned folder names */
-    if (is_array($list)){
-      foreach ($list as $val){
-
-        /* Cut domain name */
-        $val = preg_replace("/@.*$/","",$val);
-        $result[]=preg_replace ("/^.*".normalizePreg($folder)."/","INBOX", imap_utf7_decode ($val));
-      }
-    }
-
-    /* Append "INBOX" to the folder array if result is empty and request comes from user dialog */
-    if(empty($result) && !empty($uid)){
-      $result[] = "INBOX";
-    }
-
-    return ($result);
-  }
-
-
-
   /* Get quota and divide it by 1024, because in gosa we display in MB
       but we get Kb */
   function getQuota($folder)
@@ -150,6 +113,12 @@ class mailMethodKolab extends mailMethodCyrus
         $mailObject->attrs[$dest]= $mailObject->attrs[$source];
         $mailObject->$dest=        $mailObject->attrs[$source];
 
+        /* Ensure that cleanup will recognize the ampped attributes too */
+        if(isset($mailObject->saved_attributes)){
+          $mailObject->saved_attributes[$dest] = $mailObject->attrs[$source];
+          $mailObject->saved_attributes[$source] = $mailObject->attrs[$source];
+        }
+
         unset ($mailObject->$dest['count']);
         unset ($mailObject->attrs[$source]);
       }
@@ -252,13 +221,13 @@ class mailMethodKolab extends mailMethodCyrus
         }
       }
  
-      /* Save shared folder target */
-      $mailObject->attrs['gosaSharedFolderTarget']= "kolab+shared.".$mailObject->uid;
-
       /* Kolab shared folder names are like ' shared.uid@server.de ' 
         So overwrite uid to match these folder names. Else we can't read quota settings etc. 
         #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/
       $mailObject->uid = "shared.".$mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail);
+
+      /* Save shared folder target */
+      $mailObject->attrs['gosaSharedFolderTarget']= "kolab+shared.".$mailObject->cn."@".preg_replace("/^.*@/","",$mailObject->mail); 
   
       /* Assign new acls */
       $mailObject->attrs['acl']= array();
@@ -286,9 +255,25 @@ class mailMethodKolab extends mailMethodCyrus
     /* Only add kolab delete Flag in case of an user.mailAccount */
     if(!in_array("posixGroup", $mailObject->attrs['objectClass'])){
       $mailObject->attrs['kolabDeleteFlag']= preg_replace('%imap://%', '', $mailObject->gosaMailServer);
+    }else{
+      /* Kolab shared folder names are like ' shared.uid@server.de ' 
+        So overwrite uid to match these folder names. Else we can't read quota settings etc. 
+        #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/
+      $mailObject->uid = "shared.".$mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail);
+      
     }
   }
 
+
+  function deleteMailbox($folder)
+  {
+    /* Remove shared folders and skip removing users. 
+       KolabD is not able to remove shared folders yet, so we do it instead */
+    if(preg_match("/^shared/",$folder)){
+      return mailMethodCyrus::deleteMailbox($folder);
+    }
+    return (TRUE);
+  }
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: