cleanups to make more generic for iCal

This commit is contained in:
skeeter 2001-03-05 04:33:00 +00:00
parent 3f06a8752b
commit 2711d7ed03

View File

@ -301,7 +301,6 @@ class calendar extends calendar_
{ {
$rep_events = $this->repeating_events[$i]; $rep_events = $this->repeating_events[$i];
$id = $rep_events->id; $id = $rep_events->id;
$frequency = intval($rep_events->rpt_freq);
$start = $this->localdates($rep_events->datetime); $start = $this->localdates($rep_events->datetime);
if($rep_events->rpt_use_end) if($rep_events->rpt_use_end)
{ {
@ -311,83 +310,104 @@ class calendar extends calendar_
{ {
$enddate = $this->makegmttime(0,0,0,1,1,2007); $enddate = $this->makegmttime(0,0,0,1,1,2007);
} }
$full_event_date = date('Ymd',mktime(0,0,0,$rep_events->start->month,$rep_events->start->mday,$rep_events->start->year));
// only repeat after the beginning, and if there is an rpt_end before the end date // only repeat after the beginning, and if there is an rpt_end before the end date
if (($rep_events->rpt_use_end && ($date['full'] > $enddate['full'])) || if (($rep_events->rpt_use_end && ($date['full'] > $enddate['full'])) ||
($date['full'] < $start['full'])) ($date['full'] < $full_event_date))
{ {
continue; continue;
} }
if ($date['full'] == $start['full']) if ($date['full'] == $full_event_date)
{ {
$link[$this->repeating_event_matches++] = $id; $link[$this->repeating_event_matches++] = $id;
} }
elseif ($rep_events->rpt_type == 'daily')
{
if ((floor(($date['bd'] - $start['bd'])/86400) % $frequency))
{
continue;
}
else
{
$link[$this->repeating_event_matches++] = $id;
}
}
elseif ($rep_events->rpt_type == 'weekly')
{
$isDay = strtoupper(substr($rep_events->rpt_days, $date['dow'], 1));
if (floor(($date['bd'] - $start['bd'])/604800) % $frequency)
{
continue;
}
if (strcmp($isDay,'Y') == 0)
{
$link[$this->repeating_event_matches++] = $id;
}
}
elseif ($rep_events->rpt_type == 'monthlybyday')
{
if ((($date['year'] - $start['year']) * 12 + $date['month'] - $start['month']) % $frequency)
{
continue;
}
if (($start['dow'] == $date['dow']) &&
(ceil($start['day']/7) == ceil($date['day']/7)))
{
$link[$this->repeating_event_matches++] = $id;
}
}
elseif ($rep_events->rpt_type == 'monthlybydate')
{
if ((($date['year'] - $start['year']) * 12 + $date['month'] - $start['month']) % $frequency)
{
continue;
}
if ($date['day'] == $start['day'])
{
$link[$this->repeating_event_matches++] = $id;
}
}
elseif ($rep_events->rpt_type == 'yearly')
{
if (($date['year'] - $start['year']) % $frequency)
{
continue;
}
if ($date['dm'] == $start['dm'])
{
$link[$this->repeating_event_matches++] = $id;
}
}
else else
{ {
// unknown rpt type - because of all our else ifs switch($rep_events->recur_type)
{
case RECUR_DAILY:
if (floor(($date['bd'] - $start['bd'])/86400) % $rep_events->recur_interval)
{
continue;
}
else
{
$link[$this->repeating_event_matches++] = $id;
}
break;
case RECUR_WEEKLY:
$check = 0;
switch($date['dow'])
{
case 0:
$check = M_SUNDAY;
break;
case 1:
$check = M_MONDAY;
break;
case 2:
$check = M_TUESDAY;
break;
case 3:
$check = M_WEDNESDAY;
break;
case 4:
$check = M_THURSDAY;
break;
case 5:
$check = M_FRIDAY;
break;
case 6:
$check = M_SATURDAY;
break;
}
if (floor(($date['bd'] - $start['bd'])/604800) % $rep_events->recur_interval)
{
continue;
}
if ($rep_events->recur_data & $check)
{
$link[$this->repeating_event_matches++] = $id;
}
break;
case RECUR_MONTHLY_WDAY:
if ((($date['year'] - $rep_events->start->year) * 12 + $date['month'] - $rep_events->start->month) % $rep_events->recur_interval)
{
continue;
}
if (($this->day_of_week($rep_events->start->year,$rep_events->start->month,$rep_events->start->mday) == $date['dow']) &&
(ceil($rep_events->start->mday/7) == ceil($date['day']/7)))
{
$link[$this->repeating_event_matches++] = $id;
}
break;
case RECUR_MONTHLY_MDAY:
if ((($date['year'] - $rep_events->start->year) * 12 + $date['month'] - $rep_events->start->month) % $rep_events->recur_interval)
{
continue;
}
if ($date['day'] == $rep_events->start->mday)
{
$link[$this->repeating_event_matches++] = $id;
}
break;
case RECUR_YEARLY:
if (($date['year'] - $rep_events->start->year) % $rep_events->recur_interval)
{
continue;
}
if ($date['dm'] == date('dm',mktime(0,0,0,$rep_events->start->month,$rep_events->start->mday,$rep_events->start->year)))
{
$link[$this->repeating_event_matches++] = $id;
}
break;
}
} }
} // end for loop } // end for loop
@ -766,8 +786,11 @@ class calendar extends calendar_
for ($j=0;$j<7;$j++) for ($j=0;$j<7;$j++)
{ {
$date = $this->gmtdate($startdate + ($j * 24 * 3600)); $date = $this->gmtdate($startdate + ($j * 24 * 3600));
$p->set_var('column_data',''); $var = Array(
$p->set_var('extra',''); 'column_data' => '',
'extra' => ''
);
$p->set_var($var);
if ($weekly || ($date['full'] >= $monthstart && $date['full'] <= $monthend)) if ($weekly || ($date['full'] >= $monthstart && $date['full'] <= $monthend))
{ {
@ -778,36 +801,40 @@ class calendar extends calendar_
if ($date['full'] == $this->today['full']) if ($date['full'] == $this->today['full'])
{ {
$p->set_var('extra',' bgcolor="'.$phpgw_info['theme']['cal_today'].'"'); $extra = ' bgcolor="'.$phpgw_info['theme']['cal_today'].'"';
} }
else else
{ {
$p->set_var('extra',' bgcolor="'.$cellcolor.'"'); $extra = ' bgcolor="'.$cellcolor.'"';
} }
$new_event_link = '';
if (!$this->printer_friendly) if (!$this->printer_friendly)
{ {
$str = '';
if($this->check_perms(PHPGW_ACL_ADD) == True) if($this->check_perms(PHPGW_ACL_ADD) == True)
{ {
$str .= '<a href="'.$phpgw->link($phpgw_info['server']['webserver_url'].'/calendar/edit_entry.php','year='.$date_year.'&month='.$date['month'].'&day='.$date['day'].'&owner='.$this->owner).'">'; $new_event_link .= '<a href="'.$phpgw->link($phpgw_info['server']['webserver_url'].'/calendar/edit_entry.php','year='.$date_year.'&month='.$date['month'].'&day='.$date['day'].'&owner='.$this->owner).'">';
$str .= '<img src="'.$this->image_dir.'/new.gif" width="10" height="10" '; $new_event_link .= '<img src="'.$this->image_dir.'/new.gif" width="10" height="10" ';
$str .= 'alt="'.lang('New Entry').'" '; $new_event_link .= 'alt="'.lang('New Entry').'" ';
$str .= 'border="0" align="right">'; $new_event_link .= 'border="0" align="right">';
$str .= '</a>'; $new_event_link .= '</a>';
} }
$day_number = '<a href="'.$phpgw->link($phpgw_info['server']['webserver_url'].'/calendar/day.php','month='.$date['month'].'&day='.$date['day'].'&year='.$date['year'].'&owner='.$this->owner).'">'.$date['day'].'</a>';
$p->set_var('new_event_link',$str);
$str = '<a href="'.$phpgw->link($phpgw_info['server']['webserver_url'].'/calendar/day.php','month='.$date['month'].'&day='.$date['day'].'&year='.$date['year'].'&owner='.$this->owner).'">'.$date['day'].'</a>';
$p->set_var('day_number',$str);
} }
else else
{ {
$p->set_var('new_event_link',''); $day_number = $date['day'];
$p->set_var('day_number',$date['day']);
} }
$var = Array(
'extra' => $extra,
'new_event_link' => $new_event_link,
'day_number' => $day_number
);
$p->set_var($var);
$p->parse('column_data','month_day',True); $p->parse('column_data','month_day',True);
$rep_events = $this->get_sorted_by_date($date['raw'],$owner); $rep_events = $this->get_sorted_by_date($date['raw'],$owner);
@ -815,22 +842,24 @@ class calendar extends calendar_
if ($this->sorted_events_matching) if ($this->sorted_events_matching)
{ {
$lr_events = CreateObject('calendar.calendar_item'); $lr_events = CreateObject('calendar.calendar_item');
$p->set_var('week_day_font_size','2'); $var = Array(
$p->set_var('events',''); 'week_day_font_size' => '2',
'events' => ''
);
$p->set_var($var);
for ($k=0;$k<$this->sorted_events_matching;$k++) for ($k=0;$k<$this->sorted_events_matching;$k++)
{ {
$lr_events = $rep_events[$k]; $lr_events = $rep_events[$k];
$pict = 'circle.gif'; $pict = 'circle.gif';
for ($outer_loop=0;$outer_loop<count($this->repeated_events);$outer_loop++) if($lr_events->recur_type != RECUR_NONE)
{ {
$gr_events = $this->repeating_events[$outer_loop]; $pict = 'rpt.gif';
if ($gr_events->id == $lr_events->id)
{
$pict = 'rpt.gif';
}
} }
// if(count($lr_events->participants) > 1)
// {
// $pict = 'multi_1.gif';
// }
$p->set_var('link_entry','');
$description = $this->is_private($lr_events,$owner,'description'); $description = $this->is_private($lr_events,$owner,'description');
if (($this->printer_friendly == False) && (($description == 'private' && $this->check_perms(16)) || ($description != 'private')) && $this->check_perms(PHPGW_ACL_EDIT)) if (($this->printer_friendly == False) && (($description == 'private' && $this->check_perms(16)) || ($description != 'private')) && $this->check_perms(PHPGW_ACL_EDIT))
@ -844,6 +873,10 @@ class calendar extends calendar_
$p->set_var($var); $p->set_var($var);
$p->parse('link_entry','link_pict'); $p->parse('link_entry','link_pict');
} }
else
{
$p->set_var('link_entry','');
}
if (intval($phpgw->common->show_date($lr_events->datetime,'Hi'))) if (intval($phpgw->common->show_date($lr_events->datetime,'Hi')))
{ {
@ -856,7 +889,7 @@ class calendar extends calendar_
$format = 'H:i'; $format = 'H:i';
} }
if($lr_events->datetime < $date['raw'] && $lr_events->rpt_type=='none') if($lr_events->datetime < $date['raw'] && $lr_events->recur_type==RECUR_NONE)
{ {
$temp_time = $this->makegmttime(0,0,0,$date['month'],$date['day'],$date['year']); $temp_time = $this->makegmttime(0,0,0,$date['month'],$date['day'],$date['year']);
$start_time = $phpgw->common->show_date($temp_time['raw'],$format); $start_time = $phpgw->common->show_date($temp_time['raw'],$format);
@ -903,7 +936,7 @@ class calendar extends calendar_
} }
$p->parse('column_data','week_day_events',True); $p->parse('column_data','week_day_events',True);
$p->set_var('events',''); $p->set_var('events','');
if (!$j || ($j && $date["full"] == $monthstart)) if (!$j || ($j && $date['full'] == $monthstart))
{ {
if(!$this->printer_friendly) if(!$this->printer_friendly)
{ {