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

CRM-21041: Respect default 'Communication Style' when creating a … #11269

Conversation

varshith
Copy link
Contributor

...Contact via API

Overview

Respect default 'Communication Style' when creating a Contact through the API

Before

When creating a contact via the API, the default 'Communication Style' is not used and the contact has no value set for Communication Style.

After

Now when a contact is created via the API, the default 'Communication Style' is set for that contact.

@civicrm-builder
Copy link

Can one of the admins verify this patch?

@colemanw
Copy link
Member

@civicrm-builder add to whitelist


// CRM-21041: set default 'Communication Style' if unset when creating a contact.
if (empty($params['communication_style_id'])) {
$params['communication_style_id'] = array_pop(CRM_Core_OptionGroup::values('communication_style', TRUE, NULL, NULL, 'AND is_default = 1'));
Copy link
Member

Choose a reason for hiding this comment

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

in some versions of php this won't work because array_pop() can't be called on a function.

@@ -306,6 +306,11 @@ public static function &create(&$params, $fixAddress = TRUE, $invokeHooks = TRUE
}
}
}

// CRM-21041: set default 'Communication Style' if unset when creating a contact.
if (empty($params['communication_style_id'])) {
Copy link
Member

Choose a reason for hiding this comment

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

Should also test for the presence of id in params and skip if updating.

Copy link
Contributor Author

@varshith varshith Nov 12, 2017

Choose a reason for hiding this comment

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

@colemanw
This whole code block lives inside
if (empty($params['contact_id'])) { } check
So this will only be executed when creating a contact and will be skipped when updating one.
Pls let me know if this is not what you were referring to
Thanks

@colemanw colemanw merged commit 233c850 into civicrm:master Nov 13, 2017
sluc23 pushed a commit to ixiam/civicrm-core that referenced this pull request Jan 10, 2018
…ult_communication_style_on_api_contact_create

CRM-21041: Respect default 'Communication Style' when creating a …
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants