Changes to accomodate new common preference 'country'. Also found problems with dealing with holidays from different countries when viewing other peoples calendars.

This commit is contained in:
skeeter 2001-06-22 01:59:41 +00:00
parent 34fcd12d4b
commit c485583bdf
2 changed files with 11 additions and 7 deletions

View File

@ -28,9 +28,9 @@ class calendar_holiday
$this->datetime = CreateObject('phpgwapi.datetime'); $this->datetime = CreateObject('phpgwapi.datetime');
$this->db = $phpgw->db; $this->db = $phpgw->db;
if(isset($phpgw_info['user']['preferences']['calendar']['locale']) && $phpgw_info['user']['preferences']['calendar']['locale']) if(@$phpgw_info['user']['preferences']['common']['country'])
{ {
$this->users['user'] = $phpgw_info['user']['preferences']['calendar']['locale']; $this->users['user'] = $phpgw_info['user']['preferences']['common']['country'];
} }
else else
{ {
@ -41,9 +41,9 @@ class calendar_holiday
{ {
$owner_pref = CreateObject('phpgwapi.preferences',$owner_id); $owner_pref = CreateObject('phpgwapi.preferences',$owner_id);
$owner_prefs = $owner_pref->read_repository(); $owner_prefs = $owner_pref->read_repository();
if(isset($owner_prefs['calendar']['locale']) && $owner_prefs['calendar']['locale']) if(isset($owner_prefs['calendar']['locale']) && $owner_prefs['common']['country'])
{ {
$this->users['owner'] = $owner_prefs['calendar']['locale']; $this->users['owner'] = $owner_prefs['common']['country'];
} }
else else
{ {
@ -172,7 +172,7 @@ class calendar_holiday
$this->db->query($sql,__LINE__,__FILE__); $this->db->query($sql,__LINE__,__FILE__);
$i = 0; $i = 0;
$holidaycalc = CreateObject('calendar.holidaycalc'); $temp_locale = $phpgw_info['user']['preferences']['common']['country'];
while($this->db->next_record()) while($this->db->next_record())
{ {
$this->index[$this->db->f('hol_id')] = $i; $this->index[$this->db->f('hol_id')] = $i;
@ -199,7 +199,10 @@ class calendar_holiday
$this->holidays[$i]['owner'] = 'user'; $this->holidays[$i]['owner'] = 'user';
} }
$c = $i; $c = $i;
$phpgw_info['user']['preferences']['common']['country'] = $this->holidays[$i]['locale'];
$holidaycalc = CreateObject('calendar.holidaycalc');
$this->holidays[$i]['date'] = $holidaycalc->calculate_date($this->holidays[$i], $this->holidays, $this->year, $this->datetime, $c); $this->holidays[$i]['date'] = $holidaycalc->calculate_date($this->holidays[$i], $this->holidays, $this->year, $this->datetime, $c);
unset($holidaycalc);
if($c != $i) if($c != $i)
{ {
$i = $c; $i = $c;
@ -207,6 +210,7 @@ class calendar_holiday
$i++; $i++;
} }
$this->holidays = $this->sort_by_date($this->holidays); $this->holidays = $this->sort_by_date($this->holidays);
$phpgw_info['user']['preferences']['common']['country'] = $temp_locale;
return $this->holidays; return $this->holidays;
} }

View File

@ -13,13 +13,13 @@
/* $Id$ */ /* $Id$ */
if (empty($phpgw_info['user']['preferences']['calendar']['locale'])) if (empty($phpgw_info['user']['preferences']['common']['country']))
{ {
$rule = 'US'; $rule = 'US';
} }
else else
{ {
$rule = $phpgw_info['user']['preferences']['calendar']['locale']; $rule = $phpgw_info['user']['preferences']['common']['country'];
} }
include(PHPGW_INCLUDE_ROOT.'/calendar/inc/class.holidaycalc_'.$rule.'.inc.php'); include(PHPGW_INCLUDE_ROOT.'/calendar/inc/class.holidaycalc_'.$rule.'.inc.php');