function wf_civicrm_api in Webform CiviCRM Integration 7.3
Same name and namespace in other branches
- 7.5 includes/utils.inc \wf_civicrm_api()
- 7.4 includes/utils.inc \wf_civicrm_api()
Wrapper for all CiviCRM API calls For consistency, future-proofing, and error handling
Parameters
string $entity: API entity
string $operation: API operation
array $params: API params
Return value
array Result of API call
12 calls to wf_civicrm_api()
- webform_civicrm_update_6205 in ./
webform_civicrm.install - Upgrade for CiviCRM 4.1 compatibility.
- webform_civicrm_update_7300 in ./
webform_civicrm.install - Note: There are differences in how contact references and relationships work in the 3.x branch. Read the upgrade instructions at http://drupal.org/node/1615380
- wf_crm_add_remove in ./
webform_civicrm_forms.inc - Handle adding/removing multivalued data for a contact/activity/etc. Currently used only for groups and tags, but written with expansion in mind.
- wf_crm_case_find in ./
webform_civicrm_utils.inc - Fetch an existing case for client(s) Based on url param or status_id and case_type_id
- wf_crm_contact_access in ./
contact_component.inc - Load contact name if user has permission. Else return FALSE.
File
- ./
webform_civicrm_utils.inc, line 1289 - Webform CiviCRM module's common utility functions.
Code
function wf_civicrm_api($entity, $operation, $params) {
$params += array(
'check_permissions' => FALSE,
'version' => 3,
);
// Workaround the multivalued option issue until it's resolved in core
if ($entity == 'contact' && $operation == 'create') {
$sp = CRM_Core_DAO::VALUE_SEPARATOR;
foreach ($params as &$val) {
if (is_array($val)) {
$val = $val ? $sp . implode($sp, $val) . $sp : '';
}
}
}
$result = civicrm_api($entity, $operation, $params);
if (!empty($result['is_error'])) {
$bt = debug_backtrace();
$file = explode('/', $bt[0]['file']);
watchdog('webform_civicrm', 'The CiviCRM "%function" API function returned the error: "%msg" when called by line !line of !file with the following parameters: "!params"', array(
'%function' => $entity . ' ' . $operation,
'%msg' => $result['error_message'],
'!line' => $bt[0]['line'],
'!file' => array_pop($file),
'!params' => print_r($params, TRUE),
), WATCHDOG_ERROR);
}
return $result;
}