Code

Fixed groupMail-getQuota to display an error message if imap_get_quota failed
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 31 May 2006 11:31:22 +0000 (11:31 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 31 May 2006 11:31:22 +0000 (11:31 +0000)
Updated this->uid via mailMethodKolab to match typical folder names like 'shared.abc@server.de',
else we can't get account quota etc.

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

include/class_mail-methods-kolab.inc
plugins/admin/groups/class_groupMail.inc

index 3b5045d5f336c239c01e01d0d36dda3380db94d9..95ba9e5ee3e60959ddc3f6f1f8530ed910c249d9 100644 (file)
@@ -55,7 +55,7 @@ class mailMethodKolab extends mailMethodCyrus
   function getQuota($folder)
   {
     $result= array('quotaUsage' => '', 'gosaMailQuota' => '');
-        
+
     error_reporting(0);  
   
     /* Load quota settings */
@@ -82,6 +82,11 @@ class mailMethodKolab extends mailMethodCyrus
 
   function fixAttributesOnLoad(&$mailObject)
   {
+    /* 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);
+
     /* Convert attributes and objectClasses */
     foreach ($this->attribute_map as $dest => $source){
       /* Hickert 11.11.05 : Alternate email addresses were saved, but not displayed again.
@@ -196,6 +201,14 @@ 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);
   
       /* Assign new acls */
       $mailObject->attrs['acl']= array();
index abde8634bbe53cc1b295d042440aa57aaaf71cda..9bd73c3dffedad7be86e6ebe76c66536e78af1ff 100644 (file)
@@ -112,10 +112,7 @@ class mailgroup extends plugin
         $method= new $this->method($this->config);
 
         if ($method->connect($this->attrs["gosaMailServer"][0])){
-
-          /*  get Quota
-           */
-          $quota= $method->getQuota($this->uid);
+        
 
           /* Maybe the entry is not saved in new style, get
              permissions from IMAP and convert them to acl attributes */
@@ -154,21 +151,30 @@ class mailgroup extends plugin
             }
 
           } // ENDE ! isset ($this->attrs['acl'])
+          
+          /* Adapt attributes if needed */
+          $method->fixAttributesOnLoad($this);
+          
+          /*  get Quota */
+          $quota= $method->getQuota($this->uid);
 
           /* Update quota values */
-          if ($quota['gosaMailQuota'] == 2147483647){
-            $this->quotaUsage= "";
-            $this->gosaMailQuota= "";
-          } else {
-            $this->quotaUsage= $quota['quotaUsage'];
-            $this->gosaMailQuota= $quota['gosaMailQuota'];
+          if(is_array($quota)){
+            if ($quota['gosaMailQuota'] == 2147483647){
+              $this->quotaUsage= "";
+              $this->gosaMailQuota= "";
+            } else {
+              $this->quotaUsage= $quota['quotaUsage'];
+              $this->gosaMailQuota= $quota['gosaMailQuota'];
+            }
+          }else{
+            $this->quotaUsage     = "";
+            $this->gosaMailQuota  = "";
+            print_red(sprintf(_("Can't get quota for for '%s'."),$this->uid));
           }
           $method->disconnect();
         }   // ENDE $method->connect($this->attrs["gosaMailServer"][0])){
 
-        /* Adapt attributes if needed */
-        $method->fixAttributesOnLoad($this);
-
       }   // ENDE gosaMailServer
 
     }   // ENDE dn != "new"
@@ -690,15 +696,7 @@ I: Only insider delivery */
     /* Save arrays */
     $this->attrs['gosaMailAlternateAddress']  = $this->gosaMailAlternateAddress;
     $this->attrs['gosaMailForwardingAddress'] = $this->gosaMailForwardingAddress;
-
-    /* Save shared folder target */
-    if(preg_match("/kolab/i",$this->mmethod)){
-      /* Kolab style */
-      $this->attrs['gosaSharedFolderTarget']= "kolab+shared.".$this->uid;
-    }else {
-      /* GOsa style */
-      $this->attrs['gosaSharedFolderTarget']= "share+".$this->uid;
-    }
+    $this->attrs['gosaSharedFolderTarget']    = "share+".$this->uid;
 
     if(preg_match("/kolab/i",$this->mmethod)){
       /* Save acl's */