repeating events work correctly now

This commit is contained in:
skeeter 2001-01-26 13:15:38 +00:00
parent 14399c60c4
commit 6f0c6678be

View File

@ -16,7 +16,7 @@
class calendar class calendar
{ {
var $today = Array("raw","day","month","year","full","dow","dm"); var $today = Array("raw","day","month","year","full","dow","dm","bd");
var $printer_friendly = False; var $printer_friendly = False;
var $repeated_events; var $repeated_events;
var $checked_events; var $checked_events;
@ -179,12 +179,13 @@
global $phpgw; global $phpgw;
global $phpgw_info; global $phpgw_info;
$date = Array("raw","day","month","year","full","dow","dm"); $date = Array("raw","day","month","year","full","dow","dm","bd");
$date["raw"] = $localtime; $date["raw"] = $localtime;
$date["year"] = intval($phpgw->common->show_date($date["raw"],"Y")); $date["year"] = intval($phpgw->common->show_date($date["raw"],"Y"));
$date["month"] = intval($phpgw->common->show_date($date["raw"],"m")); $date["month"] = intval($phpgw->common->show_date($date["raw"],"m"));
$date["day"] = intval($phpgw->common->show_date($date["raw"],"d")); $date["day"] = intval($phpgw->common->show_date($date["raw"],"d"));
$date["full"] = intval($phpgw->common->show_date($date["raw"],"Ymd")); $date["full"] = intval($phpgw->common->show_date($date["raw"],"Ymd"));
$date["bd"] = mktime(0,0,0,$date["month"],$date["day"],$date["year"]);
$date["dm"] = intval($phpgw->common->show_date($date["raw"],"dm")); $date["dm"] = intval($phpgw->common->show_date($date["raw"],"dm"));
$date["dow"] = intval($phpgw->common->show_date($date["raw"],"w")); $date["dow"] = intval($phpgw->common->show_date($date["raw"],"w"));
$date["hour"] = intval($phpgw->common->show_date($date["raw"],"H")); $date["hour"] = intval($phpgw->common->show_date($date["raw"],"H"));
@ -545,24 +546,20 @@
$link[$this->checked_re] = $i; $link[$this->checked_re] = $i;
$this->checked_re++; $this->checked_re++;
} elseif ($rep_events->rpt_type == 'daily') { } elseif ($rep_events->rpt_type == 'daily') {
if ((floor(($date["raw"] - $start["raw"])/86400) % $frequency)) { if ((floor(($date["bd"] - $start["bd"])/86400) % $frequency)){
continue; continue;
} } else {
$link[$this->checked_re++] = $i; $link[$this->checked_re++] = $i;
// $this->checked_re++; // $this->checked_re++;
}
} elseif ($rep_events->rpt_type == 'weekly') { } elseif ($rep_events->rpt_type == 'weekly') {
$isDay = strtoupper(substr($rep_events->rpt_days, $date["dow"], 1)); $isDay = strtoupper(substr($rep_events->rpt_days, $date["dow"], 1));
if (floor(($date["bd"] - $start["bd"])/604800) % $frequency) {
/*if ( (floor($diff/86400) % $this->rep_events->rpt_freq) ) // Whats this for ?
** continue;
*/
if (floor(($date["raw"] - $start["raw"])/604800) % $frequency) {
continue; 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') { } elseif ($rep_events->rpt_type == 'monthlybyday') {
if ((($date["year"] - $start["year"]) * 12 + $date["month"] - $start["month"]) % $frequency) { if ((($date["year"] - $start["year"]) * 12 + $date["month"] - $start["month"]) % $frequency) {
@ -571,24 +568,24 @@
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++;
} }
} elseif ($rep_events->rpt_type == 'monthlybydate') { } elseif ($rep_events->rpt_type == 'monthlybydate') {
if ((($date["year"] - $start["year"]) * 12 + $date["month"] - $start["month"]) % $frequency) { if ((($date["year"] - $start["year"]) * 12 + $date["month"] - $start["month"]) % $frequency) {
continue; continue;
} }
if ($date["day"] == $start["day"]) { if ($date["day"] == $start["day"]) {
$link[$this->checked_re] = $i; $link[$this->checked_re++] = $i;
$this->checked_re++; // $this->checked_re++;
} }
} elseif ($rep_events->rpt_type == 'yearly') { } elseif ($rep_events->rpt_type == 'yearly') {
if (($date["year"] - $start["year"]) % $frequency) { if (($date["year"] - $start["year"]) % $frequency) {
continue; continue;
} }
if ($date["dm"] == $start["dm"]) { if ($date["dm"] == $start["dm"]) {
$link[$this->checked_re] = $i; $link[$this->checked_re++] = $i;
$this->checked_re++; // $this->checked_re++;
} }
} else { } else {
// unknown rpt type - because of all our else ifs // unknown rpt type - because of all our else ifs