+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2016 |
+ | Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
* Class constructor.
*/
public function __construct() {
- parent::__construct('membership', array(
- 'fee' => 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'),
+ parent::__construct('membership', array_merge(
+ array(
+ 'fee' => 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'),
+ ),
+ CRM_Utils_Token::getCustomFieldTokens('Membership')
));
}
/**
- * Is token active.
- *
- * @param \Civi\Token\TokenProcessor $processor
- *
- * @return bool
+ * @inheritDoc
*/
public function checkActive(\Civi\Token\TokenProcessor $processor) {
// Extracted from scheduled-reminders code. See the class description.
&& $processor->context['actionMapping']->getEntity() === 'civicrm_membership';
}
+ /**
+ * Alter action schedule query.
+ *
+ * @param \Civi\ActionSchedule\Event\MailingQueryEvent $e
+ */
public function alterActionScheduleQuery(\Civi\ActionSchedule\Event\MailingQueryEvent $e) {
if ($e->mapping->getEntity() !== 'civicrm_membership') {
return;
}
/**
- * 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
+ * @inheritDoc
*/
public function evaluateToken(\Civi\Token\TokenRow $row, $entity, $field, $prefetch = NULL) {
$actionSearchResult = $row->context['actionSearchResult'];
elseif (isset($actionSearchResult->$field)) {
$row->tokens($entity, $field, $actionSearchResult->$field);
}
+ elseif ($cfID = \CRM_Core_BAO_CustomField::getKeyID($field)) {
+ $row->customToken($entity, $cfID, $actionSearchResult->entity_id);
+ }
else {
$row->tokens($entity, $field, '');
}