Commit | Line | Data |
---|---|---|
86a0d21e CW |
1 | <?php |
2 | /* | |
bc77d7c0 TO |
3 | +--------------------------------------------------------------------+ |
4 | | Copyright CiviCRM LLC. All rights reserved. | | |
5 | | | | |
6 | | This work is published under the GNU AGPLv3 license with some | | |
7 | | permitted exceptions and without any warranty. For full license | | |
8 | | and copyright information, see https://civicrm.org/licensing | | |
9 | +--------------------------------------------------------------------+ | |
86a0d21e CW |
10 | */ |
11 | ||
12 | /** | |
13 | * | |
14 | * @package CRM | |
ca5cec67 | 15 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
86a0d21e CW |
16 | */ |
17 | class CRM_Core_BAO_Query { | |
18 | ||
19 | /** | |
20 | * @param CRM_Core_Form $form | |
21 | * @param array $extends | |
22 | */ | |
23 | public static function addCustomFormFields(&$form, $extends) { | |
24 | $groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $extends); | |
25 | if ($groupDetails) { | |
26 | $tplName = lcfirst($extends[0]) . 'GroupTree'; | |
27 | $form->assign($tplName, $groupDetails); | |
28 | foreach ($groupDetails as $group) { | |
29 | foreach ($group['fields'] as $field) { | |
30 | $fieldId = $field['id']; | |
31 | $elementName = 'custom_' . $fieldId; | |
e2ce074e | 32 | if ($field['data_type'] === 'Date' && $field['is_search_range']) { |
33 | $form->addDatePickerRange($elementName, $field['label']); | |
86a0d21e CW |
34 | } |
35 | else { | |
36 | CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, FALSE, TRUE); | |
37 | } | |
38 | } | |
39 | } | |
40 | } | |
41 | } | |
42 | ||
e1bbe1bf | 43 | /** |
44 | * Get legacy fields which we still maybe support. | |
45 | * | |
46 | * These are contribution specific but I think it's ok to have one list of legacy supported | |
47 | * params in a central place. | |
48 | * | |
49 | * @return array | |
50 | */ | |
51 | protected static function getLegacySupportedFields(): array { | |
52 | // @todo enotices when these are hit so we can start to elimnate them. | |
53 | $fieldAliases = [ | |
54 | 'financial_type' => 'financial_type_id', | |
55 | 'contribution_page' => 'contribution_page_id', | |
56 | 'payment_instrument' => 'payment_instrument_id', | |
57 | // or payment_instrument_id? | |
58 | 'contribution_payment_instrument' => 'contribution_payment_instrument_id', | |
59 | 'contribution_status' => 'contribution_status_id', | |
60 | ]; | |
61 | return $fieldAliases; | |
62 | } | |
63 | ||
e883a7c2 J |
64 | /** |
65 | * Getter for the qill object. | |
66 | * | |
67 | * @return string | |
68 | */ | |
69 | public function qill() { | |
70 | return (isset($this->_qill)) ? $this->_qill : ""; | |
71 | } | |
72 | ||
86a0d21e CW |
73 | /** |
74 | * Possibly unnecessary function. | |
75 | * | |
76 | * @param $row | |
77 | * @param int $id | |
78 | */ | |
79 | public static function searchAction(&$row, $id) {} | |
80 | ||
81 | /** | |
82 | * @param $tables | |
83 | */ | |
84 | public static function tableNames(&$tables) {} | |
85 | ||
e1bbe1bf | 86 | /** |
87 | * Get the name of the field. | |
88 | * | |
89 | * @param array $values | |
90 | * | |
91 | * @return string | |
92 | */ | |
93 | protected static function getFieldName($values) { | |
94 | $name = $values[0]; | |
95 | $fieldAliases = self::getLegacySupportedFields(); | |
96 | if (isset($fieldAliases[$name])) { | |
97 | CRM_Core_Error::deprecatedFunctionWarning('These parameters should be standardised before we get here'); | |
98 | return $fieldAliases[$name]; | |
99 | } | |
100 | ||
101 | return str_replace(['_high', '_low'], '', $name); | |
102 | } | |
103 | ||
86a0d21e | 104 | } |