From: jitendrapurohit Date: Fri, 5 Dec 2014 07:00:25 +0000 (+0530) Subject: CRM-15671 Fix sendSMS() field names don't match - message doesn't send X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=1b7a39f5e192085a98f9480b20e7b34669f332a1;p=civicrm-core.git CRM-15671 Fix sendSMS() field names don't match - message doesn't send --- diff --git a/CRM/Activity/BAO/Activity.php b/CRM/Activity/BAO/Activity.php index 243fcd0ac6..180dfcd4d6 100644 --- a/CRM/Activity/BAO/Activity.php +++ b/CRM/Activity/BAO/Activity.php @@ -1386,16 +1386,12 @@ LEFT JOIN civicrm_activity_contact src ON (src.activity_id = ac.activity_id AND $userID = $session->get('userID'); } - $text = &$activityParams['text_message']; - $html = &$activityParams['html_message']; + $text = &$activityParams['sms_text_message']; // CRM-4575 // token replacement of addressee/email/postal greetings // get the tokens added in subject and message $messageToken = CRM_Utils_Token::getTokens($text); - $messageToken = array_merge($messageToken, - CRM_Utils_Token::getTokens($html) - ); //create the meta level record first ( sms activity ) $activityTypeID = CRM_Core_OptionGroup::getValue('activity_type', @@ -1403,13 +1399,7 @@ LEFT JOIN civicrm_activity_contact src ON (src.activity_id = ac.activity_id AND 'name' ); - // CRM-6265: save both text and HTML parts in details (if present) - if ($html and $text) { - $details = "-ALTERNATIVE ITEM 0-\n$html\n-ALTERNATIVE ITEM 1-\n$text\n-ALTERNATIVE END-\n"; - } - else { - $details = $html ? $html : $text; - } + $details = $text; $activitySubject = $activityParams['activity_subject']; $activityParams = array( @@ -1465,9 +1455,6 @@ LEFT JOIN civicrm_activity_contact src ON (src.activity_id = ac.activity_id AND $tokenText = CRM_Utils_Token::replaceContactTokens($text, $values, FALSE, $messageToken, FALSE, $escapeSmarty); $tokenText = CRM_Utils_Token::replaceHookTokens($tokenText, $values, $categories, FALSE, $escapeSmarty); - $tokenHtml = CRM_Utils_Token::replaceContactTokens($html, $values, TRUE, $messageToken, FALSE, $escapeSmarty); - $tokenHtml = CRM_Utils_Token::replaceHookTokens($tokenHtml, $values, $categories, TRUE, $escapeSmarty); - // Only send if the phone is of type mobile $phoneTypes = CRM_Core_OptionGroup::values('phone_type', TRUE, FALSE, FALSE, NULL, 'name'); if ($values['phone_type_id'] == CRM_Utils_Array::value('Mobile', $phoneTypes)) { @@ -1480,7 +1467,6 @@ LEFT JOIN civicrm_activity_contact src ON (src.activity_id = ac.activity_id AND $sendResult = self::sendSMSMessage( $contactId, $tokenText, - $tokenHtml, $smsParams, $activityID, $userID @@ -1525,7 +1511,6 @@ LEFT JOIN civicrm_activity_contact src ON (src.activity_id = ac.activity_id AND */ static function sendSMSMessage($toID, &$tokenText, - &$tokenHtml, $smsParams = array(), $activityID, $userID = null @@ -1558,13 +1543,12 @@ LEFT JOIN civicrm_activity_contact src ON (src.activity_id = ac.activity_id AND ); } - $message = $tokenHtml ? $tokenHtml : $tokenText; $recipient = $smsParams['To']; $smsParams['contact_id'] = $toID; $smsParams['parent_activity_id'] = $activityID; $providerObj = CRM_SMS_Provider::singleton(array('provider_id' => $smsParams['provider_id'])); - $sendResult = $providerObj->send($recipient, $smsParams, $message, NULL, $userID); + $sendResult = $providerObj->send($recipient, $smsParams, $tokenText, NULL, $userID); if (PEAR::isError($sendResult)) { return $sendResult; } diff --git a/CRM/Admin/Form/ScheduleReminders.php b/CRM/Admin/Form/ScheduleReminders.php index af3cb0986e..154079b8fd 100644 --- a/CRM/Admin/Form/ScheduleReminders.php +++ b/CRM/Admin/Form/ScheduleReminders.php @@ -257,7 +257,7 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { } } - if (!empty($fields['is_active']) && + if (!empty($fields['is_active']) && $fields['mode'] != 'SMS' && CRM_Utils_System::isNull($fields['subject']) ) { $errors['subject'] = ts('Subject is a required field.'); diff --git a/CRM/Core/BAO/ActionSchedule.php b/CRM/Core/BAO/ActionSchedule.php index b3a33e2dbe..ba2e5c3a63 100755 --- a/CRM/Core/BAO/ActionSchedule.php +++ b/CRM/Core/BAO/ActionSchedule.php @@ -540,7 +540,6 @@ WHERE cas.entity_value = $id AND CRM_Activity_BAO_Activity::sendSMSMessage($contactId, $sms_text, - $html, $smsParams, $activity->id, $userID diff --git a/templates/CRM/Mailing/Form/InsertTokens.tpl b/templates/CRM/Mailing/Form/InsertTokens.tpl index 8d473eddd5..850dff3717 100644 --- a/templates/CRM/Mailing/Form/InsertTokens.tpl +++ b/templates/CRM/Mailing/Form/InsertTokens.tpl @@ -46,7 +46,7 @@ var isMailing = false; text_message = "mailing_format"; isMailing = false; {/literal} - {elseif $form.formClass eq 'CRM_SMS_Form_Upload'} + {elseif $form.formClass eq 'CRM_SMS_Form_Upload' || $form.formClass eq 'CRM_Contact_Form_Task_SMS'} {literal} prefix = "SMS"; text_message = "sms_text_message";