From e15935617131743471cdc8cedc4825fc7e9692ef Mon Sep 17 00:00:00 2001 From: hickert Date: Mon, 16 Jul 2007 10:08:52 +0000 Subject: [PATCH] Added new timezone functions. Implemented new tz function into sambaLogonHours. git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@6876 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../samba => include}/class_timezones.inc | 57 ++++++++++++++----- .../personal/samba/class_sambaLogonHours.inc | 15 +---- 2 files changed, 46 insertions(+), 26 deletions(-) rename {plugins/personal/samba => include}/class_timezones.inc (94%) diff --git a/plugins/personal/samba/class_timezones.inc b/include/class_timezones.inc similarity index 94% rename from plugins/personal/samba/class_timezones.inc rename to include/class_timezones.inc index 9be040feb..8297e7246 100644 --- a/plugins/personal/samba/class_timezones.inc +++ b/include/class_timezones.inc @@ -1,8 +1,45 @@ "unconfigured", "value" => 0); + if(isset($config->current['TIMEZONE']) || isset($config->data['MAIN']['TIMEZONE'])){ + if(isset($config->current['TIMEZONE'])){ + $tz = $config->current['TIMEZONE']; + }else{ + $tz = $config->data['MAIN']['TIMEZONE']; + } + + $zone = get_timezone($tz); + if(!count($zone)){ + trigger_error(sprintf("The timezone you have configured in your gosa.conf (%s) is not valid.",$tz)); + $zone = array("name" => "unconfigured", "value" => 0); + } + } + return($zone); +} + +function _timezones_array($selected = NULL) { - $timezones = array('Africa/Abidjan' => 0, + $timezones = array( + 'Africa/Abidjan' => 0, 'Africa/Accra' => 0, 'Africa/Addis_Ababa' => 10800, 'Africa/Algiers' => 3600, @@ -435,7 +472,7 @@ function timezones_array($selected = null) 'Pacific/Wallis' => 43200, 'Pacific/Yap' => 36000 ); - $timezones_dst = array ( + $_unused_timezones = array ( 'America/Adak' => 1, 'America/Atka' => 1, 'America/Anchorage' => 1, @@ -603,23 +640,15 @@ function timezones_array($selected = null) ); $tz_arr = array(); - if($selected != null){ + if($selected != NULL){ foreach($timezones as $timezone => $value) { if (preg_match("#".normalizePreg($timezone)."#i",$selected)){ - return($tz_arr[$timezone] = array('name'=>$timezone,'value'=>$value)); + return($tz_arr[$timezone] = array('name'=>$timezone,'value'=>$value / (60*60))); } } - foreach($timezones_dst as $timezone => $value){ - if (preg_match("/".normalizePreg($timezone)."/i",$selected)){ - return($tz_arr[$timezone] = array('name'=>$timezone,'value'=>$value)); - } - } }else{ foreach($timezones as $timezone => $value) { - $tz_arr[$timezone] = array('name'=>$timezone,'value'=>$value); - } - foreach($timezones_dst as $timezone => $value) { - $tz_arr[$timezone] = array('name'=>$timezone,'value'=>$value); + $tz_arr[$timezone] = array('name'=>$timezone,'value'=>($value / (60*60))); } } return $tz_arr; diff --git a/plugins/personal/samba/class_sambaLogonHours.inc b/plugins/personal/samba/class_sambaLogonHours.inc index e20d0e3e9..0c0dd0155 100644 --- a/plugins/personal/samba/class_sambaLogonHours.inc +++ b/plugins/personal/samba/class_sambaLogonHours.inc @@ -15,18 +15,9 @@ class sambaLogonHours extends plugin plugin::plugin($config,$dn); $this->sambaLogonHours = $slh; - /* Get Timezone to be able to shift to the correct beginning */ - if(isset($this->config->current['TIMEZONE'])){ - $tz = $this->config->current['TIMEZONE']; - $tz_a = timezones_array($tz); - - if(!count($tz_a)){ - $this->timezone = 0; - print_red(sprintf(_("The configured timezone '%s' seems not to valid."),$tz)); - }else{ - $this->timezone = $tz_a['value'] / (60*60); - } - } + /* Get default timezone */ + $zone = get_default_timezone(); + $this->timezone = $zone['value']; /* Convert to bin */ $tmp = ''; -- 2.30.2