From 1373fc77cdb0a635f66f3b387bcc2abd3880d67b Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 19 Dec 2006 07:16:32 +0000 Subject: [PATCH] Added sambaWorkingHours. Not finished yet git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@5421 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/personal/samba/class_sambaAccount.inc | 26 +++++ .../personal/samba/class_sambaLogonHours.inc | 95 +++++++++++++++++++ plugins/personal/samba/samba3.tpl | 2 + plugins/personal/samba/sambaLogonHours.tpl | 89 +++++++++++++++++ 4 files changed, 212 insertions(+) create mode 100644 plugins/personal/samba/class_sambaLogonHours.inc create mode 100644 plugins/personal/samba/sambaLogonHours.tpl diff --git a/plugins/personal/samba/class_sambaAccount.inc b/plugins/personal/samba/class_sambaAccount.inc index a03d61c23..2a84bd298 100644 --- a/plugins/personal/samba/class_sambaAccount.inc +++ b/plugins/personal/samba/class_sambaAccount.inc @@ -77,6 +77,7 @@ class sambaAccount extends plugin var $mungedObject; /* Helper */ + var $dialog; var $show_ws_dialog= FALSE; var $logon_time_set= 0; var $logoff_time_set= 0; @@ -232,6 +233,31 @@ class sambaAccount extends plugin } } + + /* Open Samaba Logong hours dialog */ + if(isset($_POST['SetSambaLogonHours']) && $this->samba3){ + $this->dialog = new sambaLogonHours($this->config,$this->dn,$this->sambaLogonHours); + } + + /* Cancel dialog */ + if(isset($_POST['cancel_logonHours'])){ + $this->dialog = NULL; + } + + /* Save selected logon hours */ + if(isset($_POST['save_logonHours'])){ + $this->dialog->save_object(); + $this->sambaLogonHours = $this->dialog->save(); + $this->dialog = NULL; + } + + /* Display dialog */ + if(isset($this->dialog)){ + $this->dialog->save_object(); + return($this->dialog->execute()); + } + + /* Prepare templating */ $smarty= get_smarty(); diff --git a/plugins/personal/samba/class_sambaLogonHours.inc b/plugins/personal/samba/class_sambaLogonHours.inc new file mode 100644 index 000000000..7123527ea --- /dev/null +++ b/plugins/personal/samba/class_sambaLogonHours.inc @@ -0,0 +1,95 @@ +sambaLogonHours = $slh; + + /* Set to default if value is empty or seams to be broken */ + if(strlen($slh) != 168){ + $slh = str_pad('',168 , "1"); + } + + /* Create matrix */ + $this->Matrix = array(); + for($day = 0 ; $day < 7 ; $day ++ ){ + for($hour = 0 ; $hour < 24 ; $hour ++){ + $bitpos = ($day * 24 + $hour) % 168; + $this->Matrix[$day][$hour] = $slh[$bitpos]; + } + } + } + + function execute() + { + $week_days = array(); + $week_days[0]= _("Sunday"); + $week_days[1]= _("Monday"); + $week_days[2]= _("Tuesday"); + $week_days[3]= _("Wednesday"); + $week_days[4]= _("Thursday"); + $week_days[5]= _("Friday"); + $week_days[6]= _("Saturday"); + + $hours = array(); + for($i = 0 ; $i <24 ; $i++ ){ + $hours[$i] = $i ; + } + + $smarty = get_smarty(); + $smarty->assign("Matrix",$this->Matrix); + $smarty->assign("Days" ,$week_days); + $smarty->assign("Hours" ,$hours); + return($smarty->fetch(get_template_path("sambaLogonHours.tpl",TRUE,dirname(__FILE__)))); + } + + function save_object() + { + /* Check if dialog was opened and if there were any changes */ + if(isset($_POST['sambaLogonHoursPosted'])){ + foreach($this->Matrix as $day_key => $days){ + foreach($days as $hour_key => $hour){ + if(isset($_POST['day_'.$day_key.'_'.$hour_key])){ + $this->Matrix[$day_key][$hour_key] = 1; + }else{ + $this->Matrix[$day_key][$hour_key] = 0; + } + } + } + } + } + + function save() + { + /* Convert Matrix to Hex */ + $ret = ""; + foreach($this->Matrix as $day_key => $days){ + $four_bit = ''; + foreach($days as $hour_key => $hour){ + $four_bit .= $hour; + if(strlen($four_bit) == 4){ + $ret .= base_convert($four_bit,2,16); + $four_bit =''; + } + } + } + return($ret); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/plugins/personal/samba/samba3.tpl b/plugins/personal/samba/samba3.tpl index ce9442dd8..6c41bf168 100644 --- a/plugins/personal/samba/samba3.tpl +++ b/plugins/personal/samba/samba3.tpl @@ -316,6 +316,8 @@ + +  {t}Samba logon restrictions{/t}   diff --git a/plugins/personal/samba/sambaLogonHours.tpl b/plugins/personal/samba/sambaLogonHours.tpl new file mode 100644 index 000000000..e259ec885 --- /dev/null +++ b/plugins/personal/samba/sambaLogonHours.tpl @@ -0,0 +1,89 @@ + + + + + + + + {foreach from=$Hours item=hours key=key_hours} + {if (($hours)%2) == 0 } + + {/foreach} + + + + + + {foreach from=$Hours item=hours key=key_hours} + {if (($hours)%2) == 0 } + + {/foreach} + + + +{foreach from=$Matrix item=days key=key_day} + + + {foreach from=$days item=hours key=key_hour} + {if (($key_hour)%2) == 0 } + + {/foreach} + + + + +{/foreach} +
+ {t}Hours{/t}  + + {else} + + {/if} + {$hours} +
+  {t}Days{/t} + + {else} + + {/if} + +
+ {$Days[$key_day]} + + {else} + + {/if} + {if $Matrix[$key_day].$key_hour} + + {else} + + {/if} + + +
+ +

+ +   + +

+ + -- 2.30.2