Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access submitted value directly rather than passing around #29627

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions CRM/Contact/Form/Task/SMSTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,7 @@ protected function postProcessSms(): void {
}
}

[$sent, $countSuccess] = $this->sendSMS($formattedContactDetails,
$thisValues
);
[$sent, $countSuccess] = $this->sendSMS($formattedContactDetails);

if ($countSuccess > 0) {
CRM_Core_Session::setStatus(ts('One message was sent successfully.', [
Expand Down Expand Up @@ -321,18 +319,14 @@ protected function postProcessSms(): void {
* Send SMS. Returns: bool $sent, int $activityId, int $success (number of sent SMS)
*
* @param array $contactDetails
* @param array $activityParams
*
* @return array(bool $sent, int $activityId, int $success)
* @throws CRM_Core_Exception
*/
protected function sendSMS(
$contactDetails,
$activityParams
$contactDetails
) {

$text = &$activityParams['sms_text_message'];

// Create the meta level record first ( sms activity )
$activityID = Activity::create()->setValues([
'source_contact_id' => CRM_Core_Session::getLoggedInContactID(),
Expand All @@ -347,7 +341,7 @@ protected function sendSMS(
$errMsgs = [];
foreach ($contactDetails as $contact) {
$contactId = $contact['contact_id'];
$tokenText = CRM_Core_BAO_MessageTemplate::renderTemplate(['messageTemplate' => ['msg_text' => $text], 'contactId' => $contactId, 'disableSmarty' => TRUE])['text'];
$tokenText = CRM_Core_BAO_MessageTemplate::renderTemplate(['messageTemplate' => ['msg_text' => $this->getSubmittedValue('sms_text_message')], 'contactId' => $contactId, 'disableSmarty' => TRUE])['text'];
$smsProviderParams = $this->getSmsProviderParams();
// Only send if the phone is of type mobile
if ($contact['phone_type_id'] == CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Phone', 'phone_type_id', 'Mobile')) {
Expand Down