Skip to content
Snippets Groups Projects
Commit f53ea1ce authored by Deepak Srivastava's avatar Deepak Srivastava
Browse files

Fix for CRM-12391

parent 94073b0a
Branches
Tags
No related merge requests found
......@@ -1498,6 +1498,7 @@ LEFT JOIN civicrm_case_activity ON ( civicrm_case_activity.activity_id = tbl.a
);
}
$success = 0;
$escapeSmarty = $sent = FALSE;
foreach ($contactDetails as $values) {
$contactId = $values['contact_id'];
......@@ -1533,10 +1534,11 @@ LEFT JOIN civicrm_case_activity ON ( civicrm_case_activity.activity_id = tbl.a
)) {
// 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);
}
/**
......
......@@ -170,7 +170,7 @@ class CRM_Contact_Form_Task_SMSCommon {
}
}
if (is_array($form->_contactIds) && $toSetDefault) {
if (is_array($form->_contactIds) && !empty($form->_contactIds) && $toSetDefault) {
$returnProperties = array(
'sort_name' => 1,
'phone' => 1,
......@@ -393,26 +393,27 @@ class CRM_Contact_Form_Task_SMSCommon {
$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>";
}
......
......@@ -159,7 +159,7 @@ INNER JOIN civicrm_mailing_job mj ON mj.mailing_id = m.id AND mj.id = %1";
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 . '"');
......
No preview for this file type
......@@ -286,7 +286,7 @@ class org_civicrm_sms_clickatell extends CRM_SMS_Provider {
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;
}
}
......@@ -385,7 +385,7 @@ class org_civicrm_sms_clickatell extends CRM_SMS_Provider {
$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'));
}
/**
......
No preview for this file type
......@@ -183,7 +183,7 @@ class org_civicrm_sms_twilio extends CRM_SMS_Provider {
function inbound() {
$like = "";
$fromPhone = $this->retrieve('From', 'String');
return parent::inbound($fromPhone, $this->retrieve('Body', 'String'), NULL, $this->retrieve('SmsSid', 'String'));
return parent::processInbound($fromPhone, $this->retrieve('Body', 'String'), NULL, $this->retrieve('SmsSid', 'String'));
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment