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 {
}
/**
+ * @deprecated Not used anywhere, use the Phone API instead
* Get the sms number and display name of a contact.
*
* @param int $id
* 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);
}