);
}
+ $success = 0;
$escapeSmarty = $sent = FALSE;
foreach ($contactDetails as $values) {
$contactId = $values['contact_id'];
)) {
// even a single successful delivery should set this falg to true
$sent = TRUE;
+ $success++;
}
}
- return array($sent, $activity->id);
+ return array($sent, $activity->id, $success);
}
/**
}
}
- if (is_array($form->_contactIds) && $toSetDefault) {
+ if (is_array($form->_contactIds) && !empty($form->_contactIds) && $toSetDefault) {
$returnProperties = array(
'sort_name' => 1,
'phone' => 1,
$smsParams = $thisValues;
unset($smsParams['text_message']);
$smsParams['provider_id'] = $fromSmsProviderId;
+ $contactIds = array_keys($form->_contactDetails);
+ $allContactIds = array_keys($form->_allContactDetails);
- list($sent, $activityId) = CRM_Activity_BAO_Activity::sendSMS($formattedContactDetails,
+ list($sent, $activityId, $countSuccess) = CRM_Activity_BAO_Activity::sendSMS($formattedContactDetails,
$thisValues,
$smsParams,
- array_keys($form->_contactDetails)
+ $contactIds
);
if ($sent) {
- $count_success = count($form->_contactDetails);
- CRM_Core_Session::setStatus(ts('One message was sent successfully.', array('plural' => '%count messages were sent successfully.', 'count' => $count_success)), ts('Message Sent', array('plural' => 'Messages Sent', 'count' => $count_success)), 'success');
+ CRM_Core_Session::setStatus(ts('One message was sent successfully.', array('plural' => '%count messages were sent successfully.', 'count' => $countSuccess)), ts('Message Sent', array('plural' => 'Messages Sent', 'count' => $countSuccess)), 'success');
}
//Display the name and number of contacts for those sms is not sent.
- $smsNotSent = array_diff_assoc($form->_allContactDetails, $form->_contactDetails);
+ $smsNotSent = array_diff_assoc($allContactIds, $contactIds);
if (!empty($smsNotSent)) {
$not_sent = array();
- foreach ($smsNotSent as $contactId => $values) {
- $displayName = $values['display_name'];
- $phone = $values['phone'];
+ foreach ($smsNotSent as $index => $contactId) {
+ $displayName = $form->_allContactDetails[$contactId]['display_name'];
+ $phone = $form->_allContactDetails[$contactId]['phone'];
$contactViewUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid=$contactId");
$not_sent[] = "<a href='$contactViewUrl' title='$phone'>$displayName</a>";
}
return $value;
}
- function inbound($from, $body, $to = NULL, $trackID = NULL) {
+ function processInbound($from, $body, $to = NULL, $trackID = NULL) {
$formatFrom = $this->formatPhone($this->stripPhone($from), $like, "like");
$escapedFrom = CRM_Utils_Type::escape($formatFrom, 'String');
$fromContactID = CRM_Core_DAO::singleValueQuery('SELECT contact_id FROM civicrm_phone WHERE phone LIKE "' . $escapedFrom . '"');
else {
// TODO: Should add a failed activity instead.
- CRM_Core_Error::debug_log_message($response['data']);
+ CRM_Core_Error::debug_log_message($response['data'] . " - for phone: {$postDataArray['to']}");
return;
}
}
$fromPhone = $this->retrieve('from', 'String');
$fromPhone = $this->formatPhone($this->stripPhone($fromPhone), $like, "like");
- return parent::inbound($fromPhone, $this->retrieve('text', 'String'), NULL, $this->retrieve('moMsgId', 'String'));
+ return parent::processInbound($fromPhone, $this->retrieve('text', 'String'), NULL, $this->retrieve('moMsgId', 'String'));
}
/**