X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FBAO%2FCustomField.php;h=bcfd206cf16ce65db8d00461ccc66e9697a9dc9f;hb=762e3fc83142fd773e32909051236f645c5a5465;hp=ba33cb9fec605732d7fd673204416d700723739d;hpb=d612bf88660ab476e7c503a890314c69f10b6164;p=civicrm-core.git diff --git a/CRM/Core/BAO/CustomField.php b/CRM/Core/BAO/CustomField.php index ba33cb9fec..bcfd206cf1 100644 --- a/CRM/Core/BAO/CustomField.php +++ b/CRM/Core/BAO/CustomField.php @@ -1217,7 +1217,12 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField { case 'Multi-Select State/Province': case 'Multi-Select Country': if ($field['data_type'] == 'ContactReference' && $value) { - $display = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $value, 'display_name'); + if (is_numeric($value)) { + $display = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $value, 'display_name'); + } + else { + $display = $value; + } } elseif (is_array($value)) { $v = array(); @@ -1666,7 +1671,7 @@ SELECT id $value = 0; } - $fileId = NULL; + $fileID = NULL; if ($customFields[$customFieldId]['data_type'] == 'File') { if (empty($value)) { @@ -1705,20 +1710,20 @@ SELECT $columnName FROM $tableName WHERE id = %1"; $params = array(1 => array($customValueId, 'Integer')); - $fileId = CRM_Core_DAO::singleValueQuery($query, $params); + $fileID = CRM_Core_DAO::singleValueQuery($query, $params); } $fileDAO = new CRM_Core_DAO_File(); - if ($fileId) { - $fileDAO->id = $fileId; + if ($fileID) { + $fileDAO->id = $fileID; } $fileDAO->uri = $filename; $fileDAO->mime_type = $mimeType; $fileDAO->upload_date = date('YmdHis'); $fileDAO->save(); - $fileId = $fileDAO->id; + $fileID = $fileDAO->id; $value = $filename; } @@ -1746,7 +1751,7 @@ SELECT $columnName 'custom_group_id' => $groupID, 'table_name' => $tableName, 'column_name' => $columnName, - 'file_id' => $fileId, + 'file_id' => $fileID, 'is_multiple' => $customFields[$customFieldId]['is_multiple'], ); @@ -2429,6 +2434,31 @@ WHERE cf.id = %1 AND cg.is_multiple = 1"; return $isMultipleWithGid; } + /** + * Does this field type have any select options? + * + * @param array $field + * + * @return bool + */ + public static function hasOptions($field) { + // Fields retrieved via api are an array, or from the dao are an object. We'll accept either. + $field = (array) $field; + // This will include boolean fields with Yes/No options. + if (in_array($field['html_type'], ['Radio', 'CheckBox'])) { + return TRUE; + } + // Do this before the "Select" string search because date fields have a "Select Date" html_type + // and contactRef fields have an "Autocomplete-Select" html_type - contacts are an FK not an option list. + if (in_array($field['data_type'], ['ContactReference', 'Date'])) { + return FALSE; + } + if (strpos($field['html_type'], 'Select') !== FALSE) { + return TRUE; + } + return !empty($field['option_group_id']); + } + /** * Does this field store a serialized string? *