Merge pull request #21943 from mattwire/gccacheignore
[civicrm-core.git] / CRM / Contact / DAO / SavedSearch.php
CommitLineData
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
31c6d00b 9 * (GenCodeChecksum:1b324e028960b1c8fd94ecdc973a6fdc)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the SavedSearch entity.
f41f0342 14 */
e501603b 15class 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
31c6d00b
CW
26 /**
27 * Icon associated with this entity.
28 *
29 * @var string
30 */
31 public static $_icon = 'fa-search-plus';
32
e501603b 33 /**
f41f0342 34 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b 35 *
c3fc2621 36 * @var bool
e501603b 37 */
fa45b5b9 38 public static $_log = FALSE;
c3fc2621 39
e501603b
TO
40 /**
41 * Saved Search ID
42 *
28979d65
CW
43 * @var int|string|null
44 * (SQL type: int unsigned)
45 * Note that values will be retrieved from the database as a string.
e501603b
TO
46 */
47 public $id;
c3fc2621 48
53b13ffe
CW
49 /**
50 * Unique name of saved search
51 *
28979d65
CW
52 * @var string|null
53 * (SQL type: varchar(255))
54 * Note that values will be retrieved from the database as a string.
53b13ffe
CW
55 */
56 public $name;
57
58 /**
59 * Administrative label for search
60 *
28979d65
CW
61 * @var string|null
62 * (SQL type: varchar(255))
63 * Note that values will be retrieved from the database as a string.
53b13ffe
CW
64 */
65 public $label;
66
e501603b
TO
67 /**
68 * Submitted form values for this search
69 *
28979d65
CW
70 * @var string|null
71 * (SQL type: text)
72 * Note that values will be retrieved from the database as a string.
e501603b
TO
73 */
74 public $form_values;
c3fc2621 75
e501603b
TO
76 /**
77 * Foreign key to civicrm_mapping used for saved search-builder searches.
78 *
28979d65
CW
79 * @var int|string|null
80 * (SQL type: int unsigned)
81 * Note that values will be retrieved from the database as a string.
e501603b
TO
82 */
83 public $mapping_id;
c3fc2621 84
e501603b
TO
85 /**
86 * Foreign key to civicrm_option value table used for saved custom searches.
87 *
28979d65
CW
88 * @var int|string|null
89 * (SQL type: int unsigned)
90 * Note that values will be retrieved from the database as a string.
e501603b
TO
91 */
92 public $search_custom_id;
c3fc2621 93
0d7216d3
CW
94 /**
95 * Entity name for API based search
96 *
28979d65
CW
97 * @var string|null
98 * (SQL type: varchar(255))
99 * Note that values will be retrieved from the database as a string.
0d7216d3
CW
100 */
101 public $api_entity;
102
103 /**
104 * Parameters for API based search
105 *
28979d65
CW
106 * @var string|null
107 * (SQL type: text)
108 * Note that values will be retrieved from the database as a string.
0d7216d3
CW
109 */
110 public $api_params;
111
49a1050c 112 /**
113 * FK to contact table.
114 *
28979d65
CW
115 * @var int|string|null
116 * (SQL type: int unsigned)
117 * Note that values will be retrieved from the database as a string.
49a1050c 118 */
119 public $created_id;
120
121 /**
122 * FK to contact table.
123 *
28979d65
CW
124 * @var int|string|null
125 * (SQL type: int unsigned)
126 * Note that values will be retrieved from the database as a string.
49a1050c 127 */
128 public $modified_id;
129
130 /**
131 * Optional date after which the search is not needed
132 *
28979d65
CW
133 * @var string
134 * (SQL type: timestamp)
135 * Note that values will be retrieved from the database as a string.
49a1050c 136 */
137 public $expires_date;
138
e12bf0ac 139 /**
140 * When the search was created.
141 *
28979d65
CW
142 * @var string
143 * (SQL type: timestamp)
144 * Note that values will be retrieved from the database as a string.
e12bf0ac 145 */
146 public $created_date;
147
148 /**
1901dd96 149 * When the search was last modified.
e12bf0ac 150 *
28979d65
CW
151 * @var string
152 * (SQL type: timestamp)
153 * Note that values will be retrieved from the database as a string.
e12bf0ac 154 */
155 public $modified_date;
156
1901dd96 157 /**
28979d65
CW
158 * @var string|null
159 * (SQL type: text)
160 * Note that values will be retrieved from the database as a string.
1901dd96 161 */
162 public $description;
163
e501603b 164 /**
f41f0342 165 * Class constructor.
e501603b 166 */
c3fc2621 167 public function __construct() {
e501603b
TO
168 $this->__table = 'civicrm_saved_search';
169 parent::__construct();
170 }
c3fc2621 171
449c4e6b
CW
172 /**
173 * Returns localized title of this entity.
7b66c3b5
AH
174 *
175 * @param bool $plural
176 * Whether to return the plural version of the title.
449c4e6b 177 */
7b66c3b5
AH
178 public static function getEntityTitle($plural = FALSE) {
179 return $plural ? ts('Saved Searches') : ts('Saved Search');
449c4e6b
CW
180 }
181
e501603b 182 /**
f41f0342 183 * Returns foreign keys and entity references.
e501603b
TO
184 *
185 * @return array
186 * [CRM_Core_Reference_Interface]
187 */
c3fc2621 188 public static function getReferenceColumns() {
346aaaba 189 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 190 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621 191 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'mapping_id', 'civicrm_mapping', 'id');
49a1050c 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');
346aaaba 194 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 195 }
346aaaba 196 return Civi::$statics[__CLASS__]['links'];
e501603b 197 }
c3fc2621 198
e501603b
TO
199 /**
200 * Returns all the column names of this table
201 *
202 * @return array
203 */
c3fc2621 204 public static function &fields() {
346aaaba 205 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
206 Civi::$statics[__CLASS__]['fields'] = [
207 'id' => [
e501603b
TO
208 'name' => 'id',
209 'type' => CRM_Utils_Type::T_INT,
c3fc2621 210 'title' => ts('Saved Search ID'),
215b423e 211 'description' => ts('Saved Search ID'),
c3fc2621 212 'required' => TRUE,
a36434b9 213 'where' => 'civicrm_saved_search.id',
522a26c9 214 'table_name' => 'civicrm_saved_search',
215 'entity' => 'SavedSearch',
216 'bao' => 'CRM_Contact_BAO_SavedSearch',
6a7e5e5d 217 'localizable' => 0,
2cbbebe8
A
218 'html' => [
219 'type' => 'Number',
220 ],
1fe423d6 221 'readonly' => TRUE,
a9d0587b 222 'add' => '1.1',
c3fc2621 223 ],
53b13ffe
CW
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',
5fb0de1f 232 'default' => NULL,
53b13ffe
CW
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',
5fb0de1f 250 'default' => NULL,
53b13ffe
CW
251 'table_name' => 'civicrm_saved_search',
252 'entity' => 'SavedSearch',
253 'bao' => 'CRM_Contact_BAO_SavedSearch',
254 'localizable' => 0,
255 'html' => [
256 'type' => 'Text',
d102f836 257 'label' => ts("Label"),
53b13ffe
CW
258 ],
259 'add' => '5.32',
260 ],
c3fc2621 261 'form_values' => [
e501603b
TO
262 'name' => 'form_values',
263 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 264 'title' => ts('Submitted Form Values'),
215b423e 265 'description' => ts('Submitted form values for this search'),
c3fc2621 266 'import' => TRUE,
e501603b 267 'where' => 'civicrm_saved_search.form_values',
c3fc2621 268 'export' => TRUE,
522a26c9 269 'table_name' => 'civicrm_saved_search',
270 'entity' => 'SavedSearch',
271 'bao' => 'CRM_Contact_BAO_SavedSearch',
6a7e5e5d 272 'localizable' => 0,
2a5c9b4d 273 'serialize' => self::SERIALIZE_PHP,
a9d0587b 274 'add' => '1.1',
c3fc2621
CW
275 ],
276 'mapping_id' => [
e501603b
TO
277 'name' => 'mapping_id',
278 'type' => CRM_Utils_Type::T_INT,
c3fc2621 279 'title' => ts('Mapping ID'),
215b423e 280 'description' => ts('Foreign key to civicrm_mapping used for saved search-builder searches.'),
a36434b9 281 'where' => 'civicrm_saved_search.mapping_id',
522a26c9 282 'table_name' => 'civicrm_saved_search',
283 'entity' => 'SavedSearch',
284 'bao' => 'CRM_Contact_BAO_SavedSearch',
6a7e5e5d 285 'localizable' => 0,
e501603b 286 'FKClassName' => 'CRM_Core_DAO_Mapping',
2cbbebe8
A
287 'html' => [
288 'label' => ts("Mapping"),
289 ],
a9d0587b 290 'add' => '1.5',
c3fc2621
CW
291 ],
292 'search_custom_id' => [
e501603b
TO
293 'name' => 'search_custom_id',
294 'type' => CRM_Utils_Type::T_INT,
c3fc2621 295 'title' => ts('Option Value ID'),
215b423e 296 'description' => ts('Foreign key to civicrm_option value table used for saved custom searches.'),
a36434b9 297 'where' => 'civicrm_saved_search.search_custom_id',
522a26c9 298 'table_name' => 'civicrm_saved_search',
299 'entity' => 'SavedSearch',
300 'bao' => 'CRM_Contact_BAO_SavedSearch',
6a7e5e5d 301 'localizable' => 0,
a9d0587b 302 'add' => '2.0',
c3fc2621 303 ],
0d7216d3
CW
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,
ddc4b6b8
CW
316 'pseudoconstant' => [
317 'callback' => 'CRM_Contact_BAO_SavedSearch::getApiEntityOptions',
318 ],
a9d0587b 319 'add' => '5.24',
0d7216d3
CW
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,
a9d0587b 332 'add' => '5.24',
0d7216d3 333 ],
49a1050c 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 ],
1e0a0433 348 'readonly' => TRUE,
49a1050c 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 ],
a0e733f3 365 'readonly' => TRUE,
49a1050c 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,
e12bf0ac 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,
1e0a0433 393 'readonly' => TRUE,
e12bf0ac 394 'add' => '5.36',
395 ],
396 'modified_date' => [
397 'name' => 'modified_date',
398 'type' => CRM_Utils_Type::T_TIMESTAMP,
399 'title' => ts('Modified Date'),
1901dd96 400 'description' => ts('When the search was last modified.'),
e12bf0ac 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,
a0e733f3 408 'readonly' => TRUE,
49a1050c 409 'add' => '5.36',
410 ],
1901dd96 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 ],
c3fc2621 427 ];
346aaaba 428 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 429 }
346aaaba 430 return Civi::$statics[__CLASS__]['fields'];
e501603b 431 }
c3fc2621 432
e501603b 433 /**
bd8e0b14 434 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
435 *
436 * @return array
bd8e0b14 437 * Array(string $name => string $uniqueName).
e501603b 438 */
c3fc2621 439 public static function &fieldKeys() {
bd8e0b14
TO
440 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
441 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 442 }
bd8e0b14 443 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 444 }
c3fc2621 445
e501603b
TO
446 /**
447 * Returns the names of this table
448 *
449 * @return string
450 */
c3fc2621 451 public static function getTableName() {
e501603b
TO
452 return self::$_tableName;
453 }
c3fc2621 454
e501603b
TO
455 /**
456 * Returns if this table needs to be logged
457 *
c3fc2621 458 * @return bool
e501603b 459 */
c3fc2621 460 public function getLog() {
e501603b
TO
461 return self::$_log;
462 }
c3fc2621 463
e501603b
TO
464 /**
465 * Returns the list of fields that can be imported
466 *
467 * @param bool $prefix
468 *
469 * @return array
470 */
c3fc2621
CW
471 public static function &import($prefix = FALSE) {
472 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'saved_search', $prefix, []);
60808919 473 return $r;
e501603b 474 }
c3fc2621 475
e501603b
TO
476 /**
477 * Returns the list of fields that can be exported
478 *
479 * @param bool $prefix
480 *
481 * @return array
482 */
c3fc2621
CW
483 public static function &export($prefix = FALSE) {
484 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'saved_search', $prefix, []);
60808919 485 return $r;
e501603b 486 }
c3fc2621 487
e7a6b91a
AS
488 /**
489 * Returns the list of indices
c3fc2621
CW
490 *
491 * @param bool $localize
492 *
493 * @return array
e7a6b91a
AS
494 */
495 public static function indices($localize = TRUE) {
53b13ffe
CW
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 ];
e7a6b91a
AS
507 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
508 }
c3fc2621 509
e501603b 510}