Skip to content

Commit

Permalink
Access submitted value directly rather than passing around
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Mar 5, 2024
1 parent f247992 commit 436aad1
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 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 @@ -327,12 +325,9 @@ protected function postProcessSms(): void {
* @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 +342,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

0 comments on commit 436aad1

Please sign in to comment.