semi-fix for repeating events

This commit is contained in:
skeeter 2001-01-22 17:48:51 +00:00
parent db8884dfe7
commit f9f160b3eb

View File

@ -522,74 +522,82 @@
$this->checked_re = 0; $this->checked_re = 0;
if(!$this->re) return False; if(!$this->re) return False;
$link = Array(); $link = Array();
$date = $this->gmtdate($datetime); // $date = $this->gmtdate($datetime);
$date = $this->localdates($datetime);
for ($i=0;$i<$this->re;$i++) { for ($i=0;$i<$this->re;$i++) {
$rep_events = $this->repeated_events[$i]; $rep_events = $this->repeated_events[$i];
$start = $this->localdates($rep_events->datetime); $start = $this->localdates($rep_events->datetime);
if($rep_events->rpt_use_end) if($rep_events->rpt_use_end)
$end = $rep_events->rpt_end; $enddate = $this->gmtdate($rep_events->rpt_end);
else else
$end = mktime(0,0,0,1,1,2007) - ((60 * 60) * $phpgw_info["users"]["preferences"]["common"]["tz_offset"]); $enddate = $this->makegmttime(0,0,0,1,1,2007);
// 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"])) {
continue;
}
$enddate = $this->localdates($end); if ($date["full"] <= $start["full"]) {
// only repeat after the beginning, and if there is an end continue;
// before the end }
if ($rep_events->rpt_use_end && ($date["full"] > $enddate["full"])) {
continue;
}
if ($date["full"] < $start["full"]) { if ($date["full"] == $start["full"]) {
continue; $link[$this->checked_re] = $i;
} $this->checked_re++;
} elseif ($rep_events->rpt_type == 'daily') {
if (floor(($date["raw"] - $start["raw"])/86400) % intval($rep_events->rpt_freq)) {
continue;
}
$link[$this->checked_re] = $i;
$this->checked_re++;
} elseif ($rep_events->rpt_type == 'weekly') {
$isDay = strtoupper(substr($rep_events->rpt_days, $date["dow"], 1));
if ($date["full"] == $start["full"]) { /*if ( (floor($diff/86400) % $this->rep_events->rpt_freq) ) // Whats this for ?
$link[$this->checked_re] = $i; ** continue;
$this->checked_re++; */
} else if ($rep_events->rpt_type == 'daily') {
if (floor(($date["raw"] - $start["raw"])/86400) % intval($rep_events->rpt_freq))
continue;
$link[$this->checked_re] = $i;
$this->checked_re++;
} else if ($rep_events->rpt_type == 'weekly') {
$isDay = strtoupper(substr($rep_events->rpt_days, $date["dow"], 1));
/*if ( (floor($diff/86400) % $this->rep_events->rpt_freq) ) // Whats this for ? if (floor(($date["raw"] - $start["raw"])/604800) % intval($rep_events->rpt_freq)) {
** continue; continue;
*/ }
if (floor(($date["raw"] - $start["raw"])/604800) % intval($rep_events->rpt_freq)) continue; if (strcmp($isDay,"Y") == 0) {
if (strcmp($isDay,"Y") == 0) { $link[$this->checked_re] = $i;
$link[$this->checked_re] = $i; $this->checked_re++;
$this->checked_re++; }
} } elseif ($rep_events->rpt_type == 'monthlybyday') {
} else if ($rep_events->rpt_type == 'monthlybyday') { if ((($date["year"] - $start["year"]) * 12 + $date["month"] - $start["month"]) % intval($rep_events->rpt_freq)) {
if ((($date["year"] - $start["year"]) * 12 + $date["month"] - $start["month"]) % intval($rep_events->rpt_freq)) continue; continue;
}
if (($start["dow"] == $date["dow"]) && if (($start["dow"] == $date["dow"]) &&
(ceil($start["day"]/7) == ceil($date["day"]/7))) { (ceil($start["day"]/7) == ceil($date["day"]/7))) {
$link[$this->checked_re] = $i; $link[$this->checked_re] = $i;
$this->checked_re++; $this->checked_re++;
} }
} else if ($rep_events->rpt_type == 'monthlybydate') { } elseif ($rep_events->rpt_type == 'monthlybydate') {
if ((($date["year"] - $start["year"]) * 12 + $date["month"] - $start["month"]) % intval($rep_events->rpt_freq)) continue; if ((($date["year"] - $start["year"]) * 12 + $date["month"] - $start["month"]) % intval($rep_events->rpt_freq)) {
if ($date["day"] == $start["day"]) { continue;
$link[$this->checked_re] = $i; }
$this->checked_re++; if ($date["day"] == $start["day"]) {
} $link[$this->checked_re] = $i;
} else if ($rep_events->rpt_type == 'yearly') { $this->checked_re++;
if (($date["year"] - $start["year"]) % intval($rep_events->rpt_freq)) continue; }
if ($date["dm"] == $start["dm"]) { } elseif ($rep_events->rpt_type == 'yearly') {
$link[$this->checked_re] = $i; if (($date["year"] - $start["year"]) % intval($rep_events->rpt_freq)) {
$this->checked_re++; continue;
} }
} else { if ($date["dm"] == $start["dm"]) {
// unknown rpt type - because of all our else ifs $link[$this->checked_re] = $i;
} $this->checked_re++;
}
} else {
// unknown rpt type - because of all our else ifs
}
} // end for loop } // end for loop
if($this->checked_re) { if($this->checked_re) {
return $link; return $link;
} else { } else {
return False; return False;
} }
} // end function } // end function
@ -770,7 +778,7 @@
} else { } else {
$format = "H:i"; $format = "H:i";
} }
if($lr_events->datetime < $date["raw"]) { if($lr_events->datetime < $date["raw"] && $lr_events->rpt_type=="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);
} else { } else {