From 819598272e5b0e34a7530e4dfbedc202470d15a7 Mon Sep 17 00:00:00 2001 From: eileen Date: Sat, 27 Jul 2019 17:21:27 +1200 Subject: [PATCH] Fix support for relative dates in urls This improves support for relative dates for fields that have been converted. For example http://dmaster.local/civicrm/contribute/search?reset=1&receive_date_relative=this.year&force=1 Now works to render donations 'This Calendar Year' --- CRM/Core/Form/Search.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CRM/Core/Form/Search.php b/CRM/Core/Form/Search.php index 26f7de8e4a..80ef7ca4f5 100644 --- a/CRM/Core/Form/Search.php +++ b/CRM/Core/Form/Search.php @@ -268,6 +268,8 @@ class CRM_Core_Form_Search extends CRM_Core_Form { * @param string $entity * * @return array + * + * @throws \CRM_Core_Exception */ protected function getEntityDefaults($entity) { $defaults = []; @@ -285,6 +287,12 @@ class CRM_Core_Form_Search extends CRM_Core_Form { $defaults[$fieldName . '_low'] = $low ? date('Y-m-d H:i:s', strtotime($low)) : NULL; $defaults[$fieldName . '_high'] = $high ? date('Y-m-d H:i:s', strtotime($high)) : NULL; } + else { + $relative = CRM_Utils_Request::retrieveValue($fieldName . '_relative', 'String', NULL, NULL, 'GET'); + if (!empty($relative) && isset(CRM_Core_OptionGroup::values('relative_date_filters')[$relative])) { + $defaults[$fieldName . '_relative'] = $relative; + } + } } } } -- 2.25.1