$query->_tables['contribution_batch'] = 1;
}
+ if (!empty($query->_returnProperties['contribution_source'])) {
+ $query->_select['contribution_source'] = "civicrm_contribution.source as contribution_source";
+ $query->_element['contribution_source'] = 1;
+ $query->_tables['civicrm_contribution'] = 1;
+ }
+
// get contribution_status
if (!empty($query->_returnProperties['contribution_status_id'])) {
$query->_select['contribution_status_id'] = "contribution_status.value as contribution_status_id";
2100, array('field' => $fieldName, "max_length"=>$fieldInfo['maxlength'])
);
}
+ $params[$fieldName] = $fieldValue;
}
}
*/
function _civicrm_api3_api_match_pseudoconstant(&$fieldValue, $entity, $fieldName, $fieldInfo) {
$options = CRM_Utils_Array::value('options', $fieldInfo);
+ $pseudoconstant = CRM_Utils_Array::value('pseudoconstant', $fieldInfo);
+
if (!$options) {
if (strtolower($entity) == 'profile' && !empty($fieldInfo['entity'])) {
// we need to get the options from the entity the field relates to
}
$options = civicrm_api($entity, 'getoptions', array('version' => 3, 'field' => $fieldInfo['name'], 'context' => 'validate'));
$options = CRM_Utils_Array::value('values', $options, array());
+
+ if (count($options) == 0 && isset($pseudoconstant['table'])) {
+ $pseudoParams = $pseudoconstant;
+ unset($pseudoParams['table']);
+ $options = CRM_Core_PseudoConstant::get(CRM_Core_DAO_AllCoreTables::getClassForTable($pseudoconstant['table']), $fieldName, $pseudoParams);
+ }
}
// If passed a value-separated string, explode to an array, then re-implode after matching values
*/
function _civicrm_api3_api_match_pseudoconstant_value(&$value, $options, $fieldName) {
// If option is a key, no need to translate
- if (array_key_exists($value, $options)) {
+ // or if no options are avaiable for pseudoconstant 'table' property
+ if (array_key_exists($value, $options) || !$options) {
return;
}
));
$options['values'][] = $optionValue['id'];
}
+ if (isset($specs['pseudoconstant']['table'])) {
+ //some psedoconstant property is based on other entity attributes
+ //as the there may or maynot be records for such entity, so we are considering empty records for now
+ //e.g. pcp_id property will be table=civicrm_pcp, keyColumn=id and labelColumn=title
+ continue;
+ }
}
$entity[$field] = array_rand($options['values']);
}