Commit 8ac3e780 authored by jaapjansma's avatar jaapjansma
Browse files

compatibility with civi 5.8.0

parent b395213f
......@@ -13,20 +13,22 @@ function activitytokens_civicrm_container($container) {
function activitytokens_evaluate_tokens(\Civi\Token\Event\TokenValueEvent $e) {
$tokenClass = CRM_ActivityTokens_Tokens::singleton();
foreach ($e->getRows() as $row) {
$activity_ids = $e->getTokenProcessor()->getContextValues('actionSearchResult', 'activity_id');
$targets = $tokenClass->getActivityContacts($activity_ids, 'Activity Targets');
$assignees = $tokenClass->getActivityContacts($activity_ids, 'Activity Assignees');
$source = $tokenClass->getActivityContacts($activity_ids, 'Activity Source');
$row->tokens(CRM_ActivityTokens_Tokens::TOKEN, 'targets', $targets);
$row->tokens(CRM_ActivityTokens_Tokens::TOKEN, 'assignees', $assignees);
$row->tokens(CRM_ActivityTokens_Tokens::TOKEN, 'source', $source);
foreach($activity_ids as $activity_id) {
if ($activity_id) {
$activity = $tokenClass->getActivity($activity_id);
foreach($activity as $field => $value) {
if (stripos($field, 'custom_') === 0) {
$row->tokens(CRM_ActivityTokens_Tokens::TOKEN, $field, $value);
if (isset($row->context['actionSearchResult']) && $row->context['actionSearchResult']->activity_id) {
$activity_ids = [$row->context['actionSearchResult']->activity_id];
$targets = $tokenClass->getActivityContacts($activity_ids, 'Activity Targets');
$assignees = $tokenClass->getActivityContacts($activity_ids, 'Activity Assignees');
$source = $tokenClass->getActivityContacts($activity_ids, 'Activity Source');
$row->tokens(CRM_ActivityTokens_Tokens::TOKEN, 'targets', $targets);
$row->tokens(CRM_ActivityTokens_Tokens::TOKEN, 'assignees', $assignees);
$row->tokens(CRM_ActivityTokens_Tokens::TOKEN, 'source', $source);
foreach ($activity_ids as $activity_id) {
if ($activity_id) {
$activity = $tokenClass->getActivity($activity_id);
foreach ($activity as $field => $value) {
if (stripos($field, 'custom_') === 0) {
$row->tokens(CRM_ActivityTokens_Tokens::TOKEN, $field, $value);
}
}
}
}
......
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