Commit | Line | Data |
---|---|---|
e501603b | 1 | <?php |
c3fc2621 | 2 | |
e501603b TO |
3 | /** |
4 | * @package CRM | |
ca5cec67 | 5 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
e501603b TO |
6 | * |
7 | * Generated from xml/schema/CRM/Contact/SavedSearch.xml | |
8 | * DO NOT EDIT. Generated by CRM_Core_CodeGen | |
1e0a0433 | 9 | * (GenCodeChecksum:8a25df5165c48a42f0280efe9eb262d5) |
e501603b | 10 | */ |
c3fc2621 | 11 | |
f41f0342 | 12 | /** |
c3fc2621 | 13 | * Database access object for the SavedSearch entity. |
f41f0342 | 14 | */ |
e501603b | 15 | class CRM_Contact_DAO_SavedSearch extends CRM_Core_DAO { |
929a1c14 CW |
16 | const EXT = 'civicrm'; |
17 | const TABLE_ADDED = '1.1'; | |
c3fc2621 | 18 | |
e501603b | 19 | /** |
f41f0342 | 20 | * Static instance to hold the table name. |
e501603b TO |
21 | * |
22 | * @var string | |
23 | */ | |
fa45b5b9 | 24 | public static $_tableName = 'civicrm_saved_search'; |
c3fc2621 | 25 | |
e501603b | 26 | /** |
f41f0342 | 27 | * Should CiviCRM log any modifications to this table in the civicrm_log table. |
e501603b | 28 | * |
c3fc2621 | 29 | * @var bool |
e501603b | 30 | */ |
fa45b5b9 | 31 | public static $_log = FALSE; |
c3fc2621 | 32 | |
e501603b TO |
33 | /** |
34 | * Saved Search ID | |
35 | * | |
e6ca0a57 | 36 | * @var int |
e501603b TO |
37 | */ |
38 | public $id; | |
c3fc2621 | 39 | |
53b13ffe CW |
40 | /** |
41 | * Unique name of saved search | |
42 | * | |
43 | * @var string | |
44 | */ | |
45 | public $name; | |
46 | ||
47 | /** | |
48 | * Administrative label for search | |
49 | * | |
50 | * @var string | |
51 | */ | |
52 | public $label; | |
53 | ||
e501603b TO |
54 | /** |
55 | * Submitted form values for this search | |
56 | * | |
57 | * @var text | |
58 | */ | |
59 | public $form_values; | |
c3fc2621 | 60 | |
e501603b TO |
61 | /** |
62 | * Foreign key to civicrm_mapping used for saved search-builder searches. | |
63 | * | |
e6ca0a57 | 64 | * @var int |
e501603b TO |
65 | */ |
66 | public $mapping_id; | |
c3fc2621 | 67 | |
e501603b TO |
68 | /** |
69 | * Foreign key to civicrm_option value table used for saved custom searches. | |
70 | * | |
e6ca0a57 | 71 | * @var int |
e501603b TO |
72 | */ |
73 | public $search_custom_id; | |
c3fc2621 | 74 | |
0d7216d3 CW |
75 | /** |
76 | * Entity name for API based search | |
77 | * | |
78 | * @var string | |
79 | */ | |
80 | public $api_entity; | |
81 | ||
82 | /** | |
83 | * Parameters for API based search | |
84 | * | |
85 | * @var text | |
86 | */ | |
87 | public $api_params; | |
88 | ||
49a1050c | 89 | /** |
90 | * FK to contact table. | |
91 | * | |
92 | * @var int | |
93 | */ | |
94 | public $created_id; | |
95 | ||
96 | /** | |
97 | * FK to contact table. | |
98 | * | |
99 | * @var int | |
100 | */ | |
101 | public $modified_id; | |
102 | ||
103 | /** | |
104 | * Optional date after which the search is not needed | |
105 | * | |
106 | * @var timestamp | |
107 | */ | |
108 | public $expires_date; | |
109 | ||
e12bf0ac | 110 | /** |
111 | * When the search was created. | |
112 | * | |
113 | * @var timestamp | |
114 | */ | |
115 | public $created_date; | |
116 | ||
117 | /** | |
1901dd96 | 118 | * When the search was last modified. |
e12bf0ac | 119 | * |
120 | * @var timestamp | |
121 | */ | |
122 | public $modified_date; | |
123 | ||
1901dd96 | 124 | /** |
125 | * @var text | |
126 | */ | |
127 | public $description; | |
128 | ||
e501603b | 129 | /** |
f41f0342 | 130 | * Class constructor. |
e501603b | 131 | */ |
c3fc2621 | 132 | public function __construct() { |
e501603b TO |
133 | $this->__table = 'civicrm_saved_search'; |
134 | parent::__construct(); | |
135 | } | |
c3fc2621 | 136 | |
449c4e6b CW |
137 | /** |
138 | * Returns localized title of this entity. | |
7b66c3b5 AH |
139 | * |
140 | * @param bool $plural | |
141 | * Whether to return the plural version of the title. | |
449c4e6b | 142 | */ |
7b66c3b5 AH |
143 | public static function getEntityTitle($plural = FALSE) { |
144 | return $plural ? ts('Saved Searches') : ts('Saved Search'); | |
449c4e6b CW |
145 | } |
146 | ||
e501603b | 147 | /** |
f41f0342 | 148 | * Returns foreign keys and entity references. |
e501603b TO |
149 | * |
150 | * @return array | |
151 | * [CRM_Core_Reference_Interface] | |
152 | */ | |
c3fc2621 | 153 | public static function getReferenceColumns() { |
346aaaba | 154 | if (!isset(Civi::$statics[__CLASS__]['links'])) { |
fa45b5b9 | 155 | Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); |
c3fc2621 | 156 | Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'mapping_id', 'civicrm_mapping', 'id'); |
49a1050c | 157 | Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id'); |
158 | Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'modified_id', 'civicrm_contact', 'id'); | |
346aaaba | 159 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); |
e501603b | 160 | } |
346aaaba | 161 | return Civi::$statics[__CLASS__]['links']; |
e501603b | 162 | } |
c3fc2621 | 163 | |
e501603b TO |
164 | /** |
165 | * Returns all the column names of this table | |
166 | * | |
167 | * @return array | |
168 | */ | |
c3fc2621 | 169 | public static function &fields() { |
346aaaba | 170 | if (!isset(Civi::$statics[__CLASS__]['fields'])) { |
c3fc2621 CW |
171 | Civi::$statics[__CLASS__]['fields'] = [ |
172 | 'id' => [ | |
e501603b TO |
173 | 'name' => 'id', |
174 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 175 | 'title' => ts('Saved Search ID'), |
215b423e | 176 | 'description' => ts('Saved Search ID'), |
c3fc2621 | 177 | 'required' => TRUE, |
a36434b9 | 178 | 'where' => 'civicrm_saved_search.id', |
522a26c9 | 179 | 'table_name' => 'civicrm_saved_search', |
180 | 'entity' => 'SavedSearch', | |
181 | 'bao' => 'CRM_Contact_BAO_SavedSearch', | |
6a7e5e5d | 182 | 'localizable' => 0, |
2cbbebe8 A |
183 | 'html' => [ |
184 | 'type' => 'Number', | |
185 | ], | |
1fe423d6 | 186 | 'readonly' => TRUE, |
a9d0587b | 187 | 'add' => '1.1', |
c3fc2621 | 188 | ], |
53b13ffe CW |
189 | 'name' => [ |
190 | 'name' => 'name', | |
191 | 'type' => CRM_Utils_Type::T_STRING, | |
192 | 'title' => ts('Saved Search Name'), | |
193 | 'description' => ts('Unique name of saved search'), | |
194 | 'maxlength' => 255, | |
195 | 'size' => CRM_Utils_Type::HUGE, | |
196 | 'where' => 'civicrm_saved_search.name', | |
197 | 'default' => 'NULL', | |
198 | 'table_name' => 'civicrm_saved_search', | |
199 | 'entity' => 'SavedSearch', | |
200 | 'bao' => 'CRM_Contact_BAO_SavedSearch', | |
201 | 'localizable' => 0, | |
202 | 'html' => [ | |
203 | 'type' => 'Text', | |
204 | ], | |
205 | 'add' => '1.0', | |
206 | ], | |
207 | 'label' => [ | |
208 | 'name' => 'label', | |
209 | 'type' => CRM_Utils_Type::T_STRING, | |
210 | 'title' => ts('Saved Search Label'), | |
211 | 'description' => ts('Administrative label for search'), | |
212 | 'maxlength' => 255, | |
213 | 'size' => CRM_Utils_Type::HUGE, | |
214 | 'where' => 'civicrm_saved_search.label', | |
215 | 'default' => 'NULL', | |
216 | 'table_name' => 'civicrm_saved_search', | |
217 | 'entity' => 'SavedSearch', | |
218 | 'bao' => 'CRM_Contact_BAO_SavedSearch', | |
219 | 'localizable' => 0, | |
220 | 'html' => [ | |
221 | 'type' => 'Text', | |
222 | ], | |
223 | 'add' => '5.32', | |
224 | ], | |
c3fc2621 | 225 | 'form_values' => [ |
e501603b TO |
226 | 'name' => 'form_values', |
227 | 'type' => CRM_Utils_Type::T_TEXT, | |
c3fc2621 | 228 | 'title' => ts('Submitted Form Values'), |
215b423e | 229 | 'description' => ts('Submitted form values for this search'), |
c3fc2621 | 230 | 'import' => TRUE, |
e501603b | 231 | 'where' => 'civicrm_saved_search.form_values', |
c3fc2621 | 232 | 'export' => TRUE, |
522a26c9 | 233 | 'table_name' => 'civicrm_saved_search', |
234 | 'entity' => 'SavedSearch', | |
235 | 'bao' => 'CRM_Contact_BAO_SavedSearch', | |
6a7e5e5d | 236 | 'localizable' => 0, |
2a5c9b4d | 237 | 'serialize' => self::SERIALIZE_PHP, |
a9d0587b | 238 | 'add' => '1.1', |
c3fc2621 CW |
239 | ], |
240 | 'mapping_id' => [ | |
e501603b TO |
241 | 'name' => 'mapping_id', |
242 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 243 | 'title' => ts('Mapping ID'), |
215b423e | 244 | 'description' => ts('Foreign key to civicrm_mapping used for saved search-builder searches.'), |
a36434b9 | 245 | 'where' => 'civicrm_saved_search.mapping_id', |
522a26c9 | 246 | 'table_name' => 'civicrm_saved_search', |
247 | 'entity' => 'SavedSearch', | |
248 | 'bao' => 'CRM_Contact_BAO_SavedSearch', | |
6a7e5e5d | 249 | 'localizable' => 0, |
e501603b | 250 | 'FKClassName' => 'CRM_Core_DAO_Mapping', |
2cbbebe8 A |
251 | 'html' => [ |
252 | 'label' => ts("Mapping"), | |
253 | ], | |
a9d0587b | 254 | 'add' => '1.5', |
c3fc2621 CW |
255 | ], |
256 | 'search_custom_id' => [ | |
e501603b TO |
257 | 'name' => 'search_custom_id', |
258 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 259 | 'title' => ts('Option Value ID'), |
215b423e | 260 | 'description' => ts('Foreign key to civicrm_option value table used for saved custom searches.'), |
a36434b9 | 261 | 'where' => 'civicrm_saved_search.search_custom_id', |
522a26c9 | 262 | 'table_name' => 'civicrm_saved_search', |
263 | 'entity' => 'SavedSearch', | |
264 | 'bao' => 'CRM_Contact_BAO_SavedSearch', | |
6a7e5e5d | 265 | 'localizable' => 0, |
a9d0587b | 266 | 'add' => '2.0', |
c3fc2621 | 267 | ], |
0d7216d3 CW |
268 | 'api_entity' => [ |
269 | 'name' => 'api_entity', | |
270 | 'type' => CRM_Utils_Type::T_STRING, | |
271 | 'title' => ts('Entity Name'), | |
272 | 'description' => ts('Entity name for API based search'), | |
273 | 'maxlength' => 255, | |
274 | 'size' => CRM_Utils_Type::HUGE, | |
275 | 'where' => 'civicrm_saved_search.api_entity', | |
276 | 'table_name' => 'civicrm_saved_search', | |
277 | 'entity' => 'SavedSearch', | |
278 | 'bao' => 'CRM_Contact_BAO_SavedSearch', | |
279 | 'localizable' => 0, | |
a9d0587b | 280 | 'add' => '5.24', |
0d7216d3 CW |
281 | ], |
282 | 'api_params' => [ | |
283 | 'name' => 'api_params', | |
284 | 'type' => CRM_Utils_Type::T_TEXT, | |
285 | 'title' => ts('API Parameters'), | |
286 | 'description' => ts('Parameters for API based search'), | |
287 | 'where' => 'civicrm_saved_search.api_params', | |
288 | 'table_name' => 'civicrm_saved_search', | |
289 | 'entity' => 'SavedSearch', | |
290 | 'bao' => 'CRM_Contact_BAO_SavedSearch', | |
291 | 'localizable' => 0, | |
292 | 'serialize' => self::SERIALIZE_JSON, | |
a9d0587b | 293 | 'add' => '5.24', |
0d7216d3 | 294 | ], |
49a1050c | 295 | 'created_id' => [ |
296 | 'name' => 'created_id', | |
297 | 'type' => CRM_Utils_Type::T_INT, | |
298 | 'title' => ts('Created By Contact ID'), | |
299 | 'description' => ts('FK to contact table.'), | |
300 | 'where' => 'civicrm_saved_search.created_id', | |
301 | 'table_name' => 'civicrm_saved_search', | |
302 | 'entity' => 'SavedSearch', | |
303 | 'bao' => 'CRM_Contact_BAO_SavedSearch', | |
304 | 'localizable' => 0, | |
305 | 'FKClassName' => 'CRM_Contact_DAO_Contact', | |
306 | 'html' => [ | |
307 | 'label' => ts("Created By"), | |
308 | ], | |
1e0a0433 | 309 | 'readonly' => TRUE, |
49a1050c | 310 | 'add' => '5.36', |
311 | ], | |
312 | 'modified_id' => [ | |
313 | 'name' => 'modified_id', | |
314 | 'type' => CRM_Utils_Type::T_INT, | |
315 | 'title' => ts('Modified By Contact ID'), | |
316 | 'description' => ts('FK to contact table.'), | |
317 | 'where' => 'civicrm_saved_search.modified_id', | |
318 | 'table_name' => 'civicrm_saved_search', | |
319 | 'entity' => 'SavedSearch', | |
320 | 'bao' => 'CRM_Contact_BAO_SavedSearch', | |
321 | 'localizable' => 0, | |
322 | 'FKClassName' => 'CRM_Contact_DAO_Contact', | |
323 | 'html' => [ | |
324 | 'label' => ts("Modified By"), | |
325 | ], | |
a0e733f3 | 326 | 'readonly' => TRUE, |
49a1050c | 327 | 'add' => '5.36', |
328 | ], | |
329 | 'expires_date' => [ | |
330 | 'name' => 'expires_date', | |
331 | 'type' => CRM_Utils_Type::T_TIMESTAMP, | |
332 | 'title' => ts('Search Expiry Date'), | |
333 | 'description' => ts('Optional date after which the search is not needed'), | |
334 | 'required' => FALSE, | |
335 | 'where' => 'civicrm_saved_search.expires_date', | |
336 | 'table_name' => 'civicrm_saved_search', | |
337 | 'entity' => 'SavedSearch', | |
338 | 'bao' => 'CRM_Contact_BAO_SavedSearch', | |
339 | 'localizable' => 0, | |
e12bf0ac | 340 | 'add' => '5.36', |
341 | ], | |
342 | 'created_date' => [ | |
343 | 'name' => 'created_date', | |
344 | 'type' => CRM_Utils_Type::T_TIMESTAMP, | |
345 | 'title' => ts('Created Date'), | |
346 | 'description' => ts('When the search was created.'), | |
347 | 'required' => TRUE, | |
348 | 'where' => 'civicrm_saved_search.created_date', | |
349 | 'default' => 'CURRENT_TIMESTAMP', | |
350 | 'table_name' => 'civicrm_saved_search', | |
351 | 'entity' => 'SavedSearch', | |
352 | 'bao' => 'CRM_Contact_BAO_SavedSearch', | |
353 | 'localizable' => 0, | |
1e0a0433 | 354 | 'readonly' => TRUE, |
e12bf0ac | 355 | 'add' => '5.36', |
356 | ], | |
357 | 'modified_date' => [ | |
358 | 'name' => 'modified_date', | |
359 | 'type' => CRM_Utils_Type::T_TIMESTAMP, | |
360 | 'title' => ts('Modified Date'), | |
1901dd96 | 361 | 'description' => ts('When the search was last modified.'), |
e12bf0ac | 362 | 'required' => TRUE, |
363 | 'where' => 'civicrm_saved_search.modified_date', | |
364 | 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', | |
365 | 'table_name' => 'civicrm_saved_search', | |
366 | 'entity' => 'SavedSearch', | |
367 | 'bao' => 'CRM_Contact_BAO_SavedSearch', | |
368 | 'localizable' => 0, | |
a0e733f3 | 369 | 'readonly' => TRUE, |
49a1050c | 370 | 'add' => '5.36', |
371 | ], | |
1901dd96 | 372 | 'description' => [ |
373 | 'name' => 'description', | |
374 | 'type' => CRM_Utils_Type::T_TEXT, | |
375 | 'title' => ts('Saved Search Description'), | |
376 | 'rows' => 2, | |
377 | 'cols' => 60, | |
378 | 'where' => 'civicrm_saved_search.description', | |
379 | 'table_name' => 'civicrm_saved_search', | |
380 | 'entity' => 'SavedSearch', | |
381 | 'bao' => 'CRM_Contact_BAO_SavedSearch', | |
382 | 'localizable' => 0, | |
383 | 'html' => [ | |
384 | 'type' => 'TextArea', | |
385 | ], | |
386 | 'add' => '5.36', | |
387 | ], | |
c3fc2621 | 388 | ]; |
346aaaba | 389 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); |
e501603b | 390 | } |
346aaaba | 391 | return Civi::$statics[__CLASS__]['fields']; |
e501603b | 392 | } |
c3fc2621 | 393 | |
e501603b | 394 | /** |
bd8e0b14 | 395 | * Return a mapping from field-name to the corresponding key (as used in fields()). |
e501603b TO |
396 | * |
397 | * @return array | |
bd8e0b14 | 398 | * Array(string $name => string $uniqueName). |
e501603b | 399 | */ |
c3fc2621 | 400 | public static function &fieldKeys() { |
bd8e0b14 TO |
401 | if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { |
402 | Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); | |
e501603b | 403 | } |
bd8e0b14 | 404 | return Civi::$statics[__CLASS__]['fieldKeys']; |
e501603b | 405 | } |
c3fc2621 | 406 | |
e501603b TO |
407 | /** |
408 | * Returns the names of this table | |
409 | * | |
410 | * @return string | |
411 | */ | |
c3fc2621 | 412 | public static function getTableName() { |
e501603b TO |
413 | return self::$_tableName; |
414 | } | |
c3fc2621 | 415 | |
e501603b TO |
416 | /** |
417 | * Returns if this table needs to be logged | |
418 | * | |
c3fc2621 | 419 | * @return bool |
e501603b | 420 | */ |
c3fc2621 | 421 | public function getLog() { |
e501603b TO |
422 | return self::$_log; |
423 | } | |
c3fc2621 | 424 | |
e501603b TO |
425 | /** |
426 | * Returns the list of fields that can be imported | |
427 | * | |
428 | * @param bool $prefix | |
429 | * | |
430 | * @return array | |
431 | */ | |
c3fc2621 CW |
432 | public static function &import($prefix = FALSE) { |
433 | $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'saved_search', $prefix, []); | |
60808919 | 434 | return $r; |
e501603b | 435 | } |
c3fc2621 | 436 | |
e501603b TO |
437 | /** |
438 | * Returns the list of fields that can be exported | |
439 | * | |
440 | * @param bool $prefix | |
441 | * | |
442 | * @return array | |
443 | */ | |
c3fc2621 CW |
444 | public static function &export($prefix = FALSE) { |
445 | $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'saved_search', $prefix, []); | |
60808919 | 446 | return $r; |
e501603b | 447 | } |
c3fc2621 | 448 | |
e7a6b91a AS |
449 | /** |
450 | * Returns the list of indices | |
c3fc2621 CW |
451 | * |
452 | * @param bool $localize | |
453 | * | |
454 | * @return array | |
e7a6b91a AS |
455 | */ |
456 | public static function indices($localize = TRUE) { | |
53b13ffe CW |
457 | $indices = [ |
458 | 'UI_name' => [ | |
459 | 'name' => 'UI_name', | |
460 | 'field' => [ | |
461 | 0 => 'name', | |
462 | ], | |
463 | 'localizable' => FALSE, | |
464 | 'unique' => TRUE, | |
465 | 'sig' => 'civicrm_saved_search::1::name', | |
466 | ], | |
467 | ]; | |
e7a6b91a AS |
468 | return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; |
469 | } | |
c3fc2621 | 470 | |
e501603b | 471 | } |