/** * Updates the class attribute to contain all custom fields of the * donation receipt database table. */ public static function getCustomFields() { if (self::$_custom_fields === NULL) { // get the ids of all relevant custom fields $params = array('version' => 3, 'name' => 'zwb_donation_receipt_item'); $custom_group = civicrm_api('CustomGroup', 'getsingle', $params); if (isset($custom_group['is_error'])) { CRM_Core_Error::debug_log_message(sprintf('de.systopia.donrec: getCustomFields: error: %s', $custom_group['error_message'])); return NULL; } self::$_custom_group_id = $custom_group['id']; $params = array('version' => 3, 'option.limit' => 999, 'custom_group_id' => $custom_group['id']); $custom_fields = civicrm_api('CustomField', 'get', $params); if ($custom_fields['is_error'] != 0) { CRM_Core_Error::debug_log_message(sprintf('de.systopia.donrec: getCustomFields: error: %s', $custom_fields['error_message'])); return NULL; } self::$_custom_fields = array(); foreach ($custom_fields['values'] as $field) { self::$_custom_fields[$field['name']] = $field['column_name']; } } return self::$_custom_fields; }