Only send SMS if it is a mobile number, do not delete parent activity as it might...
authorThom Wilhelm <thom@futurefirst.org.uk>
Fri, 5 Apr 2013 16:50:40 +0000 (17:50 +0100)
committerThom Wilhelm <thom@futurefirst.org.uk>
Fri, 5 Apr 2013 16:50:40 +0000 (17:50 +0100)
CRM/Activity/BAO/Activity.php
tools/extensions/org.civicrm.sms.clickatell/org_civicrm_sms_clickatell.php

index f86e7a59357c43534bc1737a7e2de8ba9ba11610..e58e29f021a554bf9169b2b6cccba86ec21d0e99 100644 (file)
@@ -1515,7 +1515,12 @@ LEFT JOIN   civicrm_case_activity ON ( civicrm_case_activity.activity_id = tbl.a
       $tokenHtml = CRM_Utils_Token::replaceContactTokens($html, $values, TRUE, $messageToken, FALSE, $escapeSmarty);
       $tokenHtml = CRM_Utils_Token::replaceHookTokens($tokenHtml, $values, $categories, TRUE, $escapeSmarty);
 
-      $smsParams['To'] = $values['phone'];
+      // Only send if the phone is of type mobile
+      if($values['phone_type_id'] == 2) {
+        $smsParams['To'] = $values['phone'];
+      }else{
+        $smsParams['To'] = '';
+      }
 
       if (self::sendSMSMessage($contactId,
           $tokenText,
index 98be673190bb48289b3bb3a8977f062964864070..1eeac0664dfbbf945338070fd5c38cafdb41e365 100644 (file)
@@ -284,12 +284,10 @@ class org_civicrm_sms_clickatell extends CRM_SMS_Provider {
         return $send[1];
       }
       else {
-        // delete any parent activity & throw error
-        if (CRM_Utils_Array::value('parent_activity_id', $header)) {
-          $params = array('id' => $header['parent_activity_id']);
-          CRM_Activity_BAO_Activity::deleteActivity($params);
-        }
-        return PEAR::raiseError($response['data']);
+        // TODO: Should add a failed activity instead.
+       
+        CRM_Core_Error::debug_log_message($response['data']);
+        return;
       }
     }
   }