Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
bc77d7c0 | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 5 | | | |
bc77d7c0 TO |
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 | | |
6a488035 | 9 | +--------------------------------------------------------------------+ |
d25dd0ee | 10 | */ |
6a488035 TO |
11 | |
12 | /** | |
13 | * | |
14 | * @package CRM | |
ca5cec67 | 15 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
6a488035 TO |
16 | */ |
17 | ||
18 | /** | |
19 | * This class generates form components generic to all the contact types. | |
20 | * | |
21 | * It delegates the work to lower level subclasses and integrates the changes | |
22 | * back in. It also uses a lot of functionality with the CRM API's, so any change | |
23 | * made here could potentially affect the API etc. Be careful, be aware, use unit tests. | |
6a488035 TO |
24 | */ |
25 | class CRM_Profile_Form_Search extends CRM_Profile_Form { | |
26 | ||
27 | /** | |
100fef9d | 28 | * Pre processing work done here. |
6a488035 | 29 | */ |
00be9182 | 30 | public function preProcess() { |
6a488035 TO |
31 | $this->_mode = CRM_Profile_Form::MODE_SEARCH; |
32 | parent::preProcess(); | |
33 | } | |
34 | ||
35 | /** | |
fe482240 | 36 | * Set the default form values. |
6a488035 | 37 | * |
a6c01b45 CW |
38 | * @return array |
39 | * the default array reference | |
6a488035 | 40 | */ |
00be9182 | 41 | public function setDefaultValues() { |
be2fb01f | 42 | $defaults = []; |
6a488035 TO |
43 | // note we intentionally overwrite value since we use it as defaults |
44 | // and its all pass by value | |
45 | // we need to figure out the type, so we can either set an array element | |
46 | // or a scalar -- FIX ME sometime please | |
47 | foreach ($_GET as $key => $value) { | |
48 | if (substr($key, 0, 7) == 'custom_' || $key == "preferred_communication_method") { | |
49 | if (strpos($value, CRM_Core_DAO::VALUE_SEPARATOR) !== FALSE) { | |
50 | $v = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value); | |
be2fb01f | 51 | $value = []; |
6a488035 TO |
52 | foreach ($v as $item) { |
53 | if ($item) { | |
54 | $value[$item] = $item; | |
55 | } | |
56 | } | |
57 | } | |
58 | } | |
59 | elseif ($key == 'group' || $key == 'tag') { | |
60 | $v = explode(',', $value); | |
be2fb01f | 61 | $value = []; |
6a488035 TO |
62 | foreach ($v as $item) { |
63 | $value[$item] = 1; | |
64 | } | |
65 | } | |
be2fb01f | 66 | elseif (in_array($key, [ |
353ffa53 | 67 | 'birth_date', |
28a04ea9 | 68 | 'deceased_date', |
be2fb01f | 69 | ])) { |
6a488035 TO |
70 | list($value) = CRM_Utils_Date::setDateDefaults($value); |
71 | } | |
72 | ||
73 | $defaults[$key] = $value; | |
74 | } | |
75 | return $defaults; | |
76 | } | |
77 | ||
78 | /** | |
fe482240 | 79 | * Build the form object. |
6a488035 TO |
80 | */ |
81 | public function buildQuickForm() { | |
82 | // Is proximity search enabled for this profile? | |
83 | $proxSearch = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', | |
84 | $this->get('gid'), | |
85 | 'is_proximity_search', 'id' | |
86 | ); | |
87 | if ($proxSearch) { | |
88 | CRM_Contact_Form_Task_ProximityCommon::buildQuickForm($this, $proxSearch); | |
89 | } | |
90 | ||
be2fb01f CW |
91 | $this->addButtons([ |
92 | [ | |
353ffa53 TO |
93 | 'type' => 'refresh', |
94 | 'name' => ts('Search'), | |
95 | 'isDefault' => TRUE, | |
be2fb01f CW |
96 | ], |
97 | ]); | |
6a488035 TO |
98 | |
99 | parent::buildQuickForm(); | |
100 | } | |
101 | ||
102 | /** | |
571ef2a5 | 103 | * Post process function. |
6a488035 | 104 | */ |
dc98079b TO |
105 | public function postProcess() { |
106 | } | |
96025800 | 107 | |
6a488035 | 108 | } |