}
}
+ $rangeDataTypes = ['Int', 'Float', 'Money'];
+
if (!isset($label)) {
$label = $field->label;
}
switch ($widget) {
case 'Text':
case 'Link':
- if ($field->is_search_range && $search) {
+ if ($field->is_search_range && $search && in_array($field->data_type, $rangeDataTypes)) {
$qf->add('text', $elementName . '_from', $label . ' ' . ts('From'), $field->attributes);
$qf->add('text', $elementName . '_to', ts('To'), $field->attributes);
}
break;
case 'Radio':
- $choice = array();
- parse_str($field->attributes, $radioAttributes);
- $radioAttributes = array_merge($radioAttributes, $customFieldAttributes);
-
- foreach ($options as $v => $l) {
- $choice[] = $qf->createElement('radio', NULL, '', $l, (string) $v, $radioAttributes);
- }
- $element = $qf->addGroup($choice, $elementName, $label);
- $optionEditKey = 'data-option-edit-path';
- if (isset($selectAttributes[$optionEditKey])) {
- $element->setAttribute($optionEditKey, $selectAttributes[$optionEditKey]);
- }
-
- if ($useRequired && !$search) {
- $qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required');
+ if ($field->is_search_range && $search && in_array($field->data_type, $rangeDataTypes)) {
+ $qf->add('text', $elementName . '_from', $label . ' ' . ts('From'), $field->attributes);
+ $qf->add('text', $elementName . '_to', ts('To'), $field->attributes);
}
else {
- $element->setAttribute('allowClear', TRUE);
+ $choice = array();
+ parse_str($field->attributes, $radioAttributes);
+ $radioAttributes = array_merge($radioAttributes, $customFieldAttributes);
+
+ foreach ($options as $v => $l) {
+ $choice[] = $qf->createElement('radio', NULL, '', $l, (string) $v, $radioAttributes);
+ }
+ $element = $qf->addGroup($choice, $elementName, $label);
+ $optionEditKey = 'data-option-edit-path';
+ if (isset($selectAttributes[$optionEditKey])) {
+ $element->setAttribute($optionEditKey, $selectAttributes[$optionEditKey]);
+ }
+
+ if ($useRequired && !$search) {
+ $qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required');
+ }
+ else {
+ $element->setAttribute('allowClear', TRUE);
+ }
}
break;
// For all select elements
case 'Select':
- if (empty($selectAttributes['multiple'])) {
- $options = array('' => $placeholder) + $options;
+ if ($field->is_search_range && $search && in_array($field->data_type, $rangeDataTypes)) {
+ $qf->add('text', $elementName . '_from', $label . ' ' . ts('From'), $field->attributes);
+ $qf->add('text', $elementName . '_to', ts('To'), $field->attributes);
}
- $element = $qf->add('select', $elementName, $label, $options, $useRequired && !$search, $selectAttributes);
+ else {
+ if (empty($selectAttributes['multiple'])) {
+ $options = array('' => $placeholder) + $options;
+ }
+ $element = $qf->add('select', $elementName, $label, $options, $useRequired && !$search, $selectAttributes);
- // Add and/or option for fields that store multiple values
- if ($search && self::isSerialized($field)) {
+ // Add and/or option for fields that store multiple values
+ if ($search && self::isSerialized($field)) {
- $operators = array(
- $qf->createElement('radio', NULL, '', ts('Any'), 'or', array('title' => ts('Results may contain any of the selected options'))),
- $qf->createElement('radio', NULL, '', ts('All'), 'and', array('title' => ts('Results must have all of the selected options'))),
- );
- $qf->addGroup($operators, $elementName . '_operator');
- $qf->setDefaults(array($elementName . '_operator' => 'or'));
+ $operators = array(
+ $qf->createElement('radio', NULL, '', ts('Any'), 'or', array('title' => ts('Results may contain any of the selected options'))),
+ $qf->createElement('radio', NULL, '', ts('All'), 'and', array('title' => ts('Results must have all of the selected options'))),
+ );
+ $qf->addGroup($operators, $elementName . '_operator');
+ $qf->setDefaults(array($elementName . '_operator' => 'or'));
+ }
}
break;
$urlParams = "context=customfield&id={$field->id}";
$idOfelement = $elementName;
// dev/core#362 if in an onbehalf profile clean up the name to get rid of square brackets that break the select 2 js
- if (strpos($elementName, '[') && strpos($elementName, ']')) {
+ // However this caused regression https://lab.civicrm.org/dev/core/issues/619 so it has been hacked back to
+ // only affecting on behalf - next time someone looks at this code it should be with a view to overhauling it
+ // rather than layering on more hacks.
+ if (substr($elementName, 0, 8) === 'onbehalf' && strpos($elementName, '[') && strpos($elementName, ']')) {
$idOfelement = substr(substr($elementName, (strpos($elementName, '[') + 1)), 0, -1);
}
$customUrls[$idOfelement] = CRM_Utils_System::url('civicrm/ajax/contactref',
else {
// FIXME: This won't work with customFieldOptions hook
$attributes += array(
- 'entity' => 'option_value',
+ 'entity' => 'OptionValue',
'placeholder' => $placeholder,
'multiple' => $search,
'api' => array(
case 'Text':
if ($field['data_type'] == 'Money' && isset($value)) {
- //$value can also be an array(while using IN operator from search builder or api).
+ // $value can also be an array(while using IN operator from search builder or api).
foreach ((array) $value as $val) {
$disp[] = CRM_Utils_Money::format($val, NULL, NULL, TRUE);
}
'entity_id',
'file_id'
);
- list($path) = CRM_Core_BAO_File::path($fileID, $entityId, NULL, NULL);
+ list($path) = CRM_Core_BAO_File::path($fileID, $entityId);
+ $fileHash = CRM_Core_BAO_File::generateFileHash($entityId, $fileID);
$url = CRM_Utils_System::url('civicrm/file',
- "reset=1&id=$fileID&eid=$contactID",
+ "reset=1&id=$fileID&eid=$entityId&fcs=$fileHash",
$absolute, NULL, TRUE, TRUE
);
$result['file_url'] = CRM_Utils_File::getFileURL($path, $fileType, $url);
$fileID,
'uri'
);
+ $fileHash = CRM_Core_BAO_File::generateFileHash($contactID, $fileID);
$url = CRM_Utils_System::url('civicrm/file',
- "reset=1&id=$fileID&eid=$contactID",
+ "reset=1&id=$fileID&eid=$contactID&fcs=$fileHash",
$absolute, NULL, TRUE, TRUE
);
$result['file_url'] = CRM_Utils_File::getFileURL($uri, $fileType, $url);