Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
fee14197 | 4 | | CiviCRM version 5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
8c9251b3 | 6 | | Copyright CiviCRM LLC (c) 2004-2018 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | /** | |
29 | * | |
30 | * @package CRM | |
8c9251b3 | 31 | * @copyright CiviCRM LLC (c) 2004-2018 |
6a488035 TO |
32 | */ |
33 | ||
34 | /** | |
35 | * This class generates form components generic to all the contact types. | |
36 | * | |
37 | * It delegates the work to lower level subclasses and integrates the changes | |
38 | * back in. It also uses a lot of functionality with the CRM API's, so any change | |
39 | * made here could potentially affect the API etc. Be careful, be aware, use unit tests. | |
6a488035 TO |
40 | */ |
41 | class CRM_Profile_Form_Search extends CRM_Profile_Form { | |
42 | ||
43 | /** | |
100fef9d | 44 | * Pre processing work done here. |
6a488035 | 45 | */ |
00be9182 | 46 | public function preProcess() { |
6a488035 TO |
47 | $this->_mode = CRM_Profile_Form::MODE_SEARCH; |
48 | parent::preProcess(); | |
49 | } | |
50 | ||
51 | /** | |
fe482240 | 52 | * Set the default form values. |
6a488035 | 53 | * |
a6c01b45 CW |
54 | * @return array |
55 | * the default array reference | |
6a488035 | 56 | */ |
00be9182 | 57 | public function setDefaultValues() { |
6a488035 TO |
58 | $defaults = array(); |
59 | // note we intentionally overwrite value since we use it as defaults | |
60 | // and its all pass by value | |
61 | // we need to figure out the type, so we can either set an array element | |
62 | // or a scalar -- FIX ME sometime please | |
63 | foreach ($_GET as $key => $value) { | |
64 | if (substr($key, 0, 7) == 'custom_' || $key == "preferred_communication_method") { | |
65 | if (strpos($value, CRM_Core_DAO::VALUE_SEPARATOR) !== FALSE) { | |
66 | $v = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value); | |
67 | $value = array(); | |
68 | foreach ($v as $item) { | |
69 | if ($item) { | |
70 | $value[$item] = $item; | |
71 | } | |
72 | } | |
73 | } | |
74 | } | |
75 | elseif ($key == 'group' || $key == 'tag') { | |
76 | $v = explode(',', $value); | |
77 | $value = array(); | |
78 | foreach ($v as $item) { | |
79 | $value[$item] = 1; | |
80 | } | |
81 | } | |
82 | elseif (in_array($key, array( | |
353ffa53 | 83 | 'birth_date', |
28a04ea9 | 84 | 'deceased_date', |
353ffa53 | 85 | ))) { |
6a488035 TO |
86 | list($value) = CRM_Utils_Date::setDateDefaults($value); |
87 | } | |
88 | ||
89 | $defaults[$key] = $value; | |
90 | } | |
91 | return $defaults; | |
92 | } | |
93 | ||
94 | /** | |
fe482240 | 95 | * Build the form object. |
6a488035 TO |
96 | */ |
97 | public function buildQuickForm() { | |
98 | // Is proximity search enabled for this profile? | |
99 | $proxSearch = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', | |
100 | $this->get('gid'), | |
101 | 'is_proximity_search', 'id' | |
102 | ); | |
103 | if ($proxSearch) { | |
104 | CRM_Contact_Form_Task_ProximityCommon::buildQuickForm($this, $proxSearch); | |
105 | } | |
106 | ||
107 | $this->addButtons(array( | |
353ffa53 TO |
108 | array( |
109 | 'type' => 'refresh', | |
110 | 'name' => ts('Search'), | |
111 | 'isDefault' => TRUE, | |
112 | ), | |
113 | )); | |
6a488035 TO |
114 | |
115 | parent::buildQuickForm(); | |
116 | } | |
117 | ||
118 | /** | |
571ef2a5 | 119 | * Post process function. |
6a488035 | 120 | */ |
dc98079b TO |
121 | public function postProcess() { |
122 | } | |
96025800 | 123 | |
6a488035 | 124 | } |