Code

Added start/stop for vacations
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 26 Mar 2007 07:38:38 +0000 (07:38 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 26 Mar 2007 07:38:38 +0000 (07:38 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5878 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/personal/mail/class_mailAccount.inc
plugins/personal/mail/generic.tpl

index b5ce37d8cc857cfcb2344a3e91e0234b2b510829..da82a9423ee78652715d5221a47b99bd43a44a5e 100644 (file)
@@ -24,9 +24,8 @@ class mailAccount extends plugin
   var $method             = "mailMethod";
 
   /* CLI vars */
-  var $cli_summary        = "Manage users mail account";
-  var $cli_description    = "Some longer text\nfor help";
-  var $cli_parameters     = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+  var $gosaVacationStart                  = 0;
+  var $gosaVacationStop                   = 0;
 
   /* plugin specific values */
   var $mail                               = "";
@@ -57,7 +56,7 @@ class mailAccount extends plugin
 
   /* attribute list for save action */
   var $attributes= array("mail", "gosaMailServer", "gosaMailQuota", "gosaMailMaxSize","gosaMailForwardingAddress",
-      "gosaMailDeliveryMode", "gosaSpamSortLevel", "gosaSpamMailbox","gosaMailAlternateAddress",
+      "gosaMailDeliveryMode", "gosaSpamSortLevel", "gosaSpamMailbox","gosaMailAlternateAddress","gosaVacationStart","gosaVacationStop",
       "gosaVacationMessage", "gosaMailAlternateAddress", "gosaMailForwardingAddress");
   var $objectclasses= array("gosaMailAccount");
   var $uid;
@@ -239,7 +238,7 @@ class mailAccount extends plugin
     /* 
      * Sieve Management 
      */
-    if(isset($_POST['sieveManagement']) && !preg_match("/C/",$this->gosaMailDeliveryMode)) {
+    if(isset($_POST['sieveManagement']) && preg_match("/C/",$this->gosaMailDeliveryMode)) {
       $this->dialog = new sieveManagement($this->config,$this->dn,$this);
     }
    
@@ -261,13 +260,6 @@ class mailAccount extends plugin
     } 
 
 
-
-
-
-
-
-
-
     /* Handle account state */
     /* Do we need to flip is_account state? */
     if(isset($_POST['modify_state'])){
@@ -539,8 +531,8 @@ class mailAccount extends plugin
 
     foreach(array("gosaMailServer", "gosaMailQuota", "perms", "mail",
           "gosaMailAlternateAddress", "gosaMailForwardingAddress",
-          "gosaVacationMessage", "gosaMailDeliveryMode",
-          "gosaMailMaxSize", "gosaSpamSortLevel", "gosaSpamMailbox") as $val){
+          "gosaVacationMessage", "gosaMailDeliveryMode", "gosaVacationStart",
+          "gosaVacationStop", "gosaMailMaxSize", "gosaSpamSortLevel", "gosaSpamMailbox") as $val){
       $smarty->assign("$val", $this->$val);
     }
 
@@ -557,6 +549,11 @@ class mailAccount extends plugin
       $smarty->assign("mailACL", preg_replace("/w/","",$this->getacl("mail",$SkipWrite)));
     }
 
+    if (preg_match('/V/', $this->gosaMailDeliveryMode)){
+      $smarty->assign('rangeEnabled', "");
+    } else {
+      $smarty->assign('rangeEnabled', "disabled");
+    }
 
     if (!preg_match("/L/", $this->gosaMailDeliveryMode)) {
       $smarty->assign("only_local", "checked");
@@ -579,7 +576,43 @@ class mailAccount extends plugin
         $smarty->assign($varname, "");
       }
     }
-    
+   
+    /* Display mail account tab */
+    if($this->gosaVacationStart ==0){
+      $date= getdate(time());
+    }else{
+      $date= getdate($this->gosaVacationStart);
+    }
+    $days= array();
+    for($d= 1; $d<32; $d++){
+      $days[$d]= $d;
+    }
+    $years= array();
+    for($y= $date['year']-10; $y<$date['year']+10; $y++){
+      $years[]= $y;
+    }
+    $months= array(_("January"), _("February"), _("March"), _("April"),
+        _("May"), _("June"), _("July"), _("August"), _("September"),
+        _("October"), _("November"), _("December"));
+    $smarty->assign("start_day", $date["mday"]);
+    $smarty->assign("days", $days);
+    $smarty->assign("months", $months);
+    $smarty->assign("start_month", $date["mon"]-1);
+    $smarty->assign("years", $years);
+    $smarty->assign("start_year", $date["year"]);
+
+    if($this->gosaVacationStop ==0){
+      $date= getdate(time());
+      $date["mday"]++;
+    }else{
+      $date= getdate($this->gosaVacationStop);
+    }
+    $smarty->assign("end_day", $date["mday"]);
+    $smarty->assign("end_month", $date["mon"]-1);
+    $smarty->assign("end_year", $date["year"]);
+
+
     /* Have vacation templates? */
     $smarty->assign("template", "");
     if (count($this->vacation)){
@@ -735,6 +768,7 @@ class mailAccount extends plugin
         $this->gosaMailDeliveryMode= $tmp;
       }
     }
+
   }
 
 
@@ -767,6 +801,19 @@ class mailAccount extends plugin
 
     $this->attrs['mail'] = strtolower($this->attrs['mail']); 
 
+        /* Remove attributes - if not needed */
+    if (!preg_match('/V/', $this->gosaMailDeliveryMode)){
+      unset($this->attrs['gosaVacationStart']);
+      unset($this->attrs['gosaVacationStop']);
+    }
+
+
+    /* Remove attributes - if not needed */
+    if (!preg_match('/V/', $this->gosaMailDeliveryMode)){
+      unset($this->attrs['gosaVacationStart']);
+      unset($this->attrs['gosaVacationStop']);
+    }
+
     /* Save data to LDAP */
     $ldap->cd($this->dn);
     $this->cleanup();
@@ -875,6 +922,10 @@ class mailAccount extends plugin
       $message[]= _("You specified Spam settings, but there is no Folder specified.");
     }
 
+    if (preg_match('/V/', $this->gosaMailDeliveryMode) && $this->gosaVacationStart >= $this->gosaVacationStop){
+      $message[]= _("Time interval to show vacation message is not valid.");
+    }
+
     return ($message);
   }
 
index 238e3628d37440ce8bd93a87e63c53a7cba0f8a6..51e424fa228246ecad82c2c34f62c91af3bb00bd 100644 (file)
@@ -99,7 +99,9 @@
                        changeState('gosaSpamSortLevel');
                        changeState('gosaSpamMailbox');
                        changeState('gosaMailMaxSize');
-                       
+       
+                       changeStates();
+
                "
 
 > {t}Use custom sieve script{/t} <b>({t}disables all Mail options!{/t})</b>
 {render acl=$gosaMailDeliveryModeIACL}
    <input {if $own_script != ""} disabled {/if} id='drop_own_mails' type=checkbox name="drop_own_mails" value="1" {$drop_own_mails} title="{t}Select if you want to forward mails without getting own copies of them{/t}"> {t}No delivery to own mailbox{/t}
 {/render}
-   <br>
+
+<br>
 {render acl=$gosaMailDeliveryModeVACL}
-   <input {if $own_script != ""} disabled {/if} id='use_vacation' type=checkbox name="use_vacation" value="1" {$use_vacation} title="{t}Select to automatically response with the vacation message defined below{/t}"> {t}Activate vacation message{/t}
+ <input type=checkbox name="use_vacation" value="1" {$use_vacation} id="use_vacation" {if $own_script != ""} disabled {/if}
+    title="{t}Select to automatically response with the vacation message defined below{/t}"
+onclick="changeState('day'); changeState('month'); changeState('year'); changeState('sday'); changeState('smonth'); changeState('syear');
+"> {t}Activate vacation message{/t}
 {/render}
-  </td>
+
+   <br>
+
+    <table>
+         <tr>
+          <td>
+    {t}from{/t}
+          </td>
+          <td>
+{render acl=$gosaVacationMessageACL}
+    <select {if $own_script != ""} disabled {/if} name=day id="day" onChange="createResult(this.form,this.form.gosaVacationStart);" {$rangeEnabled}>
+        {html_options values=$days output=$days selected=$start_day}
+    </select>
+{/render}
+{render acl=$gosaVacationMessageACL}
+    <select  {if $own_script != ""} disabled {/if} name=month id="month" onChange="populate(this.form,this.form.gosaVacationStart);" {$rangeEnabled}>
+        {html_options options=$months selected=$start_month}
+    </select>
+{/render}
+{render acl=$gosaVacationMessageACL}
+    <select  {if $own_script != ""} disabled {/if} name=year id="year" onChange="populate(this.form,this.form.gosaVacationStart);" {$rangeEnabled}>
+        {html_options values=$years output=$years selected=$start_year}
+    </select>
+{/render}
+    <input type="hidden" name="gosaVacationStart" value="{$gosaVacationStart}">
+          </td>
+         </tr>
+         <tr>
+          <td>
+    {t}till{/t}
+          </td>
+          <td>
+{render acl=$gosaVacationMessageACL}
+    <select  {if $own_script != ""} disabled {/if} name=sday id="sday" onChange="createResult2(this.form,this.form.gosaVacationStop);" {$rangeEnabled}>
+        {html_options values=$days output=$days selected=$end_day}
+    </select>
+{/render}
+{render acl=$gosaVacationMessageACL}
+    <select  {if $own_script != ""} disabled {/if} name=smonth id="smonth" onChange="populate2(this.form,this.form.gosaVacationStop);" {$rangeEnabled}>
+        {html_options options=$months selected=$end_month}
+    </select>
+{/render}
+{render acl=$gosaVacationMessageACL}
+    <select {if $own_script != ""} disabled {/if}  name=syear id="syear" onChange="populate2(this.form,this.form.gosaVacationStop);" {$rangeEnabled}>
+        {html_options values=$years output=$years selected=$end_year}
+    </select>
+{/render}
+    <input type="hidden" name="gosaVacationStop" value="{$gosaVacationStop}">
+          </td>
+         </tr>
+        </table>
+
+
    <td rowspan=2 style="border-left:1px solid #A0A0A0">
    &nbsp;
   </td>
 
 <!-- Place cursor -->
 <script language="JavaScript" type="text/javascript">
-  <!-- // First input field on page
+
+       {literal}
+       function changeStates()
+       {
+
+               if(document.getElementById('use_vacation').checked){
+                       changeState('day');
+                       changeState('month');
+                       changeState('year');
+                       changeState('sday');
+                       changeState('smonth');
+                       changeState('syear');
+               }else{
+                       changeSubselectState('use_vacation','day');
+                       changeSubselectState('use_vacation','month');
+                       changeSubselectState('use_vacation','year');
+                       changeSubselectState('use_vacation','sday');
+                       changeSubselectState('use_vacation','smonth');
+                       changeSubselectState('use_vacation','syear');
+               }
+       }
+
+       {/literal}
+
+<!-- // First input field on page
   document.mainform.mail.focus();
   -->
 </script>