return [$formValues, $categories, $html_message, $messageToken, $returnProperties];
}
- /**
- * @param CRM_Core_Form $form
- * @param string $html_message
- * @param array $contactIds
- * @param string $subject
- * @param int $campaign_id
- * @param array $perContactHtml
- *
- * @return array
- * List of activity IDs.
- * There may be 1 or more, depending on the system-settings
- * and use-case.
- *
- * @throws CRM_Core_Exception
- *
- * @deprecated
- */
- public static function createActivities($form, $html_message, $contactIds, $subject, $campaign_id, $perContactHtml = []) {
- CRM_Core_Error::deprecatedFunctionWarning('no alternative');
-
- $activityParams = [
- 'subject' => $subject,
- 'campaign_id' => $campaign_id,
- 'source_contact_id' => CRM_Core_Session::getLoggedInContactID(),
- 'activity_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Print PDF Letter'),
- 'activity_date_time' => date('YmdHis'),
- 'details' => $html_message,
- ];
- if (!empty($form->_activityId)) {
- $activityParams += ['id' => $form->_activityId];
- }
-
- $activityIds = [];
- switch (Civi::settings()->get('recordGeneratedLetters')) {
- case 'none':
- return [];
-
- case 'multiple':
- // One activity per contact.
- foreach ($contactIds as $i => $contactId) {
- $fullParams = [
- 'target_contact_id' => $contactId,
- ] + $activityParams;
- if (!empty($form->_caseId)) {
- $fullParams['case_id'] = $form->_caseId;
- }
- elseif (!empty($form->_caseIds[$i])) {
- $fullParams['case_id'] = $form->_caseIds[$i];
- }
-
- if (isset($perContactHtml[$contactId])) {
- $fullParams['details'] = implode('<hr>', $perContactHtml[$contactId]);
- }
- $activity = civicrm_api3('Activity', 'create', $fullParams);
- $activityIds[$contactId] = $activity['id'];
- }
-
- break;
-
- case 'combined':
- case 'combined-attached':
- // One activity with all contacts.
- $fullParams = [
- 'target_contact_id' => $contactIds,
- ] + $activityParams;
- if (!empty($form->_caseId)) {
- $fullParams['case_id'] = $form->_caseId;
- }
- elseif (!empty($form->_caseIds)) {
- $fullParams['case_id'] = $form->_caseIds;
- }
- $activity = civicrm_api3('Activity', 'create', $fullParams);
- $activityIds[] = $activity['id'];
- break;
-
- default:
- throw new CRM_Core_Exception("Unrecognized option in recordGeneratedLetters: " . Civi::settings()->get('recordGeneratedLetters'));
- }
-
- return $activityIds;
- }
-
/**
* Convert from a vague-type/file-extension to mime-type.
*