Skip to content
Snippets Groups Projects
Commit 7deea185 authored by jaapjansma's avatar jaapjansma
Browse files

Merge branch 'activitySupport' into 'master'

Add activity token support to the emailapi

See merge request !12
parents 8461961c c6d38546
No related branches found
No related tags found
1 merge request!12Add activity token support to the emailapi
......@@ -49,6 +49,10 @@ class CRM_Emailapi_CivirulesAction_Send extends CRM_CivirulesActions_Generic_Api
$case = $triggerData->getEntityData('Case');
$parameters['case_id'] = $case['id'];
}
if ($triggerData->getEntityData('Activity')) {
$activity = $triggerData->getEntityData('Activity');
$parameters['activity_id'] = $activity['id'];
}
if (!empty($actionParameters['cc'])) {
$parameters['cc'] = $actionParameters['cc'];
}
......
......@@ -22,6 +22,10 @@ function _civicrm_api3_email_send_spec(&$spec) {
'title' => 'Case ID',
'type' => CRM_Utils_Type::T_INT,
];
$spec['activity_id'] = [
'title' => 'Activity ID',
'type' => CRM_Utils_Type::T_INT,
];
$spec['contribution_id'] = [
'title' => 'Contribution ID',
'type' => CRM_Utils_Type::T_INT,
......@@ -75,6 +79,10 @@ function civicrm_api3_email_send($params) {
elseif (!empty($params['extra_data']['contribution'])) {
$contribution_id = $params['extra_data']['contribution']['contribution_id'];
}
$activity_id = false;
if (isset($params['activity_id'])) {
$activity_id = $params['activity_id'];
}
$extra_data = false;
if (isset($params['extra_data'])) {
$extra_data = $params['extra_data'];
......@@ -191,6 +199,10 @@ function civicrm_api3_email_send($params) {
if ($case_id) {
$$bodyType = CRM_Utils_Token::replaceCaseTokens($case_id, $$bodyType, $tokens);
}
if ($activity_id && !empty($tokens['activity'])) {
$activity = civicrm_api3('Activity', 'getsingle', ['id' => $activity_id]);
$$bodyType = CRM_Utils_Token::replaceEntityTokens('activity', $activity, $$bodyType, $tokens);
}
$$bodyType = CRM_Utils_Token::replaceHookTokens($$bodyType, $contact, $categories, TRUE);
CRM_Utils_Token::replaceGreetingTokens($$bodyType, $contact, $contact['contact_id']);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment