CRM-15671 Fix sendSMS() field names don't match - message doesn't send
authorjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Fri, 5 Dec 2014 07:00:25 +0000 (12:30 +0530)
committerjitendrapurohit <jitendra.purohit@webaccessglobal.com>
Fri, 5 Dec 2014 07:00:25 +0000 (12:30 +0530)
CRM/Activity/BAO/Activity.php
CRM/Admin/Form/ScheduleReminders.php
CRM/Core/BAO/ActionSchedule.php
templates/CRM/Mailing/Form/InsertTokens.tpl

index 243fcd0ac6ba034785b4a072fc3a7cd48fe2b926..180dfcd4d6eafc9880f562585dad7104feea11d3 100644 (file)
@@ -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;
     }
index af3cb0986e782b4b57b028eeb95b91dd2ce08ea6..154079b8fdec1fb858f39bda65cb0110f47a1b55 100644 (file)
@@ -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.');
index b3a33e2dbefaa57f9b88c533b585c5e4193a279a..ba2e5c3a637b49e10dcf79b82ecdc129db3f4391 100755 (executable)
@@ -540,7 +540,6 @@ WHERE   cas.entity_value = $id AND
 
         CRM_Activity_BAO_Activity::sendSMSMessage($contactId,
           $sms_text,
-          $html,
           $smsParams,
           $activity->id,
           $userID
index 8d473eddd5df32c55cce4e7d591b0844d15cf04c..850dff3717005aac790fddb8794722ff297e2aac 100644 (file)
@@ -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";