Skip to content

Commit

Permalink
Fix bug when exporting series (bug introduced in recent merge)
Browse files Browse the repository at this point in the history
  • Loading branch information
campbell-m committed Aug 9, 2023
1 parent ec86eb9 commit c340d33
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions web/lib/MRBS/ICalendar/Series.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,30 @@ class Series
// of the series. Defaults to null, ie no limit. This enables the series extract to be truncated.
public function __construct(array $row, int $limit=null)
{
// Construct the repeat rule and add it to the row
$repeat_rule = new RepeatRule();
$repeat_rule->setType($row['rep_type']);
$repeat_rule->setInterval($row['rep_interval']);
$repeat_end_date = new DateTime();
$repeat_end_date->setTimestamp($row['end_date']);
$repeat_rule->setEndDate($repeat_end_date);
$repeat_rule->setDaysFromOpt($row['rep_opt']);
if ($repeat_rule->getType() == RepeatRule::MONTHLY)
{
if (isset($row['month_absolute'])) {
$repeat_rule->setMonthlyAbsolute($row['month_absolute']);
$repeat_rule->setMonthlyType(RepeatRule::MONTHLY_ABSOLUTE);
}
elseif (isset($row['month_relative'])) {
$repeat_rule->setMonthlyRelative($row['month_relative']);
$repeat_rule->setMonthlyType(RepeatRule::MONTHLY_RELATIVE);
}
else {
throw new Exception("The repeat type is monthly but both the absolute and relative days are null.");
}
}
$row['repeat_rule'] = $repeat_rule;

$this->data = array();
$this->repeat_id = $row['repeat_id'];

Expand All @@ -47,28 +71,6 @@ public function __construct(array $row, int $limit=null)

// Construct an array of the entries we'd expect to see in this series so that
// we can check whether any are missing and if so set their status to "cancelled".
$repeat_rule = new RepeatRule();
$repeat_rule->setType($this->start_row['rep_type']);
$repeat_rule->setInterval($this->start_row['rep_interval']);
$repeat_end_date = new DateTime();
$repeat_end_date->setTimestamp($this->start_row['end_date']);
$repeat_rule->setEndDate($repeat_end_date);
$repeat_rule->setDaysFromOpt($this->start_row['rep_opt']);
if ($repeat_rule->getType() == RepeatRule::MONTHLY)
{
if (isset($this->start_row['month_absolute'])) {
$repeat_rule->setMonthlyAbsolute($this->start_row['month_absolute']);
$repeat_rule->setMonthlyType(RepeatRule::MONTHLY_ABSOLUTE);
}
elseif (isset($this->start_row['month_relative'])) {
$repeat_rule->setMonthlyRelative($this->start_row['month_relative']);
$repeat_rule->setMonthlyType(RepeatRule::MONTHLY_RELATIVE);
}
else {
throw new Exception("The repeat type is monthly but both the absolute and relative days are null.");
}
}

$this->expected_entries = $repeat_rule->getRepeatStartTimes($this->start_row['start_time']);

// And keep an array of all the entries we actually see
Expand Down

0 comments on commit c340d33

Please sign in to comment.