Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06b69b18 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
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 | +--------------------------------------------------------------------+ | |
26 | */ | |
27 | ||
28 | /** | |
29 | * | |
30 | * @package CRM | |
06b69b18 | 31 | * @copyright CiviCRM LLC (c) 2004-2014 |
6a488035 TO |
32 | * $Id$ |
33 | * | |
34 | */ | |
35 | ||
36 | /** | |
37 | * This class generates form components generic to all the contact types. | |
38 | * | |
39 | * It delegates the work to lower level subclasses and integrates the changes | |
40 | * back in. It also uses a lot of functionality with the CRM API's, so any change | |
41 | * made here could potentially affect the API etc. Be careful, be aware, use unit tests. | |
42 | * | |
43 | */ | |
44 | class CRM_Profile_Form_Search extends CRM_Profile_Form { | |
45 | ||
46 | /** | |
100fef9d | 47 | * Pre processing work done here. |
6a488035 TO |
48 | * |
49 | * @param | |
50 | * | |
51 | * @return void | |
6a488035 | 52 | */ |
00be9182 | 53 | public function preProcess() { |
6a488035 TO |
54 | $this->_mode = CRM_Profile_Form::MODE_SEARCH; |
55 | parent::preProcess(); | |
56 | } | |
57 | ||
58 | /** | |
59 | * Set the default form values | |
60 | * | |
6a488035 | 61 | * |
a6c01b45 CW |
62 | * @return array |
63 | * the default array reference | |
6a488035 | 64 | */ |
00be9182 | 65 | public function setDefaultValues() { |
6a488035 TO |
66 | $defaults = array(); |
67 | // note we intentionally overwrite value since we use it as defaults | |
68 | // and its all pass by value | |
69 | // we need to figure out the type, so we can either set an array element | |
70 | // or a scalar -- FIX ME sometime please | |
71 | foreach ($_GET as $key => $value) { | |
72 | if (substr($key, 0, 7) == 'custom_' || $key == "preferred_communication_method") { | |
73 | if (strpos($value, CRM_Core_DAO::VALUE_SEPARATOR) !== FALSE) { | |
74 | $v = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value); | |
75 | $value = array(); | |
76 | foreach ($v as $item) { | |
77 | if ($item) { | |
78 | $value[$item] = $item; | |
79 | } | |
80 | } | |
81 | } | |
82 | } | |
83 | elseif ($key == 'group' || $key == 'tag') { | |
84 | $v = explode(',', $value); | |
85 | $value = array(); | |
86 | foreach ($v as $item) { | |
87 | $value[$item] = 1; | |
88 | } | |
89 | } | |
90 | elseif (in_array($key, array( | |
353ffa53 TO |
91 | 'birth_date', |
92 | 'deceased_date' | |
93 | ))) { | |
6a488035 TO |
94 | list($value) = CRM_Utils_Date::setDateDefaults($value); |
95 | } | |
96 | ||
97 | $defaults[$key] = $value; | |
98 | } | |
99 | return $defaults; | |
100 | } | |
101 | ||
102 | /** | |
c490a46a | 103 | * Build the form object |
6a488035 TO |
104 | * |
105 | * @return void | |
6a488035 TO |
106 | */ |
107 | public function buildQuickForm() { | |
108 | // Is proximity search enabled for this profile? | |
109 | $proxSearch = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', | |
110 | $this->get('gid'), | |
111 | 'is_proximity_search', 'id' | |
112 | ); | |
113 | if ($proxSearch) { | |
114 | CRM_Contact_Form_Task_ProximityCommon::buildQuickForm($this, $proxSearch); | |
115 | } | |
116 | ||
117 | $this->addButtons(array( | |
353ffa53 TO |
118 | array( |
119 | 'type' => 'refresh', | |
120 | 'name' => ts('Search'), | |
121 | 'isDefault' => TRUE, | |
122 | ), | |
123 | )); | |
6a488035 TO |
124 | |
125 | parent::buildQuickForm(); | |
126 | } | |
127 | ||
128 | /** | |
129 | * | |
130 | * | |
6a488035 TO |
131 | * |
132 | * @return void | |
133 | */ | |
dc98079b TO |
134 | public function postProcess() { |
135 | } | |
6a488035 | 136 | } |