2001-07-18 19:30:24 +02:00
|
|
|
<?php
|
|
|
|
/**************************************************************************\
|
|
|
|
* phpGroupWare - Holiday *
|
|
|
|
* http://www.phpgroupware.org *
|
|
|
|
* Written by Mark Peters <skeeter@phpgroupware.org> *
|
|
|
|
* -------------------------------------------- *
|
|
|
|
* This program is free software; you can redistribute it and/or modify it *
|
|
|
|
* under the terms of the GNU General Public License as published by the *
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your *
|
|
|
|
* option) any later version. *
|
|
|
|
\**************************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
class boholiday
|
|
|
|
{
|
|
|
|
var $public_functions = Array(
|
2001-07-28 15:17:30 +02:00
|
|
|
'add' => True,
|
|
|
|
'delete_holiday' => True,
|
|
|
|
'delete_locale' => True,
|
|
|
|
'accept_holiday' => True,
|
|
|
|
|
2001-07-18 19:30:24 +02:00
|
|
|
'read_entries' => True,
|
|
|
|
'read_entry' => True,
|
|
|
|
'add_entry' => True,
|
|
|
|
'update_entry' => True
|
|
|
|
);
|
|
|
|
|
|
|
|
var $debug = False;
|
2001-07-28 15:17:30 +02:00
|
|
|
var $base_url = '/index.php';
|
2001-07-18 19:30:24 +02:00
|
|
|
|
2001-07-28 15:17:30 +02:00
|
|
|
var $ui;
|
2001-07-18 19:30:24 +02:00
|
|
|
var $so;
|
|
|
|
var $owner;
|
|
|
|
var $year;
|
2001-07-28 15:17:30 +02:00
|
|
|
|
|
|
|
var $id;
|
|
|
|
var $total;
|
|
|
|
var $start;
|
|
|
|
var $query;
|
|
|
|
var $sort;
|
2001-07-18 19:30:24 +02:00
|
|
|
|
|
|
|
var $locales = Array();
|
|
|
|
var $holidays;
|
|
|
|
var $cached_holidays;
|
|
|
|
|
2001-07-28 15:17:30 +02:00
|
|
|
function boholiday()
|
2001-07-18 19:30:24 +02:00
|
|
|
{
|
|
|
|
$this->so = CreateObject('calendar.soholiday');
|
|
|
|
|
2003-09-22 17:01:26 +02:00
|
|
|
$this->start = intval(get_var('start',array('POST','GET')));
|
|
|
|
$this->query = get_var('query',array('POST','GET'));
|
|
|
|
$this->sort = get_var('sort',array('POST','GET'));
|
|
|
|
$this->order = get_var('order',array('POST','GET'));
|
|
|
|
$this->id = get_var('id',array('POST','GET'));
|
|
|
|
$this->year = get_var('year',array('POST','GET'),date('Y'));
|
2003-08-28 16:31:11 +02:00
|
|
|
$this->locale = get_var('locale',array('POST','GET'));
|
|
|
|
if ($this->locale)
|
|
|
|
{
|
|
|
|
$this->locales[] = $this->locale;
|
|
|
|
}
|
2003-02-27 20:28:25 +01:00
|
|
|
|
2001-07-28 15:17:30 +02:00
|
|
|
if($this->debug)
|
|
|
|
{
|
2001-12-10 04:55:47 +01:00
|
|
|
echo '<-- Locale = '.$this->locales[0].' -->'."\n";
|
2001-07-28 15:17:30 +02:00
|
|
|
}
|
|
|
|
|
2003-02-27 20:28:25 +01:00
|
|
|
$this->total = $this->so->holiday_total($this->locales[0],$this->query,$this->year);
|
2001-07-28 15:17:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Begin Calendar functions */
|
|
|
|
function read_entry($id=0)
|
|
|
|
{
|
|
|
|
if($this->debug)
|
|
|
|
{
|
|
|
|
echo "BO : Reading Holiday ID : ".$id."<br>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!$id)
|
|
|
|
{
|
|
|
|
if(!$this->id)
|
|
|
|
{
|
|
|
|
return Array();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$id = $this->id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->so->read_holiday($id);
|
|
|
|
}
|
|
|
|
|
|
|
|
function delete_holiday($id=0)
|
|
|
|
{
|
|
|
|
if(!$id)
|
|
|
|
{
|
|
|
|
if($this->id)
|
|
|
|
{
|
|
|
|
$id = $this->id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->ui = CreateObject('calendar.uiholiday');
|
|
|
|
if($id)
|
|
|
|
{
|
|
|
|
$this->so->delete_holiday($id);
|
|
|
|
$this->ui->edit_locale();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->ui->admin();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function delete_locale($locale='')
|
|
|
|
{
|
|
|
|
if(!$locale)
|
|
|
|
{
|
|
|
|
if($this->locales[0])
|
|
|
|
{
|
|
|
|
$locale = $this->locales[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if($locale)
|
|
|
|
{
|
|
|
|
$this->so->delete_locale($locale);
|
|
|
|
}
|
|
|
|
$this->ui = CreateObject('calendar.uiholiday');
|
|
|
|
$this->ui->admin();
|
|
|
|
}
|
|
|
|
|
|
|
|
function accept_holiday()
|
|
|
|
{
|
2003-09-22 17:01:26 +02:00
|
|
|
$send_back_to = str_replace('submitlocale','holiday_admin',$_SERVER['HTTP_REFERER']);
|
2001-07-28 15:17:30 +02:00
|
|
|
if(!@$this->locales[0])
|
|
|
|
{
|
|
|
|
Header('Location: '.$send_back_to);
|
|
|
|
}
|
|
|
|
|
|
|
|
$send_back_to = str_replace('&locale='.$this->locales[0],'',$send_back_to);
|
|
|
|
$file = './holidays.'.$this->locales[0];
|
2003-09-22 17:01:26 +02:00
|
|
|
if(!file_exists($file) && count($_POST['name']))
|
2001-07-28 15:17:30 +02:00
|
|
|
{
|
2003-09-22 17:01:26 +02:00
|
|
|
$c_holidays = count($_POST['name']);
|
2001-07-28 15:17:30 +02:00
|
|
|
$fp = fopen($file,'w');
|
|
|
|
for($i=0;$i<$c_holidays;$i++)
|
|
|
|
{
|
2003-09-22 17:01:26 +02:00
|
|
|
fwrite($fp,$this->locales[0]."\t".$_POST['name'][$i]."\t".$_POST['day'][$i]."\t".$_POST['month'][$i]."\t".$_POST['occurence'][$i]."\t".$_POST['dow'][$i]."\t".$_POST['observance'][$i]."\n");
|
2001-07-28 15:17:30 +02:00
|
|
|
}
|
|
|
|
fclose($fp);
|
|
|
|
}
|
|
|
|
Header('Location: '.$send_back_to);
|
|
|
|
}
|
|
|
|
|
2003-02-27 20:28:25 +01:00
|
|
|
function get_holiday_list($locale='', $sort='', $order='', $query='', $total='', $year=0)
|
2001-07-28 15:17:30 +02:00
|
|
|
{
|
2001-08-17 02:24:20 +02:00
|
|
|
$locale = ($locale?$locale:$this->locales[0]);
|
|
|
|
$sort = ($sort?$sort:$this->sort);
|
|
|
|
$order = ($order?$order:$this->order);
|
|
|
|
$query = ($query?$query:$this->query);
|
2003-02-27 20:28:25 +01:00
|
|
|
$year = ($$year?$$year:$this->year);
|
|
|
|
return $this->so->read_holidays($locale,$query,$order,$year);
|
2001-07-28 15:17:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function get_locale_list($sort='', $order='', $query='')
|
|
|
|
{
|
2001-08-17 02:24:20 +02:00
|
|
|
$sort = ($sort?$sort:$this->sort);
|
|
|
|
$order = ($order?$order:$this->order);
|
2001-09-07 18:50:07 +02:00
|
|
|
$query = ($query?$query:$this->query);
|
2001-07-28 15:17:30 +02:00
|
|
|
return $this->so->get_locale_list($sort,$order,$query);
|
|
|
|
}
|
|
|
|
|
|
|
|
function prepare_read_holidays($year=0,$owner=0)
|
|
|
|
{
|
2003-08-28 16:31:11 +02:00
|
|
|
$this->year = (isset($year) && $year > 0?$year:$GLOBALS['phpgw']->common->show_date(time() - $GLOBALS['phpgw']->datetime->tz_offset,'Y'));
|
2001-08-17 02:24:20 +02:00
|
|
|
$this->owner = ($owner?$owner:$GLOBALS['phpgw_info']['user']['account_id']);
|
2001-07-18 19:30:24 +02:00
|
|
|
|
2001-12-24 04:07:24 +01:00
|
|
|
if($this->debug)
|
|
|
|
{
|
|
|
|
echo 'Setting Year to : '.$this->year.'<br>'."\n";
|
|
|
|
}
|
|
|
|
|
2001-08-17 02:24:20 +02:00
|
|
|
if(@$GLOBALS['phpgw_info']['user']['preferences']['common']['country'])
|
2001-07-18 19:30:24 +02:00
|
|
|
{
|
2001-08-17 02:24:20 +02:00
|
|
|
$this->locales[] = $GLOBALS['phpgw_info']['user']['preferences']['common']['country'];
|
2001-07-18 19:30:24 +02:00
|
|
|
}
|
2001-08-17 02:24:20 +02:00
|
|
|
elseif(@$GLOBALS['phpgw_info']['user']['preferences']['calendar']['locale'])
|
2001-07-18 19:30:24 +02:00
|
|
|
{
|
2001-08-17 02:24:20 +02:00
|
|
|
$this->locales[] = $GLOBALS['phpgw_info']['user']['preferences']['calendar']['locale'];
|
2001-07-18 19:30:24 +02:00
|
|
|
}
|
2001-08-14 04:20:28 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->locales[] = 'US';
|
|
|
|
}
|
2001-07-18 19:30:24 +02:00
|
|
|
|
2001-08-17 02:24:20 +02:00
|
|
|
if($this->owner != $GLOBALS['phpgw_info']['user']['account_id'])
|
2001-07-18 19:30:24 +02:00
|
|
|
{
|
|
|
|
$owner_pref = CreateObject('phpgwapi.preferences',$owner);
|
|
|
|
$owner_prefs = $owner_pref->read_repository();
|
|
|
|
if(@$owner_prefs['common']['country'])
|
|
|
|
{
|
|
|
|
$this->locales[] = $owner_prefs['common']['country'];
|
|
|
|
}
|
|
|
|
elseif(@$owner_prefs['calendar']['locale'])
|
|
|
|
{
|
|
|
|
$this->locales[] = $owner_prefs['calendar']['locale'];
|
|
|
|
}
|
|
|
|
unset($owner_pref);
|
|
|
|
}
|
|
|
|
|
|
|
|
@reset($this->locales);
|
2001-08-17 02:24:20 +02:00
|
|
|
if($GLOBALS['phpgw_info']['server']['auto_load_holidays'] == True)
|
2001-07-18 19:30:24 +02:00
|
|
|
{
|
|
|
|
while(list($key,$value) = each($this->locales))
|
|
|
|
{
|
|
|
|
$this->auto_load_holidays($value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-07-28 15:17:30 +02:00
|
|
|
|
2001-07-18 19:30:24 +02:00
|
|
|
function auto_load_holidays($locale)
|
|
|
|
{
|
2001-07-28 15:17:30 +02:00
|
|
|
if($this->so->holiday_total($locale) == 0)
|
2001-07-18 19:30:24 +02:00
|
|
|
{
|
2001-08-17 02:24:20 +02:00
|
|
|
global $HTTP_HOST, $SERVER_PORT;
|
2001-07-18 19:30:24 +02:00
|
|
|
|
|
|
|
@set_time_limit(0);
|
|
|
|
|
|
|
|
/* get the file that contains the calendar events for your locale */
|
2003-09-22 17:01:26 +02:00
|
|
|
/* "http://www.egroupware.org/cal/holidays.US"; */
|
2001-07-18 19:30:24 +02:00
|
|
|
$network = CreateObject('phpgwapi.network');
|
2001-08-17 02:24:20 +02:00
|
|
|
if(isset($GLOBALS['phpgw_info']['server']['holidays_url_path']) && $GLOBALS['phpgw_info']['server']['holidays_url_path'] != 'localhost')
|
2001-07-18 19:30:24 +02:00
|
|
|
{
|
2001-08-17 02:24:20 +02:00
|
|
|
$load_from = $GLOBALS['phpgw_info']['server']['holidays_url_path'];
|
2001-07-18 19:30:24 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-08-17 02:24:20 +02:00
|
|
|
$pos = strpos(' '.$GLOBALS['phpgw_info']['server']['webserver_url'],$HTTP_HOST);
|
2001-07-18 19:30:24 +02:00
|
|
|
if($pos == 0)
|
|
|
|
{
|
|
|
|
switch($SERVER_PORT)
|
|
|
|
{
|
|
|
|
case 80:
|
|
|
|
$http_protocol = 'http://';
|
|
|
|
break;
|
|
|
|
case 443:
|
|
|
|
$http_protocol = 'https://';
|
|
|
|
break;
|
|
|
|
}
|
2001-08-17 02:24:20 +02:00
|
|
|
$server_host = $http_protocol.$HTTP_HOST.$GLOBALS['phpgw_info']['server']['webserver_url'];
|
2001-07-18 19:30:24 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-08-17 02:24:20 +02:00
|
|
|
$server_host = $GLOBALS['phpgw_info']['server']['webserver_url'];
|
2001-07-18 19:30:24 +02:00
|
|
|
}
|
|
|
|
$load_from = $server_host.'/calendar/setup';
|
|
|
|
}
|
|
|
|
// echo 'Loading from: '.$load_from.'/holidays.'.strtoupper($locale)."<br>\n";
|
|
|
|
$lines = $network->gethttpsocketfile($load_from.'/holidays.'.strtoupper($locale));
|
|
|
|
if (!$lines)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$c_lines = count($lines);
|
|
|
|
for($i=0;$i<$c_lines;$i++)
|
|
|
|
{
|
|
|
|
// echo 'Line #'.$i.' : '.$lines[$i]."<br>\n";
|
|
|
|
$holiday = explode("\t",$lines[$i]);
|
|
|
|
if(count($holiday) == 7)
|
|
|
|
{
|
|
|
|
$holiday['locale'] = $holiday[0];
|
2001-09-17 04:33:19 +02:00
|
|
|
$holiday['name'] = $GLOBALS['phpgw']->db->db_addslashes($holiday[1]);
|
2001-07-18 19:30:24 +02:00
|
|
|
$holiday['mday'] = intval($holiday[2]);
|
|
|
|
$holiday['month_num'] = intval($holiday[3]);
|
|
|
|
$holiday['occurence'] = intval($holiday[4]);
|
|
|
|
$holiday['dow'] = intval($holiday[5]);
|
|
|
|
$holiday['observance_rule'] = intval($holiday[6]);
|
|
|
|
$holiday['hol_id'] = 0;
|
|
|
|
$this->so->save_holiday($holiday);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-07-28 15:17:30 +02:00
|
|
|
function save_holiday($holiday)
|
|
|
|
{
|
|
|
|
$this->so->save_holiday($holiday);
|
|
|
|
}
|
|
|
|
|
|
|
|
function add()
|
|
|
|
{
|
2003-09-22 17:01:26 +02:00
|
|
|
if(@$_POST['submit'])
|
2001-07-28 15:17:30 +02:00
|
|
|
{
|
2003-09-22 17:01:26 +02:00
|
|
|
$holiday = $_POST['holiday'];
|
2003-02-27 20:28:25 +01:00
|
|
|
|
|
|
|
if(empty($holiday['mday']))
|
2001-07-28 15:17:30 +02:00
|
|
|
{
|
2003-02-27 20:28:25 +01:00
|
|
|
$holiday['mday'] = 0;
|
2001-07-28 15:17:30 +02:00
|
|
|
}
|
|
|
|
if(!isset($this->bo->locales[0]) || $this->bo->locales[0]=='')
|
|
|
|
{
|
2003-02-27 20:28:25 +01:00
|
|
|
$this->bo->locales[0] = $holiday['locale'];
|
|
|
|
}
|
|
|
|
elseif(!isset($holiday['locale']) || $holiday['locale']=='')
|
|
|
|
{
|
|
|
|
$holiday['locale'] = $this->bo->locales[0];
|
|
|
|
}
|
|
|
|
if(!isset($holiday['hol_id']))
|
|
|
|
{
|
|
|
|
$holiday['hol_id'] = $this->bo->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
// some input validation
|
|
|
|
|
|
|
|
if (!$holiday['mday'] == !$holiday['occurence'])
|
|
|
|
{
|
|
|
|
$errors[] = lang('You need to set either a day or a occurence !!!');
|
2001-07-28 15:17:30 +02:00
|
|
|
}
|
2003-02-27 20:28:25 +01:00
|
|
|
if($holiday['year'] && $holiday['occurence'])
|
2001-07-28 15:17:30 +02:00
|
|
|
{
|
2003-02-27 20:28:25 +01:00
|
|
|
$errors[] = lang('You can only set a year or a occurence !!!');
|
2001-07-28 15:17:30 +02:00
|
|
|
}
|
2003-02-27 20:28:25 +01:00
|
|
|
else
|
2001-07-28 15:17:30 +02:00
|
|
|
{
|
2003-02-27 20:28:25 +01:00
|
|
|
$holiday['occurence'] = intval($holiday['occurence'] ? $holiday['occurence'] : $holiday['year']);
|
|
|
|
unset($holiday['year']);
|
2001-07-28 15:17:30 +02:00
|
|
|
}
|
2003-02-27 20:28:25 +01:00
|
|
|
|
2001-07-28 15:17:30 +02:00
|
|
|
|
|
|
|
// Still need to put some validation in here.....
|
|
|
|
|
|
|
|
$this->ui = CreateObject('calendar.uiholiday');
|
2003-02-27 20:28:25 +01:00
|
|
|
|
2001-07-28 15:17:30 +02:00
|
|
|
if (is_array($errors))
|
|
|
|
{
|
2003-02-27 20:28:25 +01:00
|
|
|
$holiday['month'] = $holiday['month_num'];
|
|
|
|
$holiday['day'] = $holiday['mday'];
|
|
|
|
$this->ui->edit_holiday($errors,$holiday);
|
2001-07-28 15:17:30 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-02-27 20:28:25 +01:00
|
|
|
$this->so->save_holiday($holiday);
|
|
|
|
$this->ui->edit_locale($holiday['locale']);
|
2001-07-28 15:17:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-07-18 19:30:24 +02:00
|
|
|
function sort_holidays_by_date($holidays)
|
|
|
|
{
|
|
|
|
$c_holidays = count($holidays);
|
|
|
|
for($outer_loop=0;$outer_loop<($c_holidays - 1);$outer_loop++)
|
|
|
|
{
|
|
|
|
for($inner_loop=$outer_loop;$inner_loop<$c_holidays;$inner_loop++)
|
|
|
|
{
|
|
|
|
if($holidays[$outer_loop]['date'] > $holidays[$inner_loop]['date'])
|
|
|
|
{
|
|
|
|
$temp = $holidays[$inner_loop];
|
|
|
|
$holidays[$inner_loop] = $holidays[$outer_loop];
|
|
|
|
$holidays[$outer_loop] = $temp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $holidays;
|
|
|
|
}
|
|
|
|
|
|
|
|
function set_holidays_to_date($holidays)
|
|
|
|
{
|
|
|
|
$new_holidays = Array();
|
|
|
|
for($i=0;$i<count($holidays);$i++)
|
|
|
|
{
|
|
|
|
// echo "Setting Holidays Date : ".date('Ymd',$holidays[$i]['date'])."<br>\n";
|
|
|
|
$new_holidays[date('Ymd',$holidays[$i]['date'])][] = $holidays[$i];
|
|
|
|
}
|
|
|
|
return $new_holidays;
|
|
|
|
}
|
|
|
|
|
|
|
|
function read_holiday()
|
|
|
|
{
|
|
|
|
if(isset($this->cached_holidays))
|
|
|
|
{
|
|
|
|
return $this->cached_holidays;
|
|
|
|
}
|
2003-02-27 20:28:25 +01:00
|
|
|
$holidays = $this->so->read_holidays($this->locales,'','',$this->year);
|
2001-07-18 19:30:24 +02:00
|
|
|
|
|
|
|
if(count($holidays) == 0)
|
|
|
|
{
|
|
|
|
return $holidays;
|
|
|
|
}
|
|
|
|
|
2001-08-17 02:24:20 +02:00
|
|
|
$temp_locale = $GLOBALS['phpgw_info']['user']['preferences']['common']['country'];
|
2001-07-18 19:30:24 +02:00
|
|
|
for($i=0;$i<count($holidays);$i++)
|
|
|
|
{
|
|
|
|
$c = $i;
|
2001-09-11 05:05:51 +02:00
|
|
|
if($i == 0 || $holidays[$i]['locale'] != $holidays[$i - 1]['locale'])
|
|
|
|
{
|
|
|
|
if(is_object($holidaycalc))
|
|
|
|
{
|
|
|
|
unset($holidaycalc);
|
|
|
|
}
|
|
|
|
$GLOBALS['phpgw_info']['user']['preferences']['common']['country'] = $holidays[$i]['locale'];
|
|
|
|
$holidaycalc = CreateObject('calendar.holidaycalc');
|
|
|
|
}
|
2003-08-28 16:31:11 +02:00
|
|
|
$holidays[$i]['date'] = $holidaycalc->calculate_date($holidays[$i], $holidays, $this->year, $c);
|
2001-07-18 19:30:24 +02:00
|
|
|
if($c != $i)
|
|
|
|
{
|
|
|
|
$i = $c;
|
|
|
|
}
|
|
|
|
}
|
2001-09-11 05:05:51 +02:00
|
|
|
unset($holidaycalc);
|
2001-07-18 19:30:24 +02:00
|
|
|
$this->holidays = $this->sort_holidays_by_date($holidays);
|
|
|
|
$this->cached_holidays = $this->set_holidays_to_date($this->holidays);
|
2001-08-17 02:24:20 +02:00
|
|
|
$GLOBALS['phpgw_info']['user']['preferences']['common']['country'] = $temp_locale;
|
2001-07-18 19:30:24 +02:00
|
|
|
return $this->cached_holidays;
|
|
|
|
}
|
|
|
|
/* End Calendar functions */
|
2001-07-28 19:54:59 +02:00
|
|
|
|
|
|
|
function check_admin()
|
|
|
|
{
|
2001-08-17 02:24:20 +02:00
|
|
|
if(!@$GLOBALS['phpgw_info']['user']['apps']['admin'])
|
2001-07-28 19:54:59 +02:00
|
|
|
{
|
2001-08-17 02:24:20 +02:00
|
|
|
Header('Location: ' . $GLOBALS['phpgw']->link('/index.php'));
|
2001-07-28 19:54:59 +02:00
|
|
|
}
|
|
|
|
}
|
2003-02-27 20:28:25 +01:00
|
|
|
|
|
|
|
function rule_string($holiday)
|
|
|
|
{
|
|
|
|
if (!is_array($holiday))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$sbox = CreateObject('phpgwapi.sbox');
|
|
|
|
$month = $holiday['month'] ? lang($sbox->monthnames[$holiday['month']]) : '';
|
|
|
|
unset($sbox);
|
|
|
|
|
|
|
|
if (!$holiday['day'])
|
|
|
|
{
|
|
|
|
$occ = $holiday['occurence'] == 99 ? lang('last') : $holiday['occurence'].'.';
|
|
|
|
|
|
|
|
$dow_str = Array(lang('Sun'),lang('Mon'),lang('Tue'),lang('Wed'),lang('Thu'),lang('Fri'),lang('Sat'));
|
|
|
|
$dow = $dow_str[$holiday['dow']];
|
|
|
|
|
|
|
|
$str = lang('%1 %2 in %3',$occ,$dow,$month);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$str = $GLOBALS['phpgw']->common->dateformatorder($holiday['occurence']>1900?$holiday['occurence']:'',$month,$holiday[day]);
|
|
|
|
}
|
|
|
|
if ($holiday['observance_rule'])
|
|
|
|
{
|
|
|
|
$str .= ' ('.lang('Observance Rule').')';
|
|
|
|
}
|
|
|
|
return $str;
|
|
|
|
}
|
2001-07-18 19:30:24 +02:00
|
|
|
}
|
|
|
|
?>
|