From 5e24b7bf9d265cb4251a220dffe33e4e46aadf61 Mon Sep 17 00:00:00 2001 From: skeeter Date: Mon, 24 Dec 2001 03:07:24 +0000 Subject: [PATCH] Fixes a problem where holidays in the following year are not loaded correctly. --- calendar/inc/class.bocalendar.inc.php | 9 +++++++-- calendar/inc/class.boholiday.inc.php | 7 ++++++- calendar/inc/class.uicalendar.inc.php | 18 +++++++++++++++--- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/calendar/inc/class.bocalendar.inc.php b/calendar/inc/class.bocalendar.inc.php index 83d49c8364..726390c44d 100755 --- a/calendar/inc/class.bocalendar.inc.php +++ b/calendar/inc/class.bocalendar.inc.php @@ -724,6 +724,7 @@ 'readsess' => 1 ) ); + $GLOBALS['phpgw']->common->phpgw_exit(True); } if($event['id']) @@ -801,10 +802,14 @@ } /* Private functions */ - function read_holidays() + function read_holidays($year=0) { + if(!$year) + { + $year = $this->year; + } $holiday = CreateObject('calendar.boholiday'); - $holiday->prepare_read_holidays($this->year,$this->owner); + $holiday->prepare_read_holidays($year,$this->owner); $this->cached_holidays = $holiday->read_holiday(); unset($holiday); } diff --git a/calendar/inc/class.boholiday.inc.php b/calendar/inc/class.boholiday.inc.php index af3a8db0e9..83d4dd4e8e 100755 --- a/calendar/inc/class.boholiday.inc.php +++ b/calendar/inc/class.boholiday.inc.php @@ -174,9 +174,14 @@ function prepare_read_holidays($year=0,$owner=0) { $datetime = CreateObject('phpgwapi.datetime'); - $this->year = ($year?$year:$GLOBALS['phpgw']->common->show_date(time() - $datetime->tz_offset,'Y')); + $this->year = (isset($year) && $year > 0?$year:$GLOBALS['phpgw']->common->show_date(time() - $datetime->tz_offset,'Y')); $this->owner = ($owner?$owner:$GLOBALS['phpgw_info']['user']['account_id']); + if($this->debug) + { + echo 'Setting Year to : '.$this->year.'
'."\n"; + } + if(@$GLOBALS['phpgw_info']['user']['preferences']['common']['country']) { $this->locales[] = $GLOBALS['phpgw_info']['user']['preferences']['common']['country']; diff --git a/calendar/inc/class.uicalendar.inc.php b/calendar/inc/class.uicalendar.inc.php index c00809f3ac..d492cd4171 100755 --- a/calendar/inc/class.uicalendar.inc.php +++ b/calendar/inc/class.uicalendar.inc.php @@ -102,6 +102,17 @@ return; } + if($params['month'] == 0) + { + $params['month'] = 12; + $params['year'] = $params['year'] - 1; + } + elseif($params['month'] == 13) + { + $params['month'] = 1; + $params['year'] = $params['year'] + 1; + } + $this->bo->store_to_cache( Array( 'smonth' => $params['month'], @@ -114,7 +125,7 @@ $params['buttons'] = (!isset($params['buttons'])?'none':$params['buttons']); $params['outside_month'] = (!isset($params['outside_month'])?True:$params['outside_month']); - $this->bo->read_holidays(); + $this->bo->read_holidays($params['year']); $date = $this->bo->datetime->makegmttime(0,0,0,$params['month'],$params['day'],$params['year']); $month_ago = intval(date('Ymd',mktime(0,0,0,$params['month'] - 1,$params['day'],$params['year']))); @@ -261,8 +272,6 @@ function get_month() { - $this->bo->read_holidays(); - $m = mktime(0,0,0,$this->bo->month,1,$this->bo->year); if (!$this->bo->printer_friendly || ($this->bo->printer_friendly && @$this->bo->prefs['calendar']['display_minicals'])) @@ -275,6 +284,7 @@ 'link' => 'day' ) ); + $minical_next = $this->mini_calendar( Array( 'day' => 1, @@ -303,6 +313,8 @@ $GLOBALS['phpgw_info']['flags']['nofooter'] = True; } + $this->bo->read_holidays(); + $var = Array( 'printer_friendly' => $printer, 'bg_text' => $this->theme['bg_text'],