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