summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c33ea84)
raw | patch | inline | side by side (parent: c33ea84)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 20 Dec 2006 07:27:01 +0000 (07:27 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 20 Dec 2006 07:27:01 +0000 (07:27 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@5442 594d385d-05f5-0310-b6e9-bd551577e9d8
plugins/personal/samba/class_sambaLogonHours.inc | patch | blob | history |
diff --git a/plugins/personal/samba/class_sambaLogonHours.inc b/plugins/personal/samba/class_sambaLogonHours.inc
index 7b7fe9a45f90430f2dc09c7ae52fa7314f7cd792..414821da35354630ba3340f855e518accbc8b70f 100644 (file)
var $sambaLogonHours = "";
var $Matrix = array();
-
+ var $timezone = 0;
var $config;
function sambaLogonHours ($config, $dn, $slh)
{
plugin::plugin($config,$dn);
+ $this->sambaLogonHours = $slh;
+
+ /* Get Timezone to be able to shift to the correct beginning */
+ if(isset($this->config->current['TIMEZONE'])){
+ $this->timezone = $this->config->current['TIMEZONE'];
+ }
/* Convert to bin */
$tmp = '';
$tmp .= str_pad(base_convert($slh[$i],16,2),4,'0',STR_PAD_LEFT);
}
$slh = $tmp;
- $this->sambaLogonHours = $slh;
/* Set to default if value is empty or seams to be broken */
if(strlen($slh) != 168){
$slh = str_pad('',168 , "1");
}
+ /* Rework string, because it was stored in little endian */
+ $new = '';
+ for($i = 0 ; $i < 21 ; $i ++ ){
+ $part = strrev(substr($slh, $i * 8, 8));
+ $byte['hi'] = substr($part,0,4);
+ $byte['low'] = substr($part,4,4);
+ $new .= $byte['hi'].$byte['low'];
+ }
+
+ /* Shift string to match given timezone settings */
+ $shift_by = (168 + $this->timezone) % 168;
+ for($i = 0 ; $i < $shift_by; $i ++){
+ $new = $new[167].$new;
+ $new = substr($new,0,168);
+ }
+
/* 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];
+ $this->Matrix[$day][$hour] = $new[$bitpos];
}
}
}
function save()
{
+
/* Convert Matrix to Hex */
- $ret = "";
+ $slh = "";
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 ='';
- }
+ $slh .= $hour;
}
}
+
+ /* Shift string to match given timezone settings */
+ $shift_by = (168 + ($this->timezone*(-1))) % 168;
+ for($i = 0 ; $i < $shift_by; $i ++){
+ $slh = $slh[167].$slh;
+ $slh = substr($slh,0,168);
+ }
+
+ /* Rework string, because it was stored in little endian */
+ $new = '';
+ for($i = 0 ; $i < 21 ; $i ++ ){
+ $part = strrev(substr($slh, $i * 8, 8));
+ $byte['hi'] = substr($part,0,4);
+ $byte['low'] = substr($part,4,4);
+ $new .= $byte['hi'].$byte['low'];
+ }
+
+ /* Convert to bin */
+ $tmp = '';
+ for($i = 0 ; $i < 21 ; $i ++){
+ $tmp .= str_pad(base_convert(substr($new,$i*8,8),2,16),2,'0',STR_PAD_LEFT);
+ }
+
+ /* Create uppercase HEX chars */
+ $ret = strtoupper( $tmp);
/* All hours and days selected */
- if(substr_count($ret,'f') == 42){
- $ret ="";
+ if(substr_count($ret,'F') == 42){
+ $ret = "";
}
-
+
return($ret);
}
}