Skip to content
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

Get phone_type by name. dev/core#2138 #18842

Merged
merged 1 commit into from
Oct 23, 2020
Merged

Conversation

muniodiego
Copy link
Contributor

Overview

When wanting to send an SMS, a mobile phone is not identified if it is not primary and if the label of the mobile phone type has been translated or modifed.

@civibot
Copy link

civibot bot commented Oct 22, 2020

(Standard links)

@civibot civibot bot added the master label Oct 22, 2020
@@ -92,7 +92,8 @@ public static function allPhones($id, $updateBlankLocInfo = FALSE, $type = NULL,

$cond = NULL;
if ($type) {
$phoneTypeId = array_search($type, CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'));
$phoneTypes = CRM_Core_OptionGroup::values('phone_type', TRUE, FALSE, FALSE, NULL, 'name');
$phoneTypeId = CRM_Utils_Array::value($type, $phoneTypes);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what the latest standard is but I think it would be preferred to replace both these lines with $phoneTypeId = CRM_Core_PseudoConstant::getKey('CRM_Core_DAO_Phone', 'phone_type_id', $type). In any case CRM_Utils_Array::value is discouraged in places where you can use $a[$b] ?? NULL instead.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes -

$phoneTypeId = CRM_Core_PseudoConstant::getKey('CRM_Core_DAO_Phone', 'phone_type_id', $type);

is the preferred syntax for this

@muniodiego
Copy link
Contributor Author

Thanks @demeritcowboy and @eileenmcnaughton . I have updated the code.

@demeritcowboy
Copy link
Contributor

  • General standards
    • [r-explain] PASS
      • This probably hasn't come up as often as it should because yes it only occurs when both the mobile phone is not primary and the label is not Mobile.
    • [r-user] PASS
    • [r-doc] PASS
    • [r-run] PASS
      • Fixed.
  • Developer standards
    • [r-tech] PASS
    • [r-code] PASS
    • [r-maint] ?
    • [r-test] PASS

@eileenmcnaughton
Copy link
Contributor

Nice - thanks @muniodiego @demeritcowboy

@eileenmcnaughton eileenmcnaughton merged commit 983cf05 into civicrm:master Oct 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants