foreach ($entities as $entity) {
$fields = civicrm_api3($entity, 'getfields');
foreach ($fields['values'] as $field => $info) {
- if (!empty($info['options']) || !empty($info['pseudoconstant']) || !empty($info['option_group_id']) || !empty($info['enumValues'])) {
+ if (!empty($info['options']) || !empty($info['pseudoconstant']) || !empty($info['option_group_id'])) {
$options[$field] = $entity;
if (substr($field, -3) == '_id') {
$options[substr($field, 0, -3)] = $entity;
}
$table['fields'] = &$fields;
- $table['hasEnum'] = FALSE;
- foreach ($table['fields'] as $field) {
- if ($field['crmType'] == 'CRM_Utils_Type::T_ENUM') {
- $table['hasEnum'] = TRUE;
- break;
- }
- }
if ($this->value('primaryKey', $tableXML)) {
$this->getPrimaryKey($tableXML->primaryKey, $fields, $table);
$field['size'] = $this->getSize($fieldXML);
break;
- case 'enum':
- $value = (string ) $fieldXML->values;
- $field['sqlType'] = 'enum(';
- $field['values'] = array();
- $field['enumValues'] = $value;
- $values = explode(',', $value);
- $first = TRUE;
- foreach ($values as $v) {
- $v = trim($v);
- $field['values'][] = $v;
-
- if (!$first) {
- $field['sqlType'] .= ', ';
- }
- $first = FALSE;
- $field['sqlType'] .= "'$v'";
- }
- $field['sqlType'] .= ')';
- $field['phpType'] = $field['sqlType'];
- $field['crmType'] = 'CRM_Utils_Type::T_ENUM';
- break;
-
case 'text':
$field['sqlType'] = $field['phpType'] = $type;
$field['crmType'] = 'CRM_Utils_Type::T_' . strtoupper($type);
case CRM_Utils_Type::T_LONGTEXT:
case CRM_Utils_Type::T_EMAIL:
default:
- if (isset($value['enumValues'])) {
- if (isset($value['default'])) {
- $object->$dbName = $value['default'];
- }
- else {
- if (is_array($value['enumValues'])) {
- $object->$dbName = $value['enumValues'][0];
- }
- else {
- $defaultValues = explode(',', $value['enumValues']);
- $object->$dbName = $defaultValues[0];
- }
- }
- }
- else {
- $object->$dbName = $dbName . '_' . $counter;
- $maxlength = CRM_Utils_Array::value('maxlength', $value);
- if ($maxlength > 0 && strlen($object->$dbName) > $maxlength) {
- $object->$dbName = substr($object->$dbName, 0, $value['maxlength']);
- }
+ $object->$dbName = $dbName . '_' . $counter;
+ $maxlength = CRM_Utils_Array::value('maxlength', $value);
+ if ($maxlength > 0 && strlen($object->$dbName) > $maxlength) {
+ $object->$dbName = substr($object->$dbName, 0, $value['maxlength']);
}
}
}
return FALSE;
}
- // If the field is an enum, explode the enum definition and return the array.
- if (isset($fieldSpec['enumValues'])) {
- // use of a space after the comma is inconsistent in xml
- $enumStr = str_replace(', ', ',', $fieldSpec['enumValues']);
- $output = explode(',', $enumStr);
- return array_combine($output, $output);
- }
-
elseif (!empty($fieldSpec['pseudoconstant'])) {
$pseudoconstant = $fieldSpec['pseudoconstant'];
// Merge params with schema defaults
break;
default:
if ($daoOrBaoName &&
- (array_key_exists('pseudoconstant', $this->_columns[$tableName][$fieldGrp][$fieldName])
- || array_key_exists('enumValues', $this->_columns[$tableName][$fieldGrp][$fieldName]))
- ) {
+ array_key_exists('pseudoconstant', $this->_columns[$tableName][$fieldGrp][$fieldName])) {
// with multiple options operator-type is generally multi-select
$this->_columns[$tableName][$fieldGrp][$fieldName]['operatorType'] = CRM_Report_Form::OP_MULTISELECT;
if (!array_key_exists('options', $this->_columns[$tableName][$fieldGrp][$fieldName])) {
* - the reason for this is that checking / transformation is done on pseudoconstants but
* - if the field is an FK then mysql will enforce the data quality (& we have handling on failure)
* @todo - if may be we should define a 'resolve' key on the psuedoconstant for when these rules are not fine enough
- * 3) if there is an 'enum' then it is split up into the relevant options
*
* This function is only split out for the purpose of code clarity / comment block documentation
* @param array $metadata the array of metadata that will form the result of the getfields function
* @param array $fieldsToResolve anny field resolutions specifically requested
*/
function _civicrm_api3_generic_get_metadata_options(&$metadata, $entity, $fieldname, $fieldSpec, $fieldsToResolve){
- if(empty($fieldSpec['pseudoconstant']) && empty($fieldSpec['enumValues'])) {
+ if (empty($fieldSpec['pseudoconstant'])) {
return;
}
throw new Exception("Currency not a valid code: $value");
}
}
- if (!empty($fieldInfo['pseudoconstant']) || !empty($fieldInfo['options']) || !empty($fieldInfo['enumValues'])) {
+ if (!empty($fieldInfo['pseudoconstant']) || !empty($fieldInfo['options'])) {
_civicrm_api3_api_match_pseudoconstant($params, $entity, $fieldName, $fieldInfo);
}
// Check our field length
case CRM_Utils_Type::T_URL:
$entity[$field] = 'warm.beer.com';
}
- if (!empty($specs['pseudoconstant']) || !empty($specs['enumValues'])) {
+ if (!empty($specs['pseudoconstant'])) {
$options = $this->callAPISuccess($entityName, 'getoptions', array('context' => 'create', 'field' => $field));
if (empty($options['values'])) {
}
{if $field.default}
'default' => '{if ($field.default[0]=="'" or $field.default[0]=='"')}{$field.default|substring:1:-1}{else}{$field.default}{/if}',
{/if} {* field.default *}
-{if $field.enumValues}
- 'enumValues' => '{$field.enumValues}',
-{/if} {* field.enumValues *}
{if $field.FKClassName}
'FKClassName' => '{$field.FKClassName}',