Code

Fixed undefined index in sieve authentification method detection
[gosa.git] / gosa-plugins / mail / personal / mail / class_mailAccount.inc
index d346f242aa82923661de7e7e04f65501cc461e34..34c66cb5211b552c2ee3d13d4138e2429ccc9455 100644 (file)
@@ -68,6 +68,8 @@ class mailAccount extends plugin
   var $gosaSpamMailbox                    = "";
 
   /* The methods defaults */
+  var $quotaUsage     = -1; // Means unknown
+
   var $mailMethod      = NULL;
   var $MailDomain      = "";
   var $sieveManagementUsed = FALSE;
@@ -121,9 +123,9 @@ class mailAccount extends plugin
      */
     $this->initially_was_account = $this->is_account;
 
-    /* Initialize vacation settings 
+    /* Initialize vacation settings, if enabled.
      */   
-    if(empty($this->gosaVacationStart)){
+    if(empty($this->gosaVacationStart) && $this->mailMethod->vacationRangeEnabled()){
       $this->gosaVacationStart = time();
       $this->gosaVacationStop = time();
     }
@@ -140,6 +142,7 @@ class mailAccount extends plugin
 
         /* Read quota */
         $this->gosaMailQuota = $this->mailMethod->getQuota($this->gosaMailQuota);
+        $this->quotaUsage    = $this->mailMethod->getQuotaUsage($this->quotaUsage);
         if($this->mailMethod->is_error()){
           msg_dialog::display(_("Mail error"), sprintf(_("Cannot read quota settings: %s"), 
                 $this->mailMethod->get_error()), ERROR_DIALOG);
@@ -392,12 +395,10 @@ class mailAccount extends plugin
       $smarty->assign($attr,$this->$attr);
     }
     $smarty->assign("quotaEnabled", $this->mailMethod->quotaEnabled());
-    if($this->mailMethod->is_connected()){
-      $smarty->assign("quotaUsage",   $this->mailMethod->getQuotaUsage());
-    }else{
-      $smarty->assign("quotaUsage",   _("Unknown"));
+    if($this->mailMethod->quotaEnabled()){
+      $smarty->assign("quotaUsage",   mailMethod::quota_to_image($this->quotaUsage,$this->gosaMailQuota));
+      $smarty->assign("gosaMailQuota",$this->gosaMailQuota);
     }
-    $smarty->assign("gosaMailQuota",$this->gosaMailQuota);
     $smarty->assign("domainSelectionEnabled", $this->mailMethod->domainSelectionEnabled());
     $smarty->assign("MailDomains", $this->mailDomainParts);
     $smarty->assign("MailDomain" , $this->mailDomainPart);
@@ -405,8 +406,6 @@ class mailAccount extends plugin
     $smarty->assign("allowSieveManagement", $this->mailMethod->allowSieveManagement());
     $smarty->assign("own_script",  $this->sieveManagementUsed);
 
-    print_a($this->multi_boxes);
-
     /* _Multiple users vars_ */
     foreach($this->attributes as $attr){
       $u_attr = "use_".$attr;
@@ -491,7 +490,6 @@ class mailAccount extends plugin
       $smarty->assign("months", $months);
       $smarty->assign("years", $years);
       $smarty->assign("days", $days);
-
     }
 
     /* fill filter settings 
@@ -598,6 +596,9 @@ class mailAccount extends plugin
           $this->is_modified= TRUE;
         }
         $this->gosaMailDeliveryMode= $tmp;
+
+        /* Get start/stop values for vacation scope of application
+         */
         if($this->mailMethod->vacationRangeEnabled()){
           if($this->acl_is_writeable("gosaVacationMessage") && preg_match("/V/",$this->gosaMailDeliveryMode)){
             if(isset($_POST['gosaVacationStart'])){
@@ -740,6 +741,24 @@ class mailAccount extends plugin
       $attrs  = $obj->attributes;
     }
     if($obj){
+
+      /* Replace vacation start and end time */
+      if($this->mailMethod->vacationRangeEnabled()){
+        if(preg_match("/%start/",$contents)){
+          $contents = preg_replace("/%start/",date("d.m.Y",$this->gosaVacationStart),$contents);
+        }
+        if(preg_match("/%end/",$contents)){
+          $contents = preg_replace("/%end/",date("d.m.Y",$this->gosaVacationStop),$contents);
+        }
+      }else{
+        if(preg_match("/%start/",$contents)){
+          $contents = preg_replace("/%start/", _("unknown"),$contents);
+        }
+        if(preg_match("/%end/",$contents)){
+          $contents = preg_replace("/%end/", _("unknown"), $contents);
+        }
+      }
+
       foreach ($attrs as $val){
         if(preg_match("/dateOfBirth/",$val)){
           if($obj->use_dob){
@@ -750,13 +769,6 @@ class mailAccount extends plugin
               $obj->$val, $contents);
         }
 
-        /* Replace vacation start and end time */
-        if(preg_match("/%start/",$contents)){
-          $contents = preg_replace("/%start/",date("d.m.Y",$this->gosaVacationStart),$contents);
-        }
-        if(preg_match("/%end/",$contents)){
-          $contents = preg_replace("/%end/",date("d.m.Y",$this->gosaVacationStop),$contents);
-        }
       }
     }
     $contents = ltrim(preg_replace("/^DESC:.*$/m","",$contents),"\n ");
@@ -1007,9 +1019,9 @@ class mailAccount extends plugin
             }
           }
         }else{
-         echo "Check sieve management here";
           @DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, 
               "User uses an own sieve script, skipping sieve update.".$str."</b>","");
+          $this->sieve_management->save();
         }
       }
     }
@@ -1232,9 +1244,7 @@ class mailAccount extends plugin
     $ret['flag_add'] = $flag_add;
     $ret['flag_remove'] = $flag_remove;
 
-    echo "1";
     if($this->mailMethod->vacationRangeEnabled()){
-      echo "2";
       if(in_array("V",$flag_add)){
         $ret['gosaVacationStart'] =  $this->gosaVacationStart = $_POST['gosaVacationStart'];
         $ret['gosaVacationStop'] =  $this->gosaVacationStop = $_POST['gosaVacationStop'];
@@ -1276,7 +1286,7 @@ class mailAccount extends plugin
       $message[]= msgPool::required(_("Spam folder"));
     }
 
-    if (  in_array("use_vacation",$this->multi_boxes) &&
+    if ($this->mailMethod->vacationRangeEnabled() && in_array("use_vacation",$this->multi_boxes) &&
         preg_match('/V/', $this->gosaMailDeliveryMode) && $this->gosaVacationStart > $this->gosaVacationStop){
       $message[]= msgPool::invalid(_("Vacation interval"));
     }