From 9e1bf145f3d295e053aafe8440f3a6b0d93899fa Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 3 Aug 2015 17:10:38 -0700 Subject: [PATCH] CRM-13244 - ActionMapping - Strictly use MappingInterface --- CRM/Admin/Form/ScheduleReminders.php | 11 +-- CRM/Core/ActionScheduleTmp.php | 26 +++---- CRM/Core/BAO/ActionSchedule.php | 74 ++++++++++--------- CRM/Event/BAO/Event.php | 6 +- CRM/Event/Form/ManageEvent/TabHeader.php | 2 +- CRM/Event/Page/ManageEvent.php | 2 +- .../Event/MappingRegisterEvent.php | 10 +-- Civi/ActionSchedule/Mapping.php | 65 +++++++++++++--- Civi/ActionSchedule/MappingInterface.php | 31 ++++++++ Civi/ActionSchedule/RecipientBuilder.php | 12 +-- 10 files changed, 154 insertions(+), 85 deletions(-) diff --git a/CRM/Admin/Form/ScheduleReminders.php b/CRM/Admin/Form/ScheduleReminders.php index 39fb4108b2..3f7a9fb0fe 100644 --- a/CRM/Admin/Form/ScheduleReminders.php +++ b/CRM/Admin/Form/ScheduleReminders.php @@ -87,7 +87,7 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { 'id' => $isTemplate ? CRM_Core_ActionScheduleTmp::EVENT_TPL_MAPPING_ID : CRM_Core_ActionScheduleTmp::EVENT_NAME_MAPPING_ID, ))); if ($mapping) { - $this->_mappingID = $mapping->id; + $this->_mappingID = $mapping->getId(); } else { CRM_Core_Error::fatal('Could not find mapping for event scheduled reminders.'); @@ -154,11 +154,6 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { //get the frequency units. $this->_freqUnits = CRM_Core_SelectValues::getRecurringFrequencyUnits(); - //pass the mapping ID in UPDATE mode - $mappings = CRM_Core_BAO_ActionSchedule::getMappings(array( - 'id' => $mappingID, - )); - $numericOptions = CRM_Core_SelectValues::getNumericOptions(0, 30); //reminder_interval @@ -215,14 +210,12 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { $this->add('text', 'from_name', ts('From Name')); $this->add('text', 'from_email', ts('From Email')); - $recipient = 'activity_contacts'; $recipientListingOptions = array(); if ($mappingID) { $mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings(array( 'id' => $mappingID, ))); - $recipient = $mapping->entity_recipient; } $limitOptions = array('' => '-neither-', 1 => ts('Limit to'), 0 => ts('Also include')); @@ -232,7 +225,7 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { $this->add('select', 'limit_to', ts('Limit Options'), $limitOptions, FALSE, array('onChange' => "showHideByValue('limit_to','','recipient', 'select','select',true);")); - $this->add('select', 'recipient', $recipientLabels['other'], $sel5[$recipient], + $this->add('select', 'recipient', $recipientLabels['other'], $sel5, FALSE, array('onchange' => "showHideByValue('recipient','manual','recipientManual','table-row','select',false); showHideByValue('recipient','group','recipientGroup','table-row','select',false);") ); diff --git a/CRM/Core/ActionScheduleTmp.php b/CRM/Core/ActionScheduleTmp.php index 124f565f1c..e56e34455c 100644 --- a/CRM/Core/ActionScheduleTmp.php +++ b/CRM/Core/ActionScheduleTmp.php @@ -64,9 +64,9 @@ class CRM_Core_ActionScheduleTmp implements EventSubscriberInterface { 'entity' => 'civicrm_activity', 'entity_label' => ts('Activity'), 'entity_value' => 'activity_type', - 'entity_value_label' => 'Activity Type', + 'entity_value_label' => ts('Activity Type'), 'entity_status' => 'activity_status', - 'entity_status_label' => 'Activity Status', + 'entity_status_label' => ts('Activity Status'), 'entity_date_start' => 'activity_date_time', 'entity_recipient' => 'activity_contacts', ))); @@ -75,9 +75,9 @@ class CRM_Core_ActionScheduleTmp implements EventSubscriberInterface { 'entity' => 'civicrm_participant', 'entity_label' => ts('Event Type'), 'entity_value' => 'event_type', - 'entity_value_label' => 'Event Type', + 'entity_value_label' => ts('Event Type'), 'entity_status' => 'civicrm_participant_status_type', - 'entity_status_label' => 'Participant Status', + 'entity_status_label' => ts('Participant Status'), 'entity_date_start' => 'event_start_date', 'entity_date_end' => 'event_end_date', 'entity_recipient' => 'event_contacts', @@ -87,9 +87,9 @@ class CRM_Core_ActionScheduleTmp implements EventSubscriberInterface { 'entity' => 'civicrm_participant', 'entity_label' => ts('Event Name'), 'entity_value' => 'civicrm_event', - 'entity_value_label' => 'Event Name', + 'entity_value_label' => ts('Event Name'), 'entity_status' => 'civicrm_participant_status_type', - 'entity_status_label' => 'Participant Status', + 'entity_status_label' => ts('Participant Status'), 'entity_date_start' => 'event_start_date', 'entity_date_end' => 'event_end_date', 'entity_recipient' => 'event_contacts', @@ -99,9 +99,9 @@ class CRM_Core_ActionScheduleTmp implements EventSubscriberInterface { 'entity' => 'civicrm_membership', 'entity_label' => ts('Membership'), 'entity_value' => 'civicrm_membership_type', - 'entity_value_label' => 'Membership Type', + 'entity_value_label' => ts('Membership Type'), 'entity_status' => 'auto_renew_options', - 'entity_status_label' => 'Auto Renew Options', + 'entity_status_label' => ts('Auto Renew Options'), 'entity_date_start' => 'membership_join_date', 'entity_date_end' => 'membership_end_date', ))); @@ -110,9 +110,9 @@ class CRM_Core_ActionScheduleTmp implements EventSubscriberInterface { 'entity' => 'civicrm_participant', 'entity_label' => ts('Event Template'), 'entity_value' => 'event_template', - 'entity_value_label' => 'Event Template', + 'entity_value_label' => ts('Event Template'), 'entity_status' => 'civicrm_participant_status_type', - 'entity_status_label' => 'Participant Status', + 'entity_status_label' => ts('Participant Status'), 'entity_date_start' => 'event_start_date', 'entity_date_end' => 'event_end_date', 'entity_recipient' => 'event_contacts', @@ -122,9 +122,9 @@ class CRM_Core_ActionScheduleTmp implements EventSubscriberInterface { 'entity' => 'civicrm_contact', 'entity_label' => ts('Contact'), 'entity_value' => 'civicrm_contact', - 'entity_value_label' => 'Date Field', + 'entity_value_label' => ts('Date Field'), 'entity_status' => 'contact_date_reminder_options', - 'entity_status_label' => 'Annual Options', + 'entity_status_label' => ts('Annual Options'), 'entity_date_start' => 'date_field', ))); } @@ -184,7 +184,7 @@ class CRM_Core_ActionScheduleTmp implements EventSubscriberInterface { //), ); - return isset($tokens[$mapping->entity]) ? $tokens[$mapping->entity] : array(); + return isset($tokens[$mapping->getEntity()]) ? $tokens[$mapping->getEntity()] : array(); } /** diff --git a/CRM/Core/BAO/ActionSchedule.php b/CRM/Core/BAO/ActionSchedule.php index 590ffe375c..b246baa5c2 100755 --- a/CRM/Core/BAO/ActionSchedule.php +++ b/CRM/Core/BAO/ActionSchedule.php @@ -40,7 +40,7 @@ class CRM_Core_BAO_ActionSchedule extends CRM_Core_DAO_ActionSchedule { /** * @param array $filters - * Filter by property (e.g. 'id', 'entity_value'). + * Filter by property (e.g. 'id'). * @return array * Array(scalar $id => Mapping $mapping). */ @@ -54,23 +54,17 @@ class CRM_Core_BAO_ActionSchedule extends CRM_Core_DAO_ActionSchedule { $_action_mapping = $event->getMappings(); } - if ($filters === NULL) { + if (empty($filters)) { return $_action_mapping; } - - $result = array(); - foreach ($_action_mapping as $mappingId => $mapping) { - $match = TRUE; - foreach ($filters as $filterField => $filterValue) { - if ($mapping->{$filterField} != $filterValue) { - $match = FALSE; - } - } - if ($match) { - $result[$mappingId] = $mapping; - } + elseif (isset($filters['id'])) { + return array( + $filters['id'] => $_action_mapping[$filters['id']], + ); + } + else { + throw new CRM_Core_Exception("getMappings() called with unsupported filter: " . implode(', ', array_keys($filters))); } - return $result; } /** @@ -95,33 +89,41 @@ class CRM_Core_BAO_ActionSchedule extends CRM_Core_DAO_ActionSchedule { foreach ($mappings as $mapping) { /** @var \Civi\ActionSchedule\Mapping $mapping */ - $entityValueLabels[$mapping->id] = $mapping->getValueLabels(); + $mappingId = $mapping->getId(); + $entityValueLabels[$mappingId] = $mapping->getValueLabels(); // Not sure why: everything *except* contact-dates have a $valueLabel. - if ($mapping->id !== CRM_Core_ActionScheduleTmp::CONTACT_MAPPING_ID) { - $valueLabel = array('- ' . strtolower($mapping->entity_value_label) . ' -'); - $entityValueLabels[$mapping->id] = $valueLabel + $entityValueLabels[$mapping->id]; + if ($mapping->getId() !== CRM_Core_ActionScheduleTmp::CONTACT_MAPPING_ID) { + $valueLabel = array('- ' . strtolower($mapping->getValueHeader()) . ' -'); + $entityValueLabels[$mapping->getId()] = $valueLabel + $entityValueLabels[$mapping->getId()]; } - if ($mapping->id == $id) { + if ($mapping->getId() == $id) { $dateFieldLabels = $mapping->getDateFields(); - $entityRecipientLabels = array($mapping->entity_recipient => $mapping->getRecipientTypes()); - $entityRecipientNames = array_combine(array_keys($entityRecipientLabels[$mapping->entity_recipient]), array_keys($entityRecipientLabels[$mapping->entity_recipient])); + $entityRecipientLabels = $mapping->getRecipientTypes(); + $entityRecipientNames = array_combine(array_keys($entityRecipientLabels), array_keys($entityRecipientLabels)); } - $statusLabel = array('- ' . strtolower($mapping->entity_status_label) . ' -'); - $entityStatusLabels[$mapping->id] = $entityValueLabels[$mapping->id]; - foreach ($entityStatusLabels[$mapping->id] as $kkey => & $vval) { + $statusLabel = array('- ' . strtolower($mapping->getStatusHeader()) . ' -'); + $entityStatusLabels[$mapping->getId()] = $entityValueLabels[$mapping->getId()]; + foreach ($entityStatusLabels[$mapping->getId()] as $kkey => & $vval) { $vval = $statusLabel + $mapping->getStatusLabels($kkey); } } + $entityLabels = array_map(function ($v) { + return $v->getLabel(); + }, $mappings); + $entityNames = array_map(function ($v) { + return $v->getEntity(); + }, $mappings); + return array( - 'sel1' => CRM_Utils_Array::collect('entity_label', $mappings), + 'sel1' => $entityLabels, 'sel2' => $entityValueLabels, 'sel3' => $entityStatusLabels, 'sel4' => $dateFieldLabels, 'sel5' => $entityRecipientLabels, - 'entityMapping' => CRM_Utils_Array::collect('entity', $mappings), + 'entityMapping' => $entityNames, 'recipientMapping' => $entityRecipientNames, ); } @@ -188,7 +190,7 @@ FROM civicrm_action_schedule cas if ($filterMapping and $filterValue) { $where .= " AND cas.entity_value = %1 AND cas.mapping_id = %2"; $queryParams[1] = array($filterValue, 'Integer'); - $queryParams[2] = array($filterMapping->id, 'Integer'); + $queryParams[2] = array($filterMapping->getId(), 'Integer'); } $where .= " AND cas.used_for IS NULL"; $query .= $where; @@ -205,7 +207,7 @@ FROM civicrm_action_schedule cas $list[$dao->id]['start_action_condition'] = $dao->start_action_condition; $list[$dao->id]['entityDate'] = ucwords(str_replace('_', ' ', $dao->entityDate)); $list[$dao->id]['absolute_date'] = $dao->absolute_date; - $list[$dao->id]['entity'] = $filterMapping->entity_label; + $list[$dao->id]['entity'] = $filterMapping->getLabel(); $list[$dao->id]['value'] = implode(', ', CRM_Utils_Array::subset( $filterMapping->getValueLabels(), explode(CRM_Core_DAO::VALUE_SEPARATOR, $dao->entityValueIds) @@ -502,7 +504,7 @@ FROM civicrm_action_schedule cas protected static function createMailingActivity($actionSchedule, $mapping, $contactID, $entityID, $caseID) { $session = CRM_Core_Session::singleton(); - if ($mapping->entity == 'civicrm_membership') { + if ($mapping->getEntity() == 'civicrm_membership') { $activityTypeID = CRM_Core_OptionGroup::getValue('activity_type', 'Membership Renewal Reminder', 'name'); } @@ -545,18 +547,18 @@ FROM civicrm_action_schedule cas ->where("reminder.action_date_time IS NULL"); if ($actionSchedule->limit_to == 0) { - $entityJoinClause = "LEFT JOIN {$mapping->entity} e ON e.id = reminder.entity_id"; + $entityJoinClause = "LEFT JOIN {$mapping->getEntity()} e ON e.id = reminder.entity_id"; $select->where("e.id = reminder.entity_id OR reminder.entity_table = 'civicrm_contact'"); } else { - $entityJoinClause = "INNER JOIN {$mapping->entity} e ON e.id = reminder.entity_id"; + $entityJoinClause = "INNER JOIN {$mapping->getEntity()} e ON e.id = reminder.entity_id"; } - if ($mapping->entity == 'civicrm_activity') { + if ($mapping->getEntity() == 'civicrm_activity') { $entityJoinClause .= ' AND e.is_current_revision = 1 AND e.is_deleted = 0 '; } $select->join('a', $entityJoinClause); - if ($mapping->entity == 'civicrm_activity') { + if ($mapping->getEntity() == 'civicrm_activity') { $compInfo = CRM_Core_Component::getEnabledComponents(); $select->select('ov.label as activity_type, e.id as activity_id'); @@ -571,7 +573,7 @@ FROM civicrm_action_schedule cas } } - if ($mapping->entity == 'civicrm_participant') { + if ($mapping->getEntity() == 'civicrm_participant') { $select->select('ov.label as event_type, ev.title, ev.id as event_id, ev.start_date, ev.end_date, ev.summary, ev.description, address.street_address, address.city, address.state_province_id, address.postal_code, email.email as contact_email, phone.phone as contact_phone'); $JOIN_TYPE = ($actionSchedule->limit_to == 0) ? 'LEFT JOIN' : 'INNER JOIN'; @@ -586,7 +588,7 @@ LEFT JOIN civicrm_phone phone ON phone.id = lb.phone_id "); } - if ($mapping->entity == 'civicrm_membership') { + if ($mapping->getEntity() == 'civicrm_membership') { $select->select('mt.minimum_fee as fee, e.id as id , e.join_date, e.start_date, e.end_date, ms.name as status, mt.name as type'); $JOIN_TYPE = ($actionSchedule->limit_to == 0) ? 'LEFT JOIN' : 'INNER JOIN'; diff --git a/CRM/Event/BAO/Event.php b/CRM/Event/BAO/Event.php index f1f91e3bc1..3596fa17bb 100644 --- a/CRM/Event/BAO/Event.php +++ b/CRM/Event/BAO/Event.php @@ -546,7 +546,7 @@ $event_summary_limit $eventSummary['events'][$dao->id]['is_show_location'] = $dao->is_show_location; $eventSummary['events'][$dao->id]['is_subevent'] = $dao->slot_label_id; $eventSummary['events'][$dao->id]['is_pcp_enabled'] = $dao->is_pcp_enabled; - $eventSummary['events'][$dao->id]['reminder'] = CRM_Core_BAO_ActionSchedule::isConfigured($dao->id, $mapping->id); + $eventSummary['events'][$dao->id]['reminder'] = CRM_Core_BAO_ActionSchedule::isConfigured($dao->id, $mapping->getId()); $eventSummary['events'][$dao->id]['is_repeating_event'] = $dao->is_repeating_event; $statusTypes = CRM_Event_PseudoConstant::participantStatus(); @@ -992,8 +992,8 @@ WHERE civicrm_event.is_active = 1 'id' => ($copyEvent->is_template == 1 ? CRM_Core_ActionScheduleTmp::EVENT_TPL_MAPPING_ID : CRM_Core_ActionScheduleTmp::EVENT_NAME_MAPPING_ID), ))); $copyReminder = &CRM_Core_DAO::copyGeneric('CRM_Core_DAO_ActionSchedule', - array('entity_value' => $id, 'mapping_id' => $oldMapping->id), - array('entity_value' => $copyEvent->id, 'mapping_id' => $copyMapping->id) + array('entity_value' => $id, 'mapping_id' => $oldMapping->getId()), + array('entity_value' => $copyEvent->id, 'mapping_id' => $copyMapping->getId()) ); if (!$afterCreate) { diff --git a/CRM/Event/Form/ManageEvent/TabHeader.php b/CRM/Event/Form/ManageEvent/TabHeader.php index f96ab2ae1e..86fbf69bb3 100644 --- a/CRM/Event/Form/ManageEvent/TabHeader.php +++ b/CRM/Event/Form/ManageEvent/TabHeader.php @@ -125,7 +125,7 @@ WHERE e.id = %1 $eventHasParent = CRM_Core_BAO_RecurringEntity::getParentFor($eventID, 'civicrm_event'); $params = array( 1 => array($eventID, 'Integer'), - 2 => array($eventNameMapping->id, 'Integer'), + 2 => array($eventNameMapping->getId(), 'Integer'), ); $dao = CRM_Core_DAO::executeQuery($sql, $params); if (!$dao->fetch()) { diff --git a/CRM/Event/Page/ManageEvent.php b/CRM/Event/Page/ManageEvent.php index 8ddbc0288b..5510b04999 100644 --- a/CRM/Event/Page/ManageEvent.php +++ b/CRM/Event/Page/ManageEvent.php @@ -373,7 +373,7 @@ ORDER BY start_date desc //show campaigns on selector. $manageEvent[$dao->id]['campaign'] = CRM_Utils_Array::value($dao->campaign_id, $allCampaigns); - $manageEvent[$dao->id]['reminder'] = CRM_Core_BAO_ActionSchedule::isConfigured($dao->id, $mapping->id); + $manageEvent[$dao->id]['reminder'] = CRM_Core_BAO_ActionSchedule::isConfigured($dao->id, $mapping->getId()); $manageEvent[$dao->id]['is_pcp_enabled'] = CRM_Utils_Array::value($dao->id, $eventPCPS); $manageEvent[$dao->id]['event_type'] = CRM_Utils_Array::value($manageEvent[$dao->id]['event_type_id'], $eventType); $manageEvent[$dao->id]['is_repeating_event'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_RecurringEntity', $dao->id, 'parent_id', 'entity_id'); diff --git a/Civi/ActionSchedule/Event/MappingRegisterEvent.php b/Civi/ActionSchedule/Event/MappingRegisterEvent.php index a2c8762637..04eab4d0f9 100644 --- a/Civi/ActionSchedule/Event/MappingRegisterEvent.php +++ b/Civi/ActionSchedule/Event/MappingRegisterEvent.php @@ -1,7 +1,7 @@ mappings[$mapping->id] = $mapping; + public function register(MappingInterface $mapping) { + $this->mappings[$mapping->getId()] = $mapping; return $this; } /** * @return array - * Array(scalar $id => Mapping $mapping). + * Array(scalar $id => MappingInterface $mapping). */ public function getMappings() { return $this->mappings; diff --git a/Civi/ActionSchedule/Mapping.php b/Civi/ActionSchedule/Mapping.php index 39db1efe48..4674b8fa14 100644 --- a/Civi/ActionSchedule/Mapping.php +++ b/Civi/ActionSchedule/Mapping.php @@ -54,10 +54,12 @@ namespace Civi\ActionSchedule; * configuration. The dozen places have been consolidated and * replaced with functions in MappingInterface. * - * This "Mapping" implementation is a refactoring of the + * This "Mapping" implementation is a refactoring of the old * hard-coded bits. Internally, it uses the concepts from * "civicrm_action_mapping". The resulting code is more - * convoluted than a clean implementation of MappingInterface. + * convoluted than a clean implementation of MappingInterface, but + * it strictly matches the old behavior (based on logging/comparing + * the queries produced through ActionScheduleTest). */ abstract class Mapping implements MappingInterface { @@ -86,7 +88,7 @@ abstract class Mapping implements MappingInterface { } } - public $id; + protected $id; /** * The basic entity to query (table name). @@ -94,7 +96,7 @@ abstract class Mapping implements MappingInterface { * @var string * Ex: 'civicrm_activity', 'civicrm_event'. */ - public $entity; + protected $entity; /** * The basic entity to query (label). @@ -102,7 +104,7 @@ abstract class Mapping implements MappingInterface { * @var * Ex: 'Activity', 'Event' */ - public $entity_label; + private $entity_label; /** * Level 1 filter -- the field/option-list to filter on. @@ -118,42 +120,83 @@ abstract class Mapping implements MappingInterface { * @var string * Ex: 'Activity Type', 'Event Name', 'Event Template'. */ - public $entity_value_label; + private $entity_value_label; /** * Level 2 filter -- the field/option-list to filter on. * @var string * Ex: 'activity_status, 'civicrm_participant_status_type', 'auto_renew_options'. */ - protected $entity_status; + private $entity_status; /** * Level 2 filter -- the field label. * @var string * Ex: 'Activity Status', 'Participant Status', 'Auto Rewnewal Options'. */ - public $entity_status_label; + private $entity_status_label; /** * Date filter -- the field name. * @var string|NULL * Ex: 'event_start_date' */ - protected $entity_date_start; + private $entity_date_start; /** * Date filter -- the field name. * @var string|NULL * Ex: 'event_end_date'. */ - protected $entity_date_end; + private $entity_date_end; /** * Contact selector -- The field/relationship/option-group name. * @var string|NULL * Ex: 'activity_contacts', 'event_contacts'. */ - public $entity_recipient; + protected $entity_recipient; + + /** + * @return mixed + */ + public function getId() { + return $this->id; + } + + /** + * @return string + */ + public function getEntity() { + return $this->entity; + } + + /** + * Get a printable label for this mapping type. + * + * @return string + */ + public function getLabel() { + return $this->entity_label; + } + + /** + * Get a printable label to use a header on the 'value' filter. + * + * @return string + */ + public function getValueHeader() { + return $this->entity_value_label; + } + + /** + * Get a printable label to use a header on the 'status' filter. + * + * @return string + */ + public function getStatusHeader() { + return $this->entity_status_label; + } /** * Get a list of value options. diff --git a/Civi/ActionSchedule/MappingInterface.php b/Civi/ActionSchedule/MappingInterface.php index b1acb7b30d..efcdd53942 100644 --- a/Civi/ActionSchedule/MappingInterface.php +++ b/Civi/ActionSchedule/MappingInterface.php @@ -29,6 +29,37 @@ namespace Civi\ActionSchedule; interface MappingInterface { + /** + * @return mixed + */ + public function getId(); + + /** + * @return string + */ + public function getEntity(); + + /** + * Get a printable label for this mapping type. + * + * @return string + */ + public function getLabel(); + + /** + * Get a printable label to use as the header on the 'value' filter. + * + * @return string + */ + public function getValueHeader(); + + /** + * Get a printable label to use as the header on the 'status' filter. + * + * @return string + */ + public function getStatusHeader(); + /** * Get a list of value options. * diff --git a/Civi/ActionSchedule/RecipientBuilder.php b/Civi/ActionSchedule/RecipientBuilder.php index 9bedcad836..08efd822b3 100644 --- a/Civi/ActionSchedule/RecipientBuilder.php +++ b/Civi/ActionSchedule/RecipientBuilder.php @@ -220,9 +220,9 @@ class RecipientBuilder { ->merge($this->prepareAddlFilter('c.id')) ->where("c.id NOT IN ( SELECT rem.contact_id - FROM civicrm_action_log rem INNER JOIN {$this->mapping->entity} e ON rem.entity_id = e.id + FROM civicrm_action_log rem INNER JOIN {$this->mapping->getEntity()} e ON rem.entity_id = e.id WHERE rem.action_schedule_id = {$this->actionSchedule->id} - AND rem.entity_table = '{$this->mapping->entity}' + AND rem.entity_table = '{$this->mapping->getEntity()}' )") // Where does e.id come from here? ^^^ ->groupBy("c.id") @@ -331,8 +331,8 @@ class RecipientBuilder { $query = $this->mapping->createQuery($this->actionSchedule, $phase); $query->param(array( 'casActionScheduleId' => $this->actionSchedule->id, - 'casMappingId' => $this->mapping->id, - 'casMappingEntity' => $this->mapping->entity, + 'casMappingId' => $this->mapping->getId(), + 'casMappingEntity' => $this->mapping->getEntity(), 'casNow' => $this->now, )); @@ -444,7 +444,7 @@ class RecipientBuilder { $date = $operator . "({$dateField}, INTERVAL {$actionSchedule->start_action_offset} {$actionSchedule->start_action_unit})"; $startDateClauses[] = "'{$now}' >= {$date}"; // This is weird. Waddupwidat? - if ($mapping->entity == 'civicrm_participant') { + if ($mapping->getEntity() == 'civicrm_participant') { $startDateClauses[] = $operator . "({$now}, INTERVAL 1 DAY ) {$op} " . $dateField; } else { @@ -601,7 +601,7 @@ WHERE $group.id = {$groupId} switch ($for) { case 'rel': $contactIdField = $query['casContactIdField']; - $entityName = $this->mapping->entity; + $entityName = $this->mapping->getEntity(); $entityIdField = $query['casEntityIdField']; break; -- 2.25.1