Code

Updated kolabMethod to display / set quota correct.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 31 May 2006 09:44:45 +0000 (09:44 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 31 May 2006 09:44:45 +0000 (09:44 +0000)
Allow kolab to remove quota restrictions

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

include/class_mail-methods-kolab.inc
plugins/personal/mail/class_mailAccount.inc
plugins/personal/mail/generic.tpl

index c6f3f22de7fedb7799848788f463be7da66378d3..3b5045d5f336c239c01e01d0d36dda3380db94d9 100644 (file)
@@ -50,12 +50,14 @@ class mailMethodKolab extends mailMethodCyrus
   }
 
 
-  /* Get quota and divide it by 1024, because in gosa we display in Kb
-      but we get bytes */
+  /* Get quota and divide it by 1024, because in gosa we display in MB
+      but we get Kb */
   function getQuota($folder)
   {
     $result= array('quotaUsage' => '', 'gosaMailQuota' => '');
-
+        
+    error_reporting(0);  
+  
     /* Load quota settings */
     $quota_value = @imap_get_quota($this->mbox, $folder);
     if(is_array($quota_value)) {
@@ -72,6 +74,8 @@ class mailMethodKolab extends mailMethodCyrus
       return(false);
     }
 
+    error_reporting(E_ALL); 
     return ($result);
   }
 
@@ -109,6 +113,12 @@ class mailMethodKolab extends mailMethodCyrus
   function fixAttributesOnStore(&$mailObject)
   {
     global $config;
+  
+    /* If quota is empty, remove quota restrictions by setting quota to 0 */
+    if(isset($mailObject->gosaMailQuota) && (empty($mailObject->gosaMailQuota))){
+      $mailObject->attrs['gosaMailQuota'] = 0;
+    }
+
     /* Convert attributes and objectClasses */
     foreach ($this->attribute_map as $source => $dest){
       if (isset($mailObject->attrs[$source])){
index 4adef1da1ec6ad60da8d69bd56266877358e4385..1d45d563f48fba359856d11917467b99018210b4 100644 (file)
@@ -128,7 +128,7 @@ class mailAccount extends plugin
 
           /* Update quota values */
           $quota= $method->getQuota($this->folder_prefix.$this->$id);
-          
+         
           if($quota){
             if ($quota['gosaMailQuota'] == 2147483647){
               $this->quotaUsage     = "";
@@ -138,6 +138,8 @@ class mailAccount extends plugin
               $this->gosaMailQuota  = $quota['gosaMailQuota'];
             }
           }else{
+            $this->quotaUsage     = "";
+            $this->gosaMailQuota  = "";
             print_red(sprintf(_("Can't get quota for for '%s'."),$this->folder_prefix.$this->$id));
           }
 
@@ -699,11 +701,12 @@ class mailAccount extends plugin
     /* Adapt attributes if needed */
     $method= new $this->method($this->config);
     $id= $method->uattrib;
+
     $method->fixAttributesOnStore($this);
 
-    /* Remove Mailquota if = "" */
-    if((isset($this->attrs['gosaMailQuota']))&&($this->attrs['gosaMailQuota']=="")) {
-      $this->attrs['gosaMailQuota']=array();
+    /* Remove Mailquota if = "" or "0"  */
+    if((isset($this->attrs['gosaMailQuota']))&&(!$this->attrs['gosaMailQuota'])) {
+      $this->attrs['gosaMailQuota']=0;
     }
 
     if(empty($this->attrs['gosaSpamMailbox'])){
index c467a89f5c24d598be88550786a3c36601d76d26..1e99bb707bf2cdb1d6b9eaa04fa53c6f5a0a3b38 100644 (file)
@@ -35,7 +35,7 @@
      <td><label for="gosaMailQuota">{t}Quota size{/t}</label></td>
      <td>
       <input id="gosaMailQuota" name="gosaMailQuota" size="6" align="middle" maxlength="60" {$gosaMailQuotaACL}
-               value="{$gosaMailQuota}"> KB
+               value="{$gosaMailQuota}"> MB
      </td>
     </tr>
    </table>