Skip to content

Commit

Permalink
Allow "Outbound SMS" when Mobile is not primary phone number
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwire committed Nov 8, 2017
1 parent 87e7278 commit 1892bdd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 13 additions & 2 deletions CRM/Activity/Form/ActivityLinks.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,19 @@ public static function commonBuildQuickForm($self) {
}
// 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(
'return' => array("contact_id.do_not_sms", "phone"),
'phone_type_id' => $mobileTypeID,
'contact_id' => $contactId,
'options' => array('limit' => 1, 'sort' => "is_primary DESC"),
));
}
catch (CRM_Core_Exception $e) {
// No mobile number found
continue;
}
if (!$phone['contact_id.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 @@ -73,6 +73,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 @@ -84,6 +85,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 1892bdd

Please sign in to comment.