*
* http://www.radix.net/~cknudsen *
* Modified by Mark Peters count(day $v)=".count($daily)." Event: start='$start', v='$v'";
}
if ($start != $v) // this is an enddate-entry --> remove it
{
unset($this->cached_events[$v][$g]);
if ($start < $firstday) // start before period --> move it to the beginning
{
$this->cached_events[$firstday][] = $event;
if($this->debug)
{
echo "moved
\n"; }
if($session)
{
$this->read_sessiondata();
$this->use_session = True;
}
if($this->debug)
{
echo "BO Filter : (".$this->filter.")
\n";
echo "Owner : ".$this->owner."
\n";
}
if(isset($GLOBALS['owner']))
{
$this->owner = intval($GLOBALS['owner']);
}
elseif(!isset($this->owner) || !$this->owner)
{
$this->owner = $GLOBALS['phpgw_info']['user']['account_id'];
}
$this->prefs['common'] = $GLOBALS['phpgw_info']['user']['preferences']['common'];
$this->prefs['calendar'] = $GLOBALS['phpgw_info']['user']['preferences']['calendar'];
if ($this->prefs['common']['timeformat'] == '12')
{
$this->users_timeformat = 'h:i a';
}
else
{
$this->users_timeformat = 'H:i';
}
$this->holiday_color = (substr($GLOBALS['phpgw_info']['theme']['bg07'],0,1)=='#'?'':'#').$GLOBALS['phpgw_info']['theme']['bg07'];
$this->printer_friendly = ($GLOBALS['friendly'] == 1?True:False);
if(isset($GLOBALS['filter'])) { $this->filter = $GLOBALS['filter']; }
if(isset($GLOBALS['cat_id'])) { $this->cat_id = $GLOBALS['cat_id']; }
if(!isset($this->filter))
{
$this->filter = ' '.$this->prefs['calendar']['defaultfilter'].' ';
}
if(isset($GLOBALS['date']))
{
$this->year = intval(substr($GLOBALS['date'],0,4));
$this->month = intval(substr($GLOBALS['date'],4,2));
$this->day = intval(substr($GLOBALS['date'],6,2));
}
else
{
if(isset($GLOBALS['year']))
{
$this->year = $GLOBALS['year'];
}
elseif($this->year == 0)
{
$this->year = date('Y',time());
}
if(isset($GLOBALS['month']))
{
$this->month = $GLOBALS['month'];
}
elseif($this->month == 0)
{
$this->month = date('m',time());
}
if(isset($GLOBALS['day']))
{
$this->day = $GLOBALS['day'];
}
elseif($this->day == 0)
{
$this->day = date('d',time());
}
}
$this->so = CreateObject('calendar.socalendar',
Array(
'owner' => $this->owner,
'filter' => $this->filter,
'category' => $this->cat_id
)
);
$this->datetime = $this->so->datetime;
$this->today = date('Ymd',time());
if($this->debug)
{
echo "BO Filter : (".$this->filter.")
\n";
echo "Owner : ".$this->owner."
\n";
}
}
function save_sessiondata($data)
{
if ($this->use_session)
{
global $phpgw;
if($this->debug) { echo '
Save:'; _debug_array($data); }
$phpgw->session->appsession('session_data','calendar',$data);
}
}
function read_sessiondata()
{
global $GLOBALS;
$data = $GLOBALS['phpgw']->session->appsession('session_data','calendar');
if($this->debug) { echo '
Read:'; _debug_array($data); }
$this->filter = $data['filter'];
$this->cat_id = $data['cat_id'];
$this->owner = intval($data['owner']);
$this->year = intval($data['year']);
$this->month = intval($data['month']);
$this->day = intval($data['day']);
}
function read_entry($id)
{
if($this->check_perms(PHPGW_ACL_READ))
{
$event = $this->so->read_entry($id);
return $event;
}
}
function delete_entry($id)
{
if($this->check_perms(PHPGW_ACL_DELETE))
{
$temp_event = $this->read_entry($id);
if($this->owner == $temp_event['owner'])
{
$this->so->delete_entry($id);
$cd = 16;
}
else
{
$cd = 60;
}
}
return $cd;
}
function delete_calendar($owner)
{
global $GLOBALS;
if($GLOBALS['phpgw_info']['user']['apps']['admin'])
{
$this->so->delete_calendar($owner);
}
}
function change_owner($account_id,$new_owner)
{
global $GLOBALS;
if($GLOBALS['phpgw_info']['server']['calendar_type'] == 'sql')
{
$this->so->change_owner($account_id,$new_owner);
}
}
function expunge()
{
if($this->check_perms(PHPGW_ACL_DELETE))
{
reset($this->so->cal->delete_events);
for($i=0;$i
\n";
}
$ui = CreateObject('calendar.uicalendar');
if(isset($HTTP_GET_VARS['readsess']))
{
$event = $this->restore_from_appsession();
$datetime_check = $this->validate_update($event);
if($datetime_check)
{
$ui->edit(
Array(
'cd' => $datetime_check,
'readsess' => 1
)
);
}
$overlapping_events = False;
}
else
{
if(!$l_cal['id'] && !$this->check_perms(PHPGW_ACL_ADD))
{
$ui->index();
}
elseif($l_cal['id'] && !$this->check_perms(PHPGW_ACL_EDIT))
{
$ui->index();
}
$this->fix_update_time($l_start);
$this->fix_update_time($l_end);
if(!isset($l_cal['private']))
{
$l_cal['private'] = 'public';
}
$is_public = ($l_cal['private'] == 'public'?1:0);
$this->so->event_init();
$this->so->set_category($l_cal['category']);
$this->so->set_title($l_cal['title']);
$this->so->set_description($l_cal['description']);
$this->so->set_start($l_start['year'],$l_start['month'],$l_start['mday'],$l_start['hour'],$l_start['min'],0);
$this->so->set_end($l_end['year'],$l_end['month'],$l_end['mday'],$l_end['hour'],$l_end['min'],0);
$this->so->set_class($is_public);
if($l_cal['id'])
{
$this->so->add_attribute('id',$l_cal['id']);
}
if($l_cal['rpt_use_end'] != 'y')
{
$l_recur_enddate['year'] = 0;
$l_recur_enddate['month'] = 0;
$l_recur_enddate['mday'] = 0;
}
switch($l_cal['recur_type'])
{
case MCAL_RECUR_NONE:
$this->so->set_recur_none();
break;
case MCAL_RECUR_DAILY:
$this->so->set_recur_daily($l_recur_enddate['year'],$l_recur_enddate['month'],$l_recur_enddate['mday'],$l_cal['recur_interval']);
break;
case MCAL_RECUR_WEEKLY:
$cal['recur_data'] = $l_cal['rpt_sun'] + $l_cal['rpt_mon'] + $l_cal['rpt_tue'] + $l_cal['rpt_wed'] + $l_cal['rpt_thu'] + $l_cal['rpt_fri'] + $l_cal['rpt_sat'];
$this->so->set_recur_weekly($l_recur_enddate['year'],$l_recur_enddate['month'],$l_recur_enddate['mday'],$cal['recur_interval'],$cal['recur_data']);
break;
case MCAL_RECUR_MONTHLY_MDAY:
$this->so->set_recur_monthly_mday($l_recur_enddate['year'],$l_recur_enddate['month'],$l_recur_enddate['mday'],$l_cal['recur_interval']);
break;
case MCAL_RECUR_MONTHLY_WDAY:
$this->so->set_recur_monthly_wday($l_recur_enddate['year'],$l_recur_enddate['month'],$l_recur_enddate['mday'],$l_cal['recur_interval']);
break;
case MCAL_RECUR_YEARLY:
$this->so->set_recur_yearly($l_recur_enddate['year'],$l_recur_enddate['month'],$l_recur_enddate['mday'],$l_cal['recur_interval']);
break;
}
$parts = $l_participants;
$minparts = min($l_participants);
$part = Array();
for($i=0;$i
\n";
}
for($i=0;$i
\n";
}
$inserted = True;
break;
}
/* This puts all spanning events across multiple days up at the top. */
if($this->cached_events[$date][$i]['recur_type'] == MCAL_RECUR_NONE)
{
if($this->cached_events[$date][$i]['start']['mday'] != $day && $this->cached_events[$date][$i]['end']['mday'] >= $day)
{
continue;
}
}
if(date('Hi',mktime($event['start']['hour'],$event['start']['min'],$event['start']['sec'],$month,$day,$year)) < date('Hi',mktime($this->cached_events[$date][$i]['start']['hour'],$this->cached_events[$date][$i]['start']['min'],$this->cached_events[$date][$i]['start']['sec'],$month,$day,$year)))
{
for($j=count($this->cached_events[$date]);$j>=$i;$j--)
{
$this->cached_events[$date][$j] = $this->cached_events[$date][$j-1];
}
$inserted = True;
$this->cached_events[$date][$i] = $event;
break;
}
}
}
if(!$inserted)
{
$this->cached_events[$date][] = $event;
}
}
function check_repeating_events($datetime)
{
@reset($this->repeating_events);
$search_date_full = date('Ymd',$datetime);
$search_date_year = date('Y',$datetime);
$search_date_month = date('m',$datetime);
$search_date_day = date('d',$datetime);
$search_date_dow = date('w',$datetime);
$search_beg_day = mktime(0,0,0,$search_date_month,$search_date_day,$search_date_year);
$repeated = $this->repeating_events;
$r_events = count($repeated);
for ($i=0;$i<$r_events;$i++)
{
$rep_events = $this->repeating_events[$i];
$id = $rep_events->id;
$event_beg_day = mktime(0,0,0,$rep_events['start']['month'],$rep_events['start']['mday'],$rep_events['start']['year']);
if($rep_events['recur_enddate']['month'] != 0 && $rep_events['recur_enddate']['mday'] != 0 && $rep_events['recur_enddate']['year'] != 0)
{
$event_recur_time = $this->maketime($rep_events['recur_enddate']);
}
else
{
$event_recur_time = mktime(0,0,0,1,1,2030);
}
$end_recur_date = date('Ymd',$event_recur_time);
$full_event_date = date('Ymd',$event_beg_day);
// only repeat after the beginning, and if there is an rpt_end before the end date
if (($search_date_full > $end_recur_date) || ($search_date_full < $full_event_date))
{
continue;
}
if ($search_date_full == $full_event_date)
{
$this->sort_event($rep_events,$search_date_full);
continue;
}
else
{
$freq = $rep_events['recur_interval'];
$type = $rep_events['recur_type'];
switch($type)
{
case MCAL_RECUR_DAILY:
if (floor(($search_beg_day - $event_beg_day)/86400) % $freq)
{
continue;
}
else
{
$this->sort_event($rep_events,$search_date_full);
}
break;
case MCAL_RECUR_WEEKLY:
if (floor(($search_beg_day - $event_beg_day)/604800) % $freq)
{
continue;
}
$check = 0;
switch($search_date_dow)
{
case 0:
$check = MCAL_M_SUNDAY;
break;
case 1:
$check = MCAL_M_MONDAY;
break;
case 2:
$check = MCAL_M_TUESDAY;
break;
case 3:
$check = MCAL_M_WEDNESDAY;
break;
case 4:
$check = MCAL_M_THURSDAY;
break;
case 5:
$check = MCAL_M_FRIDAY;
break;
case 6:
$check = MCAL_M_SATURDAY;
break;
}
if ($rep_events['recur_data'] & $check)
{
$this->sort_event($rep_events,$search_date_full);
}
break;
case MCAL_RECUR_MONTHLY_WDAY:
if ((($search_date_year - $rep_events['start']['year']) * 12 + $search_date_month - $rep_events['start']['month']) % $freq)
{
continue;
}
if (($this->datetime->day_of_week($rep_events['start']['year'],$rep_events['start']['month'],$rep_events['start']['mday']) == $this->datetime->day_of_week($search_date_year,$search_date_month,$search_date_day)) &&
(ceil($rep_events['start']['mday']/7) == ceil($search_date_day/7)))
{
$this->sort_event($rep_events,$search_date_full);
}
break;
case MCAL_RECUR_MONTHLY_MDAY:
if ((($search_date_year - $rep_events['start']['year']) * 12 + $search_date_month - $rep_events['start']['month']) % $freq)
{
continue;
}
if ($search_date_day == $rep_events['start']['mday'])
{
$this->sort_event($rep_events,$search_date_full);
}
break;
case MCAL_RECUR_YEARLY:
if (($search_date_year - $rep_events['start']['year']) % $freq)
{
continue;
}
if (date('dm',$datetime) == date('dm',$event_beg_day))
{
$this->sort_event($rep_events,$search_date_full);
}
break;
}
}
} // end for loop
} // end function
function store_to_cache($syear,$smonth,$sday,$eyear=0,$emonth=0,$eday=0)
{
if(!$eyear && !$emonth && !$eday)
{
$edate = mktime(23,59,59,$smonth + 1,$sday + 1,$syear);
$eyear = date('Y',$edate);
$emonth = date('m',$edate);
$eday = date('d',$edate);
}
else
{
if(!$eyear)
{
$eyear = $syear;
}
if(!$emonth)
{
$emonth = $smonth + 1;
}
if(!$eday)
{
$eday = $sday + 1;
}
$edate = mktime(23,59,59,$emonth,$eday,$eyear);
}
if($this->debug)
{
echo "Start Date : ".sprintf("%04d%02d%02d",$syear,$smonth,$sday)."
\n";
echo "End Date : ".sprintf("%04d%02d%02d",$eyear,$emonth,$eday)."
\n";
}
$cached_event_ids = $this->so->list_events($syear,$smonth,$sday,$eyear,$emonth,$eday);
$cached_event_ids_repeating = $this->so->list_repeated_events($syear,$smonth,$sday,$eyear,$emonth,$eday);
$c_cached_ids = count($cached_event_ids);
$c_cached_ids_repeating = count($cached_event_ids_repeating);
if($this->debug)
{
echo "events cached : $c_cached_ids : for : ".sprintf("%04d%02d%02d",$syear,$smonth,$sday)."
\n";
echo "repeating events cached : $c_cached_ids_repeating : for : ".sprintf("%04d%02d%02d",$syear,$smonth,$sday)."
\n";
}
$this->cached_events = Array();
if($c_cached_ids == 0 && $c_cached_ids_repeating == 0)
{
return;
}
$this->cached_events = Array();
if($c_cached_ids)
{
for($i=0;$i<$c_cached_ids;$i++)
{
$event = $this->so->read_entry($cached_event_ids[$i]);
$startdate = intval(date('Ymd',$this->maketime($event['start'])));
$enddate = intval(date('Ymd',$this->maketime($event['end'])));
$this->cached_events[$startdate][] = $event;
if($startdate != $enddate)
{
$start['year'] = intval(substr($startdate,0,4));
$start['month'] = intval(substr($startdate,4,2));
$start['mday'] = intval(substr($startdate,6,2));
for($j=$startdate,$k=0;$j<=$enddate;$k++,$j=intval(date('Ymd',mktime(0,0,0,$start['month'],$start['mday'] + $k,$start['year']))))
{
$c_evt_day = count($this->cached_events[$j]) - 1;
// if($c_evt_day < 0)
// {
// $c_evt_day = 0;
// }
if($this->debug)
{
echo "Date: ".$j." Count : ".$c_evt_day."
\n";
}
if($this->cached_events[$j][$c_evt_day]['id'] != $event['id'])
{
if($this->debug)
{
echo "Adding Event for Date: ".$j."
\n";
}
$this->cached_events[$j][] = $event;
}
}
}
}
}
$this->repeating_events = Array();
if($c_cached_ids_repeating)
{
for($i=0;$i<$c_cached_ids_repeating;$i++)
{
$this->repeating_events[$i] = $this->so->read_entry($cached_event_ids_repeating[$i]);
}
$edate -= $this->datetime->tz_offset;
for($date=mktime(0,0,0,$smonth,$sday,$syear) - $this->datetime->tz_offset;$date<$edate;$date += 86400)
{
$this->check_repeating_events($date);
}
}
return $this->cached_events;
}
/* Begin Appsession Data */
function store_to_appsession($event)
{
global $GLOBALS;
$GLOBALS['phpgw']->session->appsession('entry','calendar',$event);
}
function restore_from_appsession()
{
global $GLOBALS;
$this->event_init();
// $event = unserialize(str_replace('O:8:"stdClass"','O:13:"calendar_time"',serialize($GLOBALS['phpgw']->session->appsession('entry','calendar'))));
$event = $GLOBALS['phpgw']->session->appsession('entry','calendar');
$this->so->cal->event = $event;
return $event;
}
/* End Appsession Data */
/* Begin of SO functions */
function get_cached_event()
{
return $this->so->get_cached_event();
}
function add_attribute($var,$value)
{
$this->so->add_attribute($var,$value);
}
function event_init()
{
$this->so->event_init();
}
function set_start($year,$month,$day=0,$hour=0,$min=0,$sec=0)
{
$this->so->set_start($year,$month,$day,$hour,$min,$sec);
}
function set_end($year,$month,$day=0,$hour=0,$min=0,$sec=0)
{
$this->so->set_end($year,$month,$day,$hour,$min,$sec);
}
function set_title($title='')
{
$this->so->set_title($title);
}
function set_description($description='')
{
$this->so->set_description($description);
}
function set_class($class)
{
$this->so->set_class($class);
}
function set_category($category='')
{
$this->so->set_category($category);
}
function set_alarm($alarm)
{
$this->so->set_alarm($alarm);
}
function set_recur_none()
{
$this->so->set_recur_none();
}
function set_recur_daily($year,$month,$day,$interval)
{
$this->so->set_recur_daily($year,$month,$day,$interval);
}
function set_recur_weekly($year,$month,$day,$interval,$weekdays)
{
$this->so->set_recur_weekly($year,$month,$day,$interval,$weekdays);
}
function set_recur_monthly_mday($year,$month,$day,$interval)
{
$this->so->set_recur_monthly_mday($year,$month,$day,$interval);
}
function set_recur_monthly_wday($year,$month,$day,$interval)
{
$this->so->set_recur_monthly_wday($year,$month,$day,$interval);
}
function set_recur_yearly($year,$month,$day,$interval)
{
$this->so->set_recur_yearly($year,$month,$day,$interval);
}
/* End of SO functions */
function set_week_array($startdate,$cellcolor,$weekly)
{
global $GLOBALS, $phpgw, $phpgw_info;
for ($j=0,$datetime=$startdate - $this->datetime->tz_offset;$j<7;$j++,$datetime += 86400)
{
$date = date('Ymd',$datetime);
if($this->debug)
{
echo "set_week_array : Date : ".$date."
\n";
}
$holidays = $this->cached_holidays[$date];
if($weekly)
{
$cellcolor = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($cellcolor);
}
$day_image = '';
if($holidays)
{
$extra = ' bgcolor="'.$this->holiday_color.'"';
$class = 'minicalhol';
if ($date == $this->today)
{
$day_image = ' background="'.$GLOBALS['phpgw']->common->image('calendar','mini_day_block.gif').'"';
}
}
elseif ($date != $this->today)
{
$extra = ' bgcolor="'.$cellcolor.'"';
$class = 'minicalendar';
}
else
{
$extra = ' bgcolor="'.$GLOBALS['phpgw_info']['theme']['cal_today'].'"';
$class = 'minicalendar';
$day_image = ' background="'.$GLOBALS['phpgw']->common->image('calendar','mini_day_block.gif').'"';
}
if($this->printer_friendly && @$this->prefs['calendar']['print_black_white'])
{
$extra = '';
}
if(!$this->printer_friendly && $this->check_perms(PHPGW_ACL_ADD))
{
$new_event = True;
}
else
{
$new_event = False;
}
$holiday_name = Array();
if($holidays)
{
for($k=0;$k
\n";
}
$appts = True;
}
else
{
$appts = False;
}
$week = '';
if (!$j || ($j && substr($date,6,2) == '01'))
{
$week = 'week ' .(int)((date('z',($startdate+(24*3600*4)))+7)/7);
}
$daily[$date] = Array(
'extra' => $extra,
'new_event' => $new_event,
'holidays' => $holiday_name,
'appts' => $appts,
'week' => $week,
'day_image' => $day_image,
'class' => $class
);
}
if($this->debug)
{
$this->_debug_array($daily);
}
return $daily;
}
function prepare_matrix($interval,$increment,$part,$status,$fulldate)
{
global $GLOBALS;
for($h=0;$h<24;$h++)
{
for($m=0;$m<$interval;$m++)
{
$index = (($h * 10000) + (($m * $increment) * 100));
$time_slice[$index]['marker'] = ' ';
$time_slice[$index]['description'] = '';
}
}
for($k=0;$k
\n";
echo "userid = ".$userid."
\n";
}
if(!is_object($send))
{
$send = CreateObject('phpgwapi.send');
}
$preferences = CreateObject('phpgwapi.preferences',intval($userid));
$part_prefs = $preferences->read_repository();
if(!isset($part_prefs['calendar']['send_updates']) || !$part_prefs['calendar']['send_updates'])
{
continue;
}
$part_prefs = $GLOBALS['phpgw']->common->create_emailpreferences($part_prefs,intval($userid));
$to = $part_prefs['email']['address'];
if($this->debug)
{
echo "Email being sent to: ".$to."
\n";
}
$GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset'] = $part_prefs['common']['tz_offset'];
$GLOBALS['phpgw_info']['user']['preferences']['common']['timeformat'] = $part_prefs['common']['timeformat'];
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'] = $part_prefs['common']['dateformat'];
$new_tz_offset = ((60 * 60) * intval($GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset']));
if($old_event != False)
{
$old_event_date = $GLOBALS['phpgw']->common->show_date($old_event_datetime);
}
if($new_event != False)
{
$new_event_date = $GLOBALS['phpgw']->common->show_date($new_event_datetime);
}
switch($msg_type)
{
case MSG_DELETED:
$action_date = $old_event_date;
$body = 'Your meeting scehduled for '.$old_event_date.' has been canceled';
break;
case MSG_MODIFIED:
$action_date = $new_event_date;
$body = 'Your meeting that had been scheduled for '.$old_event_date.' has been rescheduled to '.$new_event_date;
break;
case MSG_ADDED:
$action_date = $new_event_date;
$body = 'You have a meeting scheduled for '.$new_event_date;
break;
case MSG_REJECTED:
case MSG_TENTATIVE:
case MSG_ACCEPTED:
$action_date = $old_event_date;
$body = 'On '.$phpgw->common->show_date(time() - $new_tz_offset).' '.$phpgw->common->grab_owner_name($phpgw_info['user']['account_id']).' '.$action.' your meeting request for '.$old_event_date;
break;
}
$subject = 'Calendar Event ('.$action.') #'.$event_id.': '.$action_date.' (L)';
$returncode = $send->msg('email',$to,$subject,$body,$msgtype,'','','',$sender);
}
}
unset($send);
if((is_int($this->user) && $this->user != $temp_user['account_id']) ||
(is_string($this->user) && $this->user != $temp_user['account_lid']))
{
$GLOBALS['phpgw_info']['user'] = $temp_user;
}
$GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset'] = $temp_tz_offset;
$GLOBALS['phpgw_info']['user']['preferences']['common']['timeformat'] = $temp_timeformat;
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'] = $temp_dateformat;
}
function prepare_recipients(&$new_event,$old_event)
{
// Find modified and deleted users.....
while(list($old_userid,$old_status) = each($old_event['participants']))
{
if(isset($new_event['participants'][$old_userid]))
{
if($this->debug)
{
echo "Modifying event for user ".$old_userid."
\n";
}
$this->modified[intval($old_userid)] = $new_status;
}
else
{
if($this->debug)
{
echo "Deleting user ".$old_userid." from the event
\n";
}
$this->deleted[intval($old_userid)] = $old_status;
}
}
// Find new users.....
while(list($new_userid,$new_status) = each($new_event['participants']))
{
if(!isset($old_event['participants'][$new_userid]))
{
if($this->debug)
{
echo "Adding event for user ".$new_userid."
\n";
}
$this->added[$new_userid] = 'U';
$new_event['participants'][$new_userid] = 'U';
}
}
if(count($this->added) > 0 || count($this->modified) > 0 || count($this->deleted) > 0)
{
if(count($this->added) > 0)
{
$this->send_update(MSG_ADDED,$this->added,'',$new_event);
}
if(count($this->modified) > 0)
{
$this->send_update(MSG_MODIFIED,$this->modified,$old_event,$new_event);
}
if(count($this->deleted) > 0)
{
$this->send_update(MSG_DELETED,$this->deleted,$old_event);
}
}
}
function remove_doubles_in_cache($firstday,$lastday)
{
for($v=$firstday;$v<=$lastday;$v += 1)
{
$daily = $this->cached_events[$v];
if($this->debug)
{
echo "
"; print_r($event); echo "