forked from extern/egroupware
cleanups to make more generic for iCal
This commit is contained in:
parent
3f06a8752b
commit
2711d7ed03
@ -301,7 +301,6 @@ class calendar extends calendar_
|
||||
{
|
||||
$rep_events = $this->repeating_events[$i];
|
||||
$id = $rep_events->id;
|
||||
$frequency = intval($rep_events->rpt_freq);
|
||||
$start = $this->localdates($rep_events->datetime);
|
||||
if($rep_events->rpt_use_end)
|
||||
{
|
||||
@ -311,21 +310,25 @@ class calendar extends calendar_
|
||||
{
|
||||
$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
|
||||
if (($rep_events->rpt_use_end && ($date['full'] > $enddate['full'])) ||
|
||||
($date['full'] < $start['full']))
|
||||
($date['full'] < $full_event_date))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($date['full'] == $start['full'])
|
||||
if ($date['full'] == $full_event_date)
|
||||
{
|
||||
$link[$this->repeating_event_matches++] = $id;
|
||||
}
|
||||
elseif ($rep_events->rpt_type == 'daily')
|
||||
else
|
||||
{
|
||||
if ((floor(($date['bd'] - $start['bd'])/86400) % $frequency))
|
||||
switch($rep_events->recur_type)
|
||||
{
|
||||
case RECUR_DAILY:
|
||||
if (floor(($date['bd'] - $start['bd'])/86400) % $rep_events->recur_interval)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -333,61 +336,78 @@ class calendar extends calendar_
|
||||
{
|
||||
$link[$this->repeating_event_matches++] = $id;
|
||||
}
|
||||
}
|
||||
elseif ($rep_events->rpt_type == 'weekly')
|
||||
break;
|
||||
case RECUR_WEEKLY:
|
||||
$check = 0;
|
||||
switch($date['dow'])
|
||||
{
|
||||
$isDay = strtoupper(substr($rep_events->rpt_days, $date['dow'], 1));
|
||||
|
||||
if (floor(($date['bd'] - $start['bd'])/604800) % $frequency)
|
||||
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 (strcmp($isDay,'Y') == 0)
|
||||
if ($rep_events->recur_data & $check)
|
||||
{
|
||||
$link[$this->repeating_event_matches++] = $id;
|
||||
}
|
||||
}
|
||||
elseif ($rep_events->rpt_type == 'monthlybyday')
|
||||
{
|
||||
if ((($date['year'] - $start['year']) * 12 + $date['month'] - $start['month']) % $frequency)
|
||||
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 (($start['dow'] == $date['dow']) &&
|
||||
(ceil($start['day']/7) == ceil($date['day']/7)))
|
||||
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;
|
||||
}
|
||||
}
|
||||
elseif ($rep_events->rpt_type == 'monthlybydate')
|
||||
{
|
||||
if ((($date['year'] - $start['year']) * 12 + $date['month'] - $start['month']) % $frequency)
|
||||
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'] == $start['day'])
|
||||
if ($date['day'] == $rep_events->start->mday)
|
||||
{
|
||||
$link[$this->repeating_event_matches++] = $id;
|
||||
}
|
||||
}
|
||||
elseif ($rep_events->rpt_type == 'yearly')
|
||||
{
|
||||
if (($date['year'] - $start['year']) % $frequency)
|
||||
break;
|
||||
case RECUR_YEARLY:
|
||||
if (($date['year'] - $rep_events->start->year) % $rep_events->recur_interval)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($date['dm'] == $start['dm'])
|
||||
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;
|
||||
}
|
||||
else
|
||||
{
|
||||
// unknown rpt type - because of all our else ifs
|
||||
}
|
||||
} // end for loop
|
||||
|
||||
@ -766,8 +786,11 @@ class calendar extends calendar_
|
||||
for ($j=0;$j<7;$j++)
|
||||
{
|
||||
$date = $this->gmtdate($startdate + ($j * 24 * 3600));
|
||||
$p->set_var('column_data','');
|
||||
$p->set_var('extra','');
|
||||
$var = Array(
|
||||
'column_data' => '',
|
||||
'extra' => ''
|
||||
);
|
||||
$p->set_var($var);
|
||||
|
||||
if ($weekly || ($date['full'] >= $monthstart && $date['full'] <= $monthend))
|
||||
{
|
||||
@ -778,36 +801,40 @@ class calendar extends calendar_
|
||||
|
||||
if ($date['full'] == $this->today['full'])
|
||||
{
|
||||
$p->set_var('extra',' bgcolor="'.$phpgw_info['theme']['cal_today'].'"');
|
||||
$extra = ' bgcolor="'.$phpgw_info['theme']['cal_today'].'"';
|
||||
}
|
||||
else
|
||||
{
|
||||
$p->set_var('extra',' bgcolor="'.$cellcolor.'"');
|
||||
$extra = ' bgcolor="'.$cellcolor.'"';
|
||||
}
|
||||
|
||||
$new_event_link = '';
|
||||
if (!$this->printer_friendly)
|
||||
{
|
||||
$str = '';
|
||||
|
||||
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).'">';
|
||||
$str .= '<img src="'.$this->image_dir.'/new.gif" width="10" height="10" ';
|
||||
$str .= 'alt="'.lang('New Entry').'" ';
|
||||
$str .= 'border="0" align="right">';
|
||||
$str .= '</a>';
|
||||
$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).'">';
|
||||
$new_event_link .= '<img src="'.$this->image_dir.'/new.gif" width="10" height="10" ';
|
||||
$new_event_link .= 'alt="'.lang('New Entry').'" ';
|
||||
$new_event_link .= 'border="0" align="right">';
|
||||
$new_event_link .= '</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);
|
||||
$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>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$p->set_var('new_event_link','');
|
||||
$p->set_var('day_number',$date['day']);
|
||||
$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);
|
||||
|
||||
$rep_events = $this->get_sorted_by_date($date['raw'],$owner);
|
||||
@ -815,22 +842,24 @@ class calendar extends calendar_
|
||||
if ($this->sorted_events_matching)
|
||||
{
|
||||
$lr_events = CreateObject('calendar.calendar_item');
|
||||
$p->set_var('week_day_font_size','2');
|
||||
$p->set_var('events','');
|
||||
$var = Array(
|
||||
'week_day_font_size' => '2',
|
||||
'events' => ''
|
||||
);
|
||||
$p->set_var($var);
|
||||
for ($k=0;$k<$this->sorted_events_matching;$k++)
|
||||
{
|
||||
$lr_events = $rep_events[$k];
|
||||
$pict = 'circle.gif';
|
||||
for ($outer_loop=0;$outer_loop<count($this->repeated_events);$outer_loop++)
|
||||
{
|
||||
$gr_events = $this->repeating_events[$outer_loop];
|
||||
if ($gr_events->id == $lr_events->id)
|
||||
if($lr_events->recur_type != RECUR_NONE)
|
||||
{
|
||||
$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');
|
||||
|
||||
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->parse('link_entry','link_pict');
|
||||
}
|
||||
else
|
||||
{
|
||||
$p->set_var('link_entry','');
|
||||
}
|
||||
|
||||
if (intval($phpgw->common->show_date($lr_events->datetime,'Hi')))
|
||||
{
|
||||
@ -856,7 +889,7 @@ class calendar extends calendar_
|
||||
$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']);
|
||||
$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->set_var('events','');
|
||||
if (!$j || ($j && $date["full"] == $monthstart))
|
||||
if (!$j || ($j && $date['full'] == $monthstart))
|
||||
{
|
||||
if(!$this->printer_friendly)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user