Skip to content

Commit

Permalink
Merge pull request #11252 from mattwire/CRM-21405_outboundsms_mobile_…
Browse files Browse the repository at this point in the history
…notprimary

CRM-21405 Allow "Outbound SMS" when Mobile is not primary phone number
  • Loading branch information
monishdeb authored Feb 16, 2018
2 parents 8c3695a + c9184ed commit 56715f8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
19 changes: 16 additions & 3 deletions CRM/Activity/Form/ActivityLinks.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,22 @@ public static function commonBuildQuickForm($self) {
continue;
}
// Check for existence of a mobile phone and ! do not SMS privacy setting
$mobileTypeID = CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Phone', 'phone_type_id', 'Mobile');
list($name, $phone, $doNotSMS) = CRM_Contact_BAO_Contact_Location::getPhoneDetails($contactId, $mobileTypeID);
if (!$doNotSMS && $phone) {
try {
$phone = civicrm_api3('Phone', 'getsingle', array(
'contact_id' => $contactId,
'phone_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Phone', 'phone_type_id', 'Mobile'),
'return' => array('phone', 'contact_id'),
'options' => array('limit' => 1, 'sort' => "is_primary DESC"),
'api.Contact.getsingle' => array(
'id' => '$value.contact_id',
'return' => 'do_not_sms',
),
));
}
catch (CiviCRM_API3_Exception $e) {
continue;
}
if (!$phone['api.Contact.getsingle']['do_not_sms'] && $phone['phone']) {
$url = 'civicrm/activity/sms/add';
}
else {
Expand Down
2 changes: 2 additions & 0 deletions CRM/Contact/BAO/Contact/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public static function getEmailDetails($id, $isPrimary = TRUE, $locationTypeID =
}

/**
* @deprecated Not used anywhere, use the Phone API instead
* Get the sms number and display name of a contact.
*
* @param int $id
Expand All @@ -74,6 +75,7 @@ public static function getEmailDetails($id, $isPrimary = TRUE, $locationTypeID =
* tuple of display_name and sms if found, or (null,null)
*/
public static function getPhoneDetails($id, $type = NULL) {
Civi::log()->warning('Deprecated function CRM_Contact_BAO_Contact_Location::getPhoneDetails, use Phone.get API instead', array('civi.tag' => 'deprecated'));
if (!$id) {
return array(NULL, NULL);
}
Expand Down

0 comments on commit 56715f8

Please sign in to comment.