Commit fb9acc32 authored by mattwire's avatar mattwire
Browse files

Update for new When library

parent 788fa982
......@@ -9,13 +9,7 @@
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2018
*/
require_once 'packages/When/When.php';
use When\When;
/**
* Class CRM_AdvancedEvents_BAO_RecurringEntity.
......@@ -31,6 +25,9 @@ class CRM_AdvancedEvents_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntit
public $intervalDateColumns = [];
public $excludeDates = [];
/**
* @var When
*/
protected $recursion = NULL;
protected $recursion_start_date = NULL;
......@@ -152,7 +149,7 @@ class CRM_AdvancedEvents_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntit
$this->generateRecursion();
$recursionDates = [];
if (is_a($this->recursion, 'When')) {
if (is_a($this->recursion, 'When\When')) {
$initialCount = CRM_Utils_Array::value('start_action_offset', $this->schedule) + 1;
$exRangeStart = $exRangeEnd = NULL;
......@@ -163,7 +160,14 @@ class CRM_AdvancedEvents_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntit
$count = 0;
$this->recursion->count($initialCount);
while ($result = $this->recursion->next()) {
try {
$this->recursion->generateOccurrences();
}
catch (Exception $e) {
CRM_Core_Error::statusBounce($e->getMessage());
return $recursionDates;
}
foreach ($this->recursion->occurrences as $result) {
$skip = FALSE;
$baseDate = $result->format('YmdHis');
......@@ -396,7 +400,8 @@ class CRM_AdvancedEvents_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntit
$repetition_frequency_unit = "dai";
}
$repetition_frequency_unit = $repetition_frequency_unit . 'ly';
$r->recur($start, $repetition_frequency_unit);
$r->startDate($start)
->freq($repetition_frequency_unit);
}
if ($scheduleReminderDetails['repetition_frequency_interval']) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment