From a84aeb1fcad47e6dda7de83eef45732ac2c8edd1 Mon Sep 17 00:00:00 2001 From: Erik Hommel <hommel@ee-atwork.nl> Date: Tue, 18 Aug 2015 12:40:39 +0200 Subject: [PATCH] fix issue with DonorHasRecurring condition --- .../Contribution/DonorIsRecurring.php | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/CRM/CivirulesConditions/Contribution/DonorIsRecurring.php b/CRM/CivirulesConditions/Contribution/DonorIsRecurring.php index 28fe007..4c167b3 100644 --- a/CRM/CivirulesConditions/Contribution/DonorIsRecurring.php +++ b/CRM/CivirulesConditions/Contribution/DonorIsRecurring.php @@ -34,19 +34,38 @@ class CRM_CivirulesConditions_Contribution_DonorIsRecurring extends CRM_Civirule * @access public */ public function isConditionValid(CRM_Civirules_EventData_EventData $eventData) { - $isConditionValid = FALSE; $contactId = $eventData->getContactId(); + $donorHasAny = FALSE; $recurringParams = array( 'contact_id' => $contactId, 'is_test' => 0); try { $foundRecurring = civicrm_api3('ContributionRecur', 'Get', $recurringParams); foreach ($foundRecurring['values'] as $recurring) { - if (CRM_Civirules_Utils::endDateLaterThanToday($recurring['end_date']) == TRUE) { + if (CRM_Civirules_Utils::endDateLaterThanToday($recurring['end_date']) == TRUE || !isset($recurring['end_date'])) { + $donorHasAny = TRUE; + } + } + if ($donorHasAny) { + if ($this->conditionParams['has_recurring']) { + $isConditionValid = TRUE; + } else { + $isConditionValid = FALSE; + } + } else { + if ($this->conditionParams['has_recurring']) { + $isConditionValid = FALSE; + } else { $isConditionValid = TRUE; } } - } catch (CiviCRM_API3_Exception $ex) {} + } catch (CiviCRM_API3_Exception $ex) { + if ($this->conditionParams['has_recurring']) { + $isConditionValid = FALSE; + } else { + $isConditionValid = TRUE; + } + } return $isConditionValid; } -- GitLab