Code

Updated samba3 plugin to use the datepicker
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 2 Oct 2009 12:25:19 +0000 (12:25 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 2 Oct 2009 12:25:19 +0000 (12:25 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14478 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/samba/personal/samba/class_sambaAccount.inc
gosa-plugins/samba/personal/samba/samba3.tpl

index 58b94b965c6b6138b91393874b0c46657d879367..3031af3b9d32caffc2040bc2a1e8e0508d7e59a8 100644 (file)
@@ -196,6 +196,11 @@ class sambaAccount extends plugin
 
     /* Save initial account state */
     $this->initially_was_account= $this->is_account;
+
+    /* Convert kickoff */
+    #TODO: use date format
+    $this->sambaKickoffTime= $this->sambaKickoffTime == 0?"":date('d.m.Y', $this->sambaKickoffTime);
+    $this->sambaPwdMustChange= $this->sambaPwdMustChange == 2147483647?"":date('d.m.Y', $this->sambaPwdMustChange);
   }
 
   function execute()
@@ -278,6 +283,7 @@ class sambaAccount extends plugin
 
     /* Prepare templating */
     $smarty= get_smarty();
+    $smarty->assign("usePrototype", "true");
 
     $tmp = $this->plInfo();
     foreach($tmp['plProvidedAcls'] as $var => $rest){
@@ -288,12 +294,6 @@ class sambaAccount extends plugin
       $smarty->assign("sambaLogonHoursACL","");
     }
 
-    if ($this->sambaPwdMustChange=="0"){
-      $date= getdate();
-    } else {
-      $date= getdate($this->sambaPwdMustChange);
-    }
-
     if ($this->sambaLogonTime=="2147483647" || $this->sambaLogonTime=="0"){
       $sambaLogonTime_date= getdate();
     } else {
@@ -306,12 +306,6 @@ class sambaAccount extends plugin
       $sambaLogoffTime_date= getdate($this->sambaLogoffTime);
     }
     
-    if ($this->sambaKickoffTime=="2147483647" || $this->sambaKickoffTime=="0"){
-      $sambaKickoffTime_date= getdate();
-    } else {
-      $sambaKickoffTime_date= getdate($this->sambaKickoffTime);
-    }
-
     /* Remove user workstations? */
     if (isset($_POST["delete_ws"]) && isset($_POST['workstation_list'])){
 
@@ -436,72 +430,6 @@ class sambaAccount extends plugin
       return ($display);
     }
 
-    /* Fill calendar */
-    $days= array();
-    for($d= 1; $d<32; $d++){
-      $days[]= $d;
-    }
-    $years= array();
-    for($y= $date['year']-4; $y<$date['year']+4; $y++){
-      $years[]= $y;
-    }
-    $months= msgPool::months();
-    $smarty->assign("day", $date["mday"]);
-    $smarty->assign("days", $days);
-    $smarty->assign("months", $months);
-    $smarty->assign("month", $date["mon"]-1);
-    $smarty->assign("years", $years);
-    $smarty->assign("year", $date["year"]);
-    
-    $sambaLogonTime_days= array();
-    for($d= 1; $d<32; $d++){
-      $sambaLogonTime_days[]= $d;
-    }
-    $sambaLogonTime_years= array();
-    for($y= $date['year']-4; $y<$date['year']+4; $y++){
-      $sambaLogonTime_years[]= $y;
-    }
-    $sambaLogonTime_months= msgPool::months();
-    $smarty->assign("sambaLogonTime_day", $sambaLogonTime_date["mday"]);
-    $smarty->assign("sambaLogonTime_days", $sambaLogonTime_days);
-    $smarty->assign("sambaLogonTime_months", $sambaLogonTime_months);
-    $smarty->assign("sambaLogonTime_month", $sambaLogonTime_date["mon"]-1);
-    $smarty->assign("sambaLogonTime_years", $sambaLogonTime_years);
-    $smarty->assign("sambaLogonTime_year", $sambaLogonTime_date["year"]);
-    
-    $sambaLogoffTime_days= array();
-    for($d= 1; $d<32; $d++){
-      $sambaLogoffTime_days[]= $d;
-    }
-    $sambaLogoffTime_years= array();
-    for($y= $date['year']-4; $y<$date['year']+4; $y++){
-      $sambaLogoffTime_years[]= $y;
-    }
-    $sambaLogoffTime_months= msgPool::months();
-    $smarty->assign("sambaLogoffTime_day", $sambaLogoffTime_date["mday"]);
-    $smarty->assign("sambaLogoffTime_days", $sambaLogoffTime_days);
-    $smarty->assign("sambaLogoffTime_months", $sambaLogoffTime_months);
-    $smarty->assign("sambaLogoffTime_month", $sambaLogoffTime_date["mon"]-1);
-    $smarty->assign("sambaLogoffTime_years", $sambaLogoffTime_years);
-    $smarty->assign("sambaLogoffTime_year", $sambaLogoffTime_date["year"]);
-    
-    $sambaKickoffTime_days= array();
-    for($d= 1; $d<32; $d++){
-      $sambaKickoffTime_days[]= $d;
-    }
-    $sambaKickoffTime_years= array();
-    for($y= $date['year']-4; $y<$date['year']+4; $y++){
-      $sambaKickoffTime_years[]= $y;
-    }
-    $sambaKickoffTime_months= msgPool::months();
-    //$smarty->assign("sambaKickoffTime_day", $sambaKickoffTime_date["mday"]-1);
-    $smarty->assign("sambaKickoffTime_day", $sambaKickoffTime_date["mday"]); // hickert
-    $smarty->assign("sambaKickoffTime_days", $sambaKickoffTime_days);
-    $smarty->assign("sambaKickoffTime_months", $sambaKickoffTime_months);
-    $smarty->assign("sambaKickoffTime_month", $sambaKickoffTime_date["mon"]-1);
-    $smarty->assign("sambaKickoffTime_years", $sambaKickoffTime_years);
-    $smarty->assign("sambaKickoffTime_year", $sambaKickoffTime_date["year"]);
-     
     /* Fill boxes */
     if ($this->samba3){
       $domains= array();
@@ -823,9 +751,13 @@ class sambaAccount extends plugin
     }
     if($this->password_expires){
       $sambaPwdMustChange = $this->sambaPwdMustChange;
+    } else {
+      $sambaPwdMustChange= date('d.m.Y', $sambaPwdMustChange);
     }
     if($this->kickoff_time_set){
       $sambaKickoffTime = $this->sambaKickoffTime;
+    } else {
+      $sambaKickoffTime= date('d.m.Y', $sambaKickoffTime);
     }
     $sambaPwdCanChange = $this->sambaPwdCanChange;
 
@@ -947,16 +879,12 @@ class sambaAccount extends plugin
      */
     if($sambaKickoffTime == "unset" || empty($sambaKickoffTime)){
       $sambaKickoffTime = "<i>("._("unset").")</i>";
-    }else{
-      $sambaKickoffTime = date("d.m.Y H:i:s",$sambaKickoffTime);
     }
 
     /* sambaPwdMustChange: Timestamp of when the password will expire
      */
     if($sambaPwdMustChange == "unset" || empty($sambaPwdMustChange)){
       $sambaPwdMustChange = "<i>("._("unset").")</i>";
-    }else{
-      $sambaPwdMustChange = date("d.m.Y H:i:s",$sambaPwdMustChange);
     }
 
     /* sambaPwdCanChange: Timestamp of when the user is allowed to update the password
@@ -1351,7 +1279,13 @@ class sambaAccount extends plugin
 
       /* Password expiery */
       if ($this->password_expires == "1"){
-        $this->attrs['sambaPwdMustChange']= $this->sambaPwdMustChange;
+        #TODO: check for date format
+        if ($this->attrs['sambaPwdMustChange'] == ""){
+          $this->attrs['sambaPwdMustChange']= 0;
+        } else {
+          list($day, $month, $year)= split('\.', $this->sambaPwdMustChange);
+          $this->attrs['sambaPwdMustChange']= mktime(0,0,0,$month, $day, $year);
+        }
       } else {
         $this->attrs['sambaPwdMustChange']= array();
       }
@@ -1373,9 +1307,14 @@ class sambaAccount extends plugin
         $this->attrs['sambaLogoffTime']= array();
       }
       if ($this->kickoff_time_set == "1"){
-        # Add one day in unixtime format to be compatible with usrmgr
-        //$this->attrs['sambaKickoffTime']= $this->sambaKickoffTime + 86400; 
-        $this->attrs['sambaKickoffTime']= $this->sambaKickoffTime; //hickert 
+        /* Adapt values to be timestamps */
+        #TODO: check for date format
+        if ($this->attrs['sambaKickoffTime'] == ""){
+          $this->attrs['sambaKickoffTime']= 2147483647;
+        } else {
+          list($day, $month, $year)= split('\.', $this->sambaKickoffTime);
+          $this->attrs['sambaKickoffTime']= mktime(0,0,0,$month, $day, $year);
+        }
       } else {
         $this->attrs['sambaKickoffTime']= array();
       }
index a1cb6f9c71afd9d89ea359943e38bfbc497ffa58..abbdb97b85a6216ab7f15a4f2bd61ab4a1f7ca7a 100644 (file)
      </td>
     </tr>
     <tr>
-     <td  colspan=2 style="width:50%; vertical-align:top;">
+     <td colspan=2 style="vertical-align:top;">
       {render acl=$sambaPwdCanChangeACL  checkbox=$multiple_support checked=$use_allow_pwchange}
        <input id="allow_pwchange" type=checkbox name="allow_pwchange" value="1" {$flagsP} class="center">
       {/render}
       {/render}
       <label for="password_expires">{t}Password expires on{/t}</label>
      </td>
-     <td>
-      {render acl=$sambaPwdMustChangeACL}
-      <select name=day onChange="createResult(this.form,this.form.sambaPwdMustChange); document.mainform.submit();">
-       {html_options values=$days output=$days selected=$day}
-      </select>
-      {/render}
-      {render acl=$sambaPwdMustChangeACL}
-      <select name=month onChange="populate(this.form,this.form.sambaPwdMustChange); document.mainform.submit();">
-       {html_options options=$months selected=$month}
-      </select>
-      {/render}
+     <td style='width:55%'>
       {render acl=$sambaPwdMustChangeACL}
-      <select name=year onChange="populate(this.form,this.form.sambaPwdMustChange); document.mainform.submit();">
-       {html_options values=$years output=$years selected=$year}
-      </select>
+        <input type="text" id="sambaPwdMustChange" name="sambaPwdMustChange" class="date" style='width:100px' value="{$sambaPwdMustChange}">
+        {if $sambaPwdMustChangeACL|regex_replace:"/[cdmr]/":"" == "w"}
+        <script type="text/javascript">
+          {literal}
+          var datepicker  = new DatePicker({ relative : 'sambaPwdMustChange', language : '{/literal}{$lang}{literal}', keepFieldEmpty : true, enableCloseEffect : false, enableShowEffect : false });
+          {/literal}
+        </script>
+        {/if}
       {/render}
      </td>
     </tr>
         </td>
      <td>
       {render acl=$sambaKickoffTimeACL}
-       <select name=sambaKickoffTime_day onChange="createResult_sambaKickoffTime(this.form,this.form.sambaKickoffTime);">
-        {html_options values=$sambaKickoffTime_days output=$sambaKickoffTime_days selected=$sambaKickoffTime_day}
-       </select>
-      {/render}
-      {render acl=$sambaKickoffTimeACL}
-       <select name=sambaKickoffTime_month onChange="populate_sambaKickoffTime(this.form,this.form.sambaKickoffTime);">
-        {html_options options=$sambaKickoffTime_months output=$sambaKickoffTime_months selected=$sambaKickoffTime_month}
-       </select>
+        <input type="text" id="sambaKickoffTime" name="sambaKickoffTime" class="date" style='width:100px' value="{$sambaKickoffTime}">
+        {if $sambaKickoffTimeACL|regex_replace:"/[cdmr]/":"" == "w"}
+        <script type="text/javascript">
+          {literal}
+          var datepicker2 = new DatePicker({ relative : 'sambaKickoffTime', language : '{/literal}{$lang}{literal}', keepFieldEmpty : true, enableCloseEffect : false, enableShowEffect : false });
+          {/literal}
+        </script>
+        {/if}
       {/render}
-      {render acl=$sambaKickoffTimeACL}
-       <select name=sambaKickoffTime_year onChange="populate_sambaKickoffTime(this.form,this.form.sambaKickoffTime);">
-        {html_options values=$sambaKickoffTime_years output=$sambaKickoffTime_years selected=$sambaKickoffTime_year}
-       </select>
-      {/render}
-      <input type="hidden" name="sambaPwdMustChange" value="{$sambaPwdMustChange}">
-      <input type="hidden" name="sambaPwdCanChange" value="{$sambaPwdMustChange}">
-      <input type="hidden" name="sambaKickoffTime" value="{$sambaKickoffTime}">
      </td>
     </tr>
     <tr>
 </table>
 
 <input type="hidden" name="sambaTab" value="sambaTab">
-
-<!-- Place cursor -->
-<script language="JavaScript" type="text/javascript">
-  <!-- 
-  // Populate expiery dialog
-  populate(document.mainform,document.mainform.sambaPwdMustChange);
-
-  // Populate samba Time dialogs
-  populate_sambaLogonTime(document.mainform,document.mainform.sambaLogonTime);
-  populate_sambaLogoffTime(document.mainform,document.mainform.sambaLogoffTime);
-  populate_sambaKickoffTime(document.mainform,document.mainform.sambaKickoffTime);
-  -->
-</script>