ts('Membership Fee'), 'id' => ts('Membership ID'), 'join_date' => ts('Membership Join Date'), 'start_date' => ts('Membership Start Date'), 'end_date' => ts('Membership End Date'), 'status' => ts('Membership Status'), 'type' => ts('Membership Type'), )); } /** * Is token active. * * @param \Civi\Token\TokenProcessor $processor * * @return bool */ public function checkActive(\Civi\Token\TokenProcessor $processor) { // Extracted from scheduled-reminders code. See the class description. return !empty($processor->context['actionMapping']) && $processor->context['actionMapping']->getEntity() === 'civicrm_membership'; } public function alterActionScheduleQuery(\Civi\ActionSchedule\Event\MailingQueryEvent $e) { if ($e->mapping->getEntity() !== 'civicrm_membership') { return; } // FIXME: `select('e.*')` seems too broad. $e->query ->select('e.*') ->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('mt', "!casMailingJoinType civicrm_membership_type mt ON e.membership_type_id = mt.id") ->join('ms', "!casMailingJoinType civicrm_membership_status ms ON e.status_id = ms.id"); } /** * Evaluate the content of a single token. * * @param \Civi\Token\TokenRow $row * The record for which we want token values. * @param string $entity * @param string $field * The name of the token field. * @param mixed $prefetch * Any data that was returned by the prefetch(). * * @return mixed */ public function evaluateToken(\Civi\Token\TokenRow $row, $entity, $field, $prefetch = NULL) { $actionSearchResult = $row->context['actionSearchResult']; if (in_array($field, array('start_date', 'end_date', 'join_date'))) { $row->tokens($entity, $field, \CRM_Utils_Date::customFormat($actionSearchResult->$field)); } elseif (isset($actionSearchResult->$field)) { $row->tokens($entity, $field, $actionSearchResult->$field); } else { $row->tokens($entity, $field, ''); } } }