-
-
Notifications
You must be signed in to change notification settings - Fork 814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CRM-21405 Allow "Outbound SMS" when Mobile is not primary phone number #11252
CRM-21405 Allow "Outbound SMS" when Mobile is not primary phone number #11252
Conversation
@JKingsnorth Are you able to review this please? |
1892bdd
to
8a7d7a4
Compare
Jenkins test this please |
@JKingsnorth @monishdeb @michaelmcandrew Be great if we could get this simple SMS PR reviewed/merged :-) |
Hi @mattwire I did some manual UI testing on this. Here are the results in the format "Conditions -> Could I see the outbound SMS action?"
So it looks like it is working nicely. I presume that the following section is API chaining but I am slightly baffled as to how it works. I would have thought that if you want to get a field from the contact entity, you need to reference the contact entity somewhere. $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"), Maybe the phone API is randomly returning some fields from the contact. Or maybe it is a documented feature that I am not aware of. On the one hand, I am hesitant to suggest modifying code that works / passes the manual testing I did. On the other hand, if this is an undocumented way of using the phone API that is not guaranteed to work in the future, it would be good to change it. Do you have any ideas about that? |
@mattwire - I rewrote the api call to use explicit chaining - let me know what you think. |
@michaelmcandrew That's fine - happy with your changes. I think both work :-) So, do you think this is good to merge? |
CRM/Activity/Form/ActivityLinks.php
Outdated
try { | ||
$phone = civicrm_api3('Phone', 'getsingle', array( | ||
'contact_id' => $contactId, | ||
'phone_type_id' => $mobileTypeID, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use
- 'phone_type_id' => $mobileTypeID,
+ 'phone_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Phone', 'phone_type_id', 'Mobile'),
as I can see $mobileTypeID isn't used anywhere else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good
catch (CiviCRM_API3_Exception $e) { | ||
continue; | ||
} | ||
if (!$phone['api.Contact.getsingle']['do_not_sms'] && $phone['phone']) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope this doesn't throw notice errors as it will hit continue
before that, at line 94 if $phone is empty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the contact does not have a phone, then getsingle will indeed throw an exception which will get caught, so no notice will be shown. I ran the code to check that this actually happened.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool 👍
Apart from the minor change mentioned in the patch and based on @michaelmcandrew feedback, this PR good to merge. Will it be possible to replicate this behavior in a unit test? |
Yup, I vote merge
…On 14 Feb 2018 21:07, "Matthew Wire" ***@***.***> wrote:
@michaelmcandrew <https://github.com/michaelmcandrew> That's fine - happy
with your changes. I think both work :-) So, do you think this is good to
merge?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#11252 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAM0L5lZ6K-Pg04S-eGEfgQFm1MZFmY4ks5tU0r6gaJpZM4QWPB9>
.
|
Sorry @monishdeb, I sent that previous message from my email and had not seen your message - have replied now. |
@michaelmcandrew no problem and thanks for your quick response. @mattwire can you please make the minor change mentioned in the patch? |
304e9ce
to
c9184ed
Compare
@monishdeb I've made the changes as requested. Merge on pass? |
Absolutely 👍 |
Overview
Allow "Outbound SMS" when Mobile is not primary phone number
Before
When a contact has a mobile phone number but it is not the primary number the "Outbound SMS" action is removed from the contact actions.
After
When a contact has a mobile phone number but it is not the primary number the "Outbound SMS" action is allowed, and will use the first available mobile number from the contact.