$details = $query->apiQuery($params, $returnProperties, NULL, NULL, 0, $numberofContacts, TRUE, FALSE, TRUE, CRM_Contact_BAO_Query::MODE_CONTACTS, NULL, $primaryLocationOnly);
$messageToken = CRM_Utils_Token::getTokens($mailingFormat);
+ // $details[0] is an array of [ contactID => contactDetails ]
// also get all token values
CRM_Utils_Hook::tokenValues($details[0],
$this->_contactIds,
$details = $query->apiQuery($params, $returnProperties, NULL, NULL, 0, $numberofContacts);
$messageToken = CRM_Utils_Token::getTokens($mailingFormat);
+ // $details[0] is an array of [ contactID => contactDetails ]
$details = $details[0];
$tokenFields = CRM_Contact_Form_Task_LabelCommon::getTokenData($details);
elseif ($contactId === 0) {
//anonymous user
$contact = [];
- CRM_Utils_Hook::tokenValues($contact, $contactId, $job_id);
+ CRM_Utils_Hook::tokenValues($contact, [$contactId], $job_id);
}
else {
$params = [['contact_id', '=', $contactId, 0, 0]];
list($contact) = CRM_Contact_BAO_Query::apiQuery($params);
+ // $contact is an array of [ contactID => contactDetails ]
- //CRM-4524
- $contact = reset($contact);
+ // also call the hook to get contact details
+ CRM_Utils_Hook::tokenValues($contact, [$contactId], $job_id);
+ // Don't send if contact doesn't exist
+ $contact = reset($contact);
if (!$contact || is_a($contact, 'CRM_Core_Error')) {
CRM_Core_Error::debug_log_message(ts('CiviMail will not send email to a non-existent contact: %1',
[1 => $contactId]
$res = NULL;
return $res;
}
-
- // also call the hook to get contact details
- CRM_Utils_Hook::tokenValues($contact, $contactId, $job_id);
}
$pTemplates = $this->getPreparedTemplates();
$mailing->getFlattenedTokens(),
get_class($this)
);
-
+ // $details[0] is an array of [ contactID => contactDetails ]
$mime = &$mailing->compose(NULL, NULL, NULL, $session->get('userID'), $fromEmail, $fromEmail,
TRUE, $details[0][$session->get('userID')], $attachments
);
* tokens returned by the 'tokens' hook
*
* @param array $details
- * The array to store the token values indexed by contactIDs (unless it a single).
+ * The array to store the token values indexed by contactIDs.
* @param array $contactIDs
* An array of contactIDs.
* @param int $jobID
}
$details = CRM_Contact_BAO_Query::apiQuery($params, $returnProperties, NULL, NULL, 0, count($contactIDs), TRUE, FALSE, TRUE, CRM_Contact_BAO_Query::MODE_CONTACTS, NULL, TRUE);
-
$contactDetails = &$details[0];
foreach ($contactIDs as $contactID) {
}
}
+ // $contactDetails = &$details[0] = is an array of [ contactID => contactDetails ]
// also call a hook and get token details
- CRM_Utils_Hook::tokenValues($details[0],
+ CRM_Utils_Hook::tokenValues($contactDetails,
$contactIDs,
$jobID,
$tokens,
* @return array
* contactDetails with hooks swapped out
*/
- public static function getAnonymousTokenDetails($contactIDs = [
- 0,
- ],
+ public static function getAnonymousTokenDetails($contactIDs = [0],
$returnProperties = NULL,
$skipOnHold = TRUE,
$skipDeceased = TRUE,
$contact = array_merge($contact, $row->context['tmpTokenParams']);
}
- $contactArray = !is_array($contactId) ? [$contactId => $contact] : $contact;
-
- // Note: This is a small contract change from the past; data should be missing
- // less randomly.
+ $contactArray = [$contactId => $contact];
\CRM_Utils_Hook::tokenValues($contactArray,
- (array) $contactId,
+ [$contactId],
empty($row->context['mailingJobId']) ? NULL : $row->context['mailingJobId'],
$messageTokens,
$row->context['controller']