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