Code

Added selectboxes to heimdal date values.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 6 Dec 2007 07:31:03 +0000 (07:31 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 6 Dec 2007 07:31:03 +0000 (07:31 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8031 594d385d-05f5-0310-b6e9-bd551577e9d8

ihtml/themes/default/pwd_heimdal.tpl
include/class_password-methods-heimdal.inc

index 0d1ae4adbcc226e04823aef1268242cff6140d39..5ccb473158a548a6f0472dc9d6a7db30fd3bcf9f 100644 (file)
                                                <label for="krb5ValidStart">{t}Valid ticket start time{/t}</label>
                                        </td>
                                        <td>
-                                               <input id="krb5ValidStart" type="text" name="krb5ValidStart" value="{$krb5ValidStart}">
+                                               <input type="checkbox" name="krb5ValidStart_clear" 
+                                                       onClick="       changeState('krb5ValidStart_y');
+                                                                               changeState('krb5ValidStart_m');
+                                                                               changeState('krb5ValidStart_d');
+                                                                               changeState('krb5ValidStart_h');
+                                                                               changeState('krb5ValidStart_i');"
+                                                       {if $krb5ValidStart_clear} checked {/if}
+                                               >
+                                               <select name="krb5ValidStart_y" id="krb5ValidStart_y" {if $krb5ValidStart_clear} disabled {/if}> 
+                                                       {html_options options=$years selected=$krb5ValidStart_y}
+                                               </select>
+                                               <select name="krb5ValidStart_m" id="krb5ValidStart_m" {if $krb5ValidStart_clear} disabled {/if}>
+                                                       {html_options options=$month selected=$krb5ValidStart_m}
+                                               </select>
+                                               <select name="krb5ValidStart_d" id="krb5ValidStart_d" {if $krb5ValidStart_clear} disabled {/if}>
+                                                       {html_options options=$days selected=$krb5ValidStart_d}
+                                               </select>
+                                               <select name="krb5ValidStart_h" id="krb5ValidStart_h" {if $krb5ValidStart_clear} disabled {/if}>
+                                                       {html_options options=$hours selected=$krb5ValidStart_h}
+                                               </select>
+                                               <select name="krb5ValidStart_i" id="krb5ValidStart_i" {if $krb5ValidStart_clear} disabled {/if}>
+                                                       {html_options options=$minutes selected=$krb5ValidStart_i}
+                                               </select>
                                        </td>
                                </tr>
                                <tr>
                                                <label for="krb5ValidEnd">{t}Valid ticket end time{/t}</label>
                                        </td>
                                        <td>
-                                               <input id="krb5ValidEnd" type="text" name="krb5ValidEnd" value="{$krb5ValidEnd}">
+                                               <input type="checkbox" name="krb5ValidEnd_clear" 
+                                                       onClick="       changeState('krb5ValidEnd_y');
+                                                                               changeState('krb5ValidEnd_m');
+                                                                               changeState('krb5ValidEnd_d');
+                                                                               changeState('krb5ValidEnd_h');
+                                                                               changeState('krb5ValidEnd_i');"
+                                                       {if $krb5ValidEnd_clear} checked {/if}
+                                               >
+                                               <select name="krb5ValidEnd_y" id="krb5ValidEnd_y" {if $krb5ValidEnd_clear} disabled {/if}>
+                                                       {html_options options=$years selected=$krb5ValidEnd_y}
+                                               </select>
+                                               <select name="krb5ValidEnd_m" id="krb5ValidEnd_m" {if $krb5ValidEnd_clear} disabled {/if}>
+                                                       {html_options options=$month selected=$krb5ValidEnd_m}
+                                               </select>
+                                               <select name="krb5ValidEnd_d" id="krb5ValidEnd_d" {if $krb5ValidEnd_clear} disabled {/if}>
+                                                       {html_options options=$days selected=$krb5ValidEnd_d}
+                                               </select>
+                                               <select name="krb5ValidEnd_h" id="krb5ValidEnd_h" {if $krb5ValidEnd_clear} disabled {/if}>
+                                                       {html_options options=$hours selected=$krb5ValidEnd_h}
+                                               </select>
+                                               <select name="krb5ValidEnd_i" id="krb5ValidEnd_i" {if $krb5ValidEnd_clear} disabled {/if}>
+                                                       {html_options options=$minutes selected=$krb5ValidEnd_i}
+                                               </select>
                                        </td>
                                </tr>
                                <tr>
                                                <label for="krb5PasswordEnd">{t}Password end{/t}</label>
                                        </td>
                                        <td>
-                                               <input id="krb5PasswordEnd" type="text" name="krb5PasswordEnd" value="{$krb5PasswordEnd}">
+                                               <input type="checkbox" name="krb5PasswordEnd_clear" 
+                                                       onClick="       changeState('krb5PasswordEnd_y');
+                                                                               changeState('krb5PasswordEnd_m');
+                                                                               changeState('krb5PasswordEnd_d');
+                                                                               changeState('krb5PasswordEnd_h');
+                                                                               changeState('krb5PasswordEnd_i');"
+                                                       {if $krb5PasswordEnd_clear} checked {/if}
+                                               >
+                                               <select name="krb5PasswordEnd_y" id="krb5PasswordEnd_y" {if $krb5PasswordEnd_clear} disabled {/if}>
+                                                       {html_options options=$years selected=$krb5PasswordEnd_y}
+                                               </select>
+                                               <select name="krb5PasswordEnd_m" id="krb5PasswordEnd_m" {if $krb5PasswordEnd_clear} disabled {/if}>
+                                                       {html_options options=$month selected=$krb5PasswordEnd_m}
+                                               </select>
+                                               <select name="krb5PasswordEnd_d" id="krb5PasswordEnd_d" {if $krb5PasswordEnd_clear} disabled {/if}>
+                                                       {html_options options=$days selected=$krb5PasswordEnd_d}
+                                               </select>
+                                               <select name="krb5PasswordEnd_h" id="krb5PasswordEnd_h" {if $krb5PasswordEnd_clear} disabled {/if}>
+                                                       {html_options options=$hours selected=$krb5PasswordEnd_h}
+                                               </select>
+                                               <select name="krb5PasswordEnd_i" id="krb5PasswordEnd_i" {if $krb5PasswordEnd_clear} disabled {/if}>
+                                                       {html_options options=$minutes selected=$krb5PasswordEnd_i}
+                                               </select>
+
                                        </td>
                                </tr>
                        </table>
index 924a244004bafa30c7226ff39131142162e11892..370ee803f8cd3320a5f07a6efed404fdfe6cdc24 100644 (file)
@@ -27,6 +27,9 @@ class passwordMethodheimdal extends passwordMethod
   var $krb5ValidStart   = "";
   var $krb5ValidEnd     = "";
   var $krb5PasswordEnd  = "";
+  var $krb5ValidStart_clear   = TRUE;
+  var $krb5ValidEnd_clear     = TRUE;
+  var $krb5PasswordEnd_clear  = TRUE;
 
   var $display = TRUE;
 
@@ -82,6 +85,15 @@ class passwordMethodheimdal extends passwordMethod
             $this->$attr = "";
           }
         }
+        $date_values = array("krb5ValidStart","krb5ValidEnd","krb5PasswordEnd");
+        foreach($date_values as $date_val){
+          $clear = $date_val."_clear";
+          if(empty($this->$date_val)){
+            $this->$clear = TRUE;
+          }else{
+            $this->$clear = FALSE;
+          }
+        }
       }elseif($ldap->count() >= 2){
         new msg_dialog(_("Heimdal"),sprintf(_("Error loading heimdal configuration, more than one configuration entry was found for '%s'."),$this->parent_dn));
       }
@@ -212,7 +224,47 @@ class passwordMethodheimdal extends passwordMethod
       }
     }
 
+    $years = array();
+    $start = date("Y")-1;
+    for($i = $start; $i < ($start +20) ; $i++){
+      $years[$i] = $i;
+    }
+    $month= array();
+    for($i = 1; $i <= 12  ; $i++){
+      $month[str_pad($i,2,"0",STR_PAD_LEFT)] = $i;
+    }
+    $days= array();
+    for($i = 1; $i <= 31  ; $i++){
+      $days[str_pad($i,2,"0",STR_PAD_LEFT)] = $i;
+    }
+    $hours= array();
+    for($i = 0; $i <= 23  ; $i++){
+      $hours[str_pad($i,2,"0",STR_PAD_LEFT)] = $i;
+    }
+    $minutes= array();
+    for($i = 0; $i <= 59  ; $i++){
+      $minutes[str_pad($i,2,"0",STR_PAD_LEFT)] = $i;
+    }
+  
+
     $smarty = get_smarty();
+    $smarty->assign("years",$years);
+    $smarty->assign("month",$month);
+    $smarty->assign("days",$days);
+    $smarty->assign("hours",$hours);
+    $smarty->assign("minutes",$minutes);
+
+    $date_values = array("krb5ValidStart","krb5ValidEnd","krb5PasswordEnd");
+    foreach($date_values as $date_val){
+      $clear = $date_val."_clear";
+      $smarty->assign($date_val."_clear",$this->$clear);
+      $smarty->assign($date_val."_y",substr($this->$date_val,0,4));
+      $smarty->assign($date_val."_m",substr($this->$date_val,4,2));
+      $smarty->assign($date_val."_d",substr($this->$date_val,6,2));
+      $smarty->assign($date_val."_h",substr($this->$date_val,8,2));
+      $smarty->assign($date_val."_i",substr($this->$date_val,10,2));
+    }
+
     foreach($this->attributes as $attr){
       $smarty->assign($attr ,$this->$attr);
     }
@@ -232,6 +284,24 @@ class passwordMethodheimdal extends passwordMethod
   function save_object()
   {
     if(isset($_POST['pwd_heimdal_posted'])){
+
+      $date_values = array("krb5ValidStart","krb5ValidEnd","krb5PasswordEnd");
+      foreach($date_values as $date_value){
+        $clear = $date_value."_clear";
+        if(isset($_POST[$date_value."_clear"])){
+          $this->$clear = TRUE;
+        }else{
+          $this->$clear = FALSE;
+          $str = "";
+          foreach(array("y","m","d","h","i") as $val){
+            if(isset($_POST[$date_value."_".$val])){
+              $str .= $_POST[$date_value."_".$val]; 
+            }
+          }
+          $this->$date_value = $str."Z";
+        }
+      }
+
       foreach($this->attributes as $attr){
         if(isset($_POST[$attr])){
           $this->$attr = get_post($attr);
@@ -258,13 +328,13 @@ class passwordMethodheimdal extends passwordMethod
     if(!is_numeric($this->krb5MaxRenew) && !empty($this->krb5MaxRenew)){
       $message[] = sprintf(_("Please specify a numeric value for %s."),_("Max renew"));
     }
-   if(!empty($this->krb5ValidStart) && !$this->chk_times($this->krb5ValidStart)){
+   if(!$this->krb5ValidStart_clear && !$this->chk_times($this->krb5ValidStart)){
      $message[] = sprintf(_("Please specify a numeric value for %s."),_("Valid start"));
    }
-   if(!empty($this->krb5ValidEnd) && !$this->chk_times($this->krb5ValidEnd)){
+   if(!$this->krb5ValidEnd_clear && !$this->chk_times($this->krb5ValidEnd)){
      $message[] = sprintf(_("Please specify a numeric value for %s."),_("Valid end"));
    }
-   if(!empty($this->krb5PasswordEnd) && !$this->chk_times($this->krb5PasswordEnd)){
+   if(!$this->krb5PasswordEnd_clear && !$this->chk_times($this->krb5PasswordEnd)){
      $message[] = sprintf(_("Please specify a numeric value for %s."),_("Valid password"));
    }
     return($message);
@@ -315,13 +385,13 @@ class passwordMethodheimdal extends passwordMethod
       if(!empty($this->krb5MaxRenew)){
         $data['krb5MaxRenew']   = $this->krb5MaxRenew;
       }
-      if(!empty($this->krb5ValidStart)){
+      if(!$this->krb5ValidStart_clear){
         $data['krb5ValidStart'] = $this->krb5ValidStart;
       }
-      if(!empty($this->krb5ValidEnd)){
+      if(!$this->krb5ValidEnd_clear){
         $data['krb5ValidEnd']   = $this->krb5ValidEnd;
       }
-      if(!empty($this->krb5PasswordEnd)){
+      if(!$this->krb5PasswordEnd_clear){
         $data['krb5PasswordEnd']= $this->krb5PasswordEnd;
       }