X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FBAO%2FQuery.php;h=fed0c0edaa4ae509f5102b04067ef9ddb037eb88;hb=f299f7db79fed6f3598c84302966bda087e7cac3;hp=5e700a7ae01e61f09c7e73e0f0ce09dc0df65f16;hpb=fa3cdb8efb79c28c9f425543815556f6cfefe9ac;p=civicrm-core.git diff --git a/CRM/Core/BAO/Query.php b/CRM/Core/BAO/Query.php index 5e700a7ae0..fed0c0edaa 100644 --- a/CRM/Core/BAO/Query.php +++ b/CRM/Core/BAO/Query.php @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 5 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2019 | + | Copyright CiviCRM LLC (c) 2004-2020 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2019 + * @copyright CiviCRM LLC (c) 2004-2020 * $Id$ * */ @@ -47,8 +47,8 @@ class CRM_Core_BAO_Query { foreach ($group['fields'] as $field) { $fieldId = $field['id']; $elementName = 'custom_' . $fieldId; - if ($field['data_type'] == 'Date' && $field['is_search_range']) { - CRM_Core_Form_Date::buildDateRange($form, $elementName, 1, '_from', '_to', ts('From:'), FALSE); + if ($field['data_type'] === 'Date' && $field['is_search_range']) { + $form->addDatePickerRange($elementName, $field['label']); } else { CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, FALSE, TRUE); @@ -58,6 +58,27 @@ class CRM_Core_BAO_Query { } } + /** + * Get legacy fields which we still maybe support. + * + * These are contribution specific but I think it's ok to have one list of legacy supported + * params in a central place. + * + * @return array + */ + protected static function getLegacySupportedFields(): array { + // @todo enotices when these are hit so we can start to elimnate them. + $fieldAliases = [ + 'financial_type' => 'financial_type_id', + 'contribution_page' => 'contribution_page_id', + 'payment_instrument' => 'payment_instrument_id', + // or payment_instrument_id? + 'contribution_payment_instrument' => 'contribution_payment_instrument_id', + 'contribution_status' => 'contribution_status_id', + ]; + return $fieldAliases; + } + /** * Getter for the qill object. * @@ -80,4 +101,22 @@ class CRM_Core_BAO_Query { */ public static function tableNames(&$tables) {} + /** + * Get the name of the field. + * + * @param array $values + * + * @return string + */ + protected static function getFieldName($values) { + $name = $values[0]; + $fieldAliases = self::getLegacySupportedFields(); + if (isset($fieldAliases[$name])) { + CRM_Core_Error::deprecatedFunctionWarning('These parameters should be standardised before we get here'); + return $fieldAliases[$name]; + } + + return str_replace(['_high', '_low'], '', $name); + } + }