From 3c49839d4b72dd240652b4c94f73baa8d803690c Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 15 May 2017 11:19:36 +1200 Subject: [PATCH] Fix call to deprecated funciton --- CRM/Contact/BAO/SavedSearch.php | 7 ++++++ .../Form/Search/Custom/ContribSYBNT.php | 24 ++++++++++++++++++- CRM/Core/BAO/ActionSchedule.php | 5 +--- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/CRM/Contact/BAO/SavedSearch.php b/CRM/Contact/BAO/SavedSearch.php index 694f849847..04fe04ef7c 100644 --- a/CRM/Contact/BAO/SavedSearch.php +++ b/CRM/Contact/BAO/SavedSearch.php @@ -183,6 +183,13 @@ class CRM_Contact_BAO_SavedSearch extends CRM_Contact_DAO_SavedSearch { } } + if ($customSearchClass = CRM_Utils_Array::value('customSearchClass', $result)) { + // check if there is a special function - formatSavedSearchFields defined in the custom search form + if (method_exists($customSearchClass, 'formatSavedSearchFields')) { + $customSearchClass::formatSavedSearchFields($result); + } + } + return $result; } diff --git a/CRM/Contact/Form/Search/Custom/ContribSYBNT.php b/CRM/Contact/Form/Search/Custom/ContribSYBNT.php index 52601d1a5f..e88f797070 100644 --- a/CRM/Contact/Form/Search/Custom/ContribSYBNT.php +++ b/CRM/Contact/Form/Search/Custom/ContribSYBNT.php @@ -43,7 +43,7 @@ class CRM_Contact_Form_Search_Custom_ContribSYBNT extends CRM_Contact_Form_Searc * @param $formValues */ public function __construct(&$formValues) { - $this->_formValues = $formValues; + $this->_formValues = self::formatSavedSearchFields($formValues); $this->_permissionedComponent = 'CiviContribute'; $this->_columns = array( @@ -400,4 +400,26 @@ AND c.receive_date < {$this->start_date_1} list($this->_aclFrom, $this->_aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause($tableAlias); } + /** + * Format saved search fields for this custom group + * + * @param array $formValues + * + */ + public static function formatSavedSearchFields(&$formValues) { + $dateFields = array( + 'start_date_1', + 'end_date_1', + 'start_date_2', + 'end_date_2', + 'exclude_start_date', + 'exclude_end_date', + ); + foreach ($formValues as $element => $value) { + if (in_array($element, $dateFields) && !empty($value)) { + $formValues[$element] = date('Y-m-d', strtotime($value)); + } + } + } + } diff --git a/CRM/Core/BAO/ActionSchedule.php b/CRM/Core/BAO/ActionSchedule.php index 35a41f1aae..45cfe04a2a 100644 --- a/CRM/Core/BAO/ActionSchedule.php +++ b/CRM/Core/BAO/ActionSchedule.php @@ -556,10 +556,7 @@ FROM civicrm_action_schedule cas 'provider_id' => $schedule->sms_provider_id, 'activity_subject' => $messageSubject, ); - $activityTypeID = CRM_Core_OptionGroup::getValue('activity_type', - 'SMS', - 'name' - ); + $activityTypeID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'SMS'); $activityParams = array( 'source_contact_id' => $userID, 'activity_type_id' => $activityTypeID, -- 2.25.1