curious
[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:bca384578ea59c0cf4f0a80617c788fe)
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
37 */
38 public $id;
39
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
54 /**
55 * Submitted form values for this search
56 *
57 * @var text
58 */
59 public $form_values;
60
61 /**
62 * Foreign key to civicrm_mapping used for saved search-builder searches.
63 *
64 * @var int
65 */
66 public $mapping_id;
67
68 /**
69 * Foreign key to civicrm_option value table used for saved custom searches.
70 *
71 * @var int
72 */
73 public $search_custom_id;
74
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
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
110 /**
111 * When the search was created.
112 *
113 * @var timestamp
114 */
115 public $created_date;
116
117 /**
118 * When the search was last modified.
119 *
120 * @var timestamp
121 */
122 public $modified_date;
123
124 /**
125 * @var text
126 */
127 public $description;
128
129 /**
130 * Class constructor.
131 */
132 public function __construct() {
133 $this->__table = 'civicrm_saved_search';
134 parent::__construct();
135 }
136
137 /**
138 * Returns localized title of this entity.
139 *
140 * @param bool $plural
141 * Whether to return the plural version of the title.
142 */
143 public static function getEntityTitle($plural = FALSE) {
144 return $plural ? ts('Saved Searches') : ts('Saved Search');
145 }
146
147 /**
148 * Returns foreign keys and entity references.
149 *
150 * @return array
151 * [CRM_Core_Reference_Interface]
152 */
153 public static function getReferenceColumns() {
154 if (!isset(Civi::$statics[__CLASS__]['links'])) {
155 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
156 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'mapping_id', 'civicrm_mapping', 'id');
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');
159 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
160 }
161 return Civi::$statics[__CLASS__]['links'];
162 }
163
164 /**
165 * Returns all the column names of this table
166 *
167 * @return array
168 */
169 public static function &fields() {
170 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
171 Civi::$statics[__CLASS__]['fields'] = [
172 'id' => [
173 'name' => 'id',
174 'type' => CRM_Utils_Type::T_INT,
175 'title' => ts('Saved Search ID'),
176 'description' => ts('Saved Search ID'),
177 'required' => TRUE,
178 'where' => 'civicrm_saved_search.id',
179 'table_name' => 'civicrm_saved_search',
180 'entity' => 'SavedSearch',
181 'bao' => 'CRM_Contact_BAO_SavedSearch',
182 'localizable' => 0,
183 'html' => [
184 'type' => 'Number',
185 ],
186 'readonly' => TRUE,
187 'add' => '1.1',
188 ],
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 'label' => ts("Label"),
223 ],
224 'add' => '5.32',
225 ],
226 'form_values' => [
227 'name' => 'form_values',
228 'type' => CRM_Utils_Type::T_TEXT,
229 'title' => ts('Submitted Form Values'),
230 'description' => ts('Submitted form values for this search'),
231 'import' => TRUE,
232 'where' => 'civicrm_saved_search.form_values',
233 'export' => TRUE,
234 'table_name' => 'civicrm_saved_search',
235 'entity' => 'SavedSearch',
236 'bao' => 'CRM_Contact_BAO_SavedSearch',
237 'localizable' => 0,
238 'serialize' => self::SERIALIZE_PHP,
239 'add' => '1.1',
240 ],
241 'mapping_id' => [
242 'name' => 'mapping_id',
243 'type' => CRM_Utils_Type::T_INT,
244 'title' => ts('Mapping ID'),
245 'description' => ts('Foreign key to civicrm_mapping used for saved search-builder searches.'),
246 'where' => 'civicrm_saved_search.mapping_id',
247 'table_name' => 'civicrm_saved_search',
248 'entity' => 'SavedSearch',
249 'bao' => 'CRM_Contact_BAO_SavedSearch',
250 'localizable' => 0,
251 'FKClassName' => 'CRM_Core_DAO_Mapping',
252 'html' => [
253 'label' => ts("Mapping"),
254 ],
255 'add' => '1.5',
256 ],
257 'search_custom_id' => [
258 'name' => 'search_custom_id',
259 'type' => CRM_Utils_Type::T_INT,
260 'title' => ts('Option Value ID'),
261 'description' => ts('Foreign key to civicrm_option value table used for saved custom searches.'),
262 'where' => 'civicrm_saved_search.search_custom_id',
263 'table_name' => 'civicrm_saved_search',
264 'entity' => 'SavedSearch',
265 'bao' => 'CRM_Contact_BAO_SavedSearch',
266 'localizable' => 0,
267 'add' => '2.0',
268 ],
269 'api_entity' => [
270 'name' => 'api_entity',
271 'type' => CRM_Utils_Type::T_STRING,
272 'title' => ts('Entity Name'),
273 'description' => ts('Entity name for API based search'),
274 'maxlength' => 255,
275 'size' => CRM_Utils_Type::HUGE,
276 'where' => 'civicrm_saved_search.api_entity',
277 'table_name' => 'civicrm_saved_search',
278 'entity' => 'SavedSearch',
279 'bao' => 'CRM_Contact_BAO_SavedSearch',
280 'localizable' => 0,
281 'pseudoconstant' => [
282 'callback' => 'CRM_Contact_BAO_SavedSearch::getApiEntityOptions',
283 ],
284 'add' => '5.24',
285 ],
286 'api_params' => [
287 'name' => 'api_params',
288 'type' => CRM_Utils_Type::T_TEXT,
289 'title' => ts('API Parameters'),
290 'description' => ts('Parameters for API based search'),
291 'where' => 'civicrm_saved_search.api_params',
292 'table_name' => 'civicrm_saved_search',
293 'entity' => 'SavedSearch',
294 'bao' => 'CRM_Contact_BAO_SavedSearch',
295 'localizable' => 0,
296 'serialize' => self::SERIALIZE_JSON,
297 'add' => '5.24',
298 ],
299 'created_id' => [
300 'name' => 'created_id',
301 'type' => CRM_Utils_Type::T_INT,
302 'title' => ts('Created By Contact ID'),
303 'description' => ts('FK to contact table.'),
304 'where' => 'civicrm_saved_search.created_id',
305 'table_name' => 'civicrm_saved_search',
306 'entity' => 'SavedSearch',
307 'bao' => 'CRM_Contact_BAO_SavedSearch',
308 'localizable' => 0,
309 'FKClassName' => 'CRM_Contact_DAO_Contact',
310 'html' => [
311 'label' => ts("Created By"),
312 ],
313 'readonly' => TRUE,
314 'add' => '5.36',
315 ],
316 'modified_id' => [
317 'name' => 'modified_id',
318 'type' => CRM_Utils_Type::T_INT,
319 'title' => ts('Modified By Contact ID'),
320 'description' => ts('FK to contact table.'),
321 'where' => 'civicrm_saved_search.modified_id',
322 'table_name' => 'civicrm_saved_search',
323 'entity' => 'SavedSearch',
324 'bao' => 'CRM_Contact_BAO_SavedSearch',
325 'localizable' => 0,
326 'FKClassName' => 'CRM_Contact_DAO_Contact',
327 'html' => [
328 'label' => ts("Modified By"),
329 ],
330 'readonly' => TRUE,
331 'add' => '5.36',
332 ],
333 'expires_date' => [
334 'name' => 'expires_date',
335 'type' => CRM_Utils_Type::T_TIMESTAMP,
336 'title' => ts('Search Expiry Date'),
337 'description' => ts('Optional date after which the search is not needed'),
338 'required' => FALSE,
339 'where' => 'civicrm_saved_search.expires_date',
340 'table_name' => 'civicrm_saved_search',
341 'entity' => 'SavedSearch',
342 'bao' => 'CRM_Contact_BAO_SavedSearch',
343 'localizable' => 0,
344 'add' => '5.36',
345 ],
346 'created_date' => [
347 'name' => 'created_date',
348 'type' => CRM_Utils_Type::T_TIMESTAMP,
349 'title' => ts('Created Date'),
350 'description' => ts('When the search was created.'),
351 'required' => TRUE,
352 'where' => 'civicrm_saved_search.created_date',
353 'default' => 'CURRENT_TIMESTAMP',
354 'table_name' => 'civicrm_saved_search',
355 'entity' => 'SavedSearch',
356 'bao' => 'CRM_Contact_BAO_SavedSearch',
357 'localizable' => 0,
358 'readonly' => TRUE,
359 'add' => '5.36',
360 ],
361 'modified_date' => [
362 'name' => 'modified_date',
363 'type' => CRM_Utils_Type::T_TIMESTAMP,
364 'title' => ts('Modified Date'),
365 'description' => ts('When the search was last modified.'),
366 'required' => TRUE,
367 'where' => 'civicrm_saved_search.modified_date',
368 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
369 'table_name' => 'civicrm_saved_search',
370 'entity' => 'SavedSearch',
371 'bao' => 'CRM_Contact_BAO_SavedSearch',
372 'localizable' => 0,
373 'readonly' => TRUE,
374 'add' => '5.36',
375 ],
376 'description' => [
377 'name' => 'description',
378 'type' => CRM_Utils_Type::T_TEXT,
379 'title' => ts('Saved Search Description'),
380 'rows' => 2,
381 'cols' => 60,
382 'where' => 'civicrm_saved_search.description',
383 'table_name' => 'civicrm_saved_search',
384 'entity' => 'SavedSearch',
385 'bao' => 'CRM_Contact_BAO_SavedSearch',
386 'localizable' => 0,
387 'html' => [
388 'type' => 'TextArea',
389 ],
390 'add' => '5.36',
391 ],
392 ];
393 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
394 }
395 return Civi::$statics[__CLASS__]['fields'];
396 }
397
398 /**
399 * Return a mapping from field-name to the corresponding key (as used in fields()).
400 *
401 * @return array
402 * Array(string $name => string $uniqueName).
403 */
404 public static function &fieldKeys() {
405 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
406 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
407 }
408 return Civi::$statics[__CLASS__]['fieldKeys'];
409 }
410
411 /**
412 * Returns the names of this table
413 *
414 * @return string
415 */
416 public static function getTableName() {
417 return self::$_tableName;
418 }
419
420 /**
421 * Returns if this table needs to be logged
422 *
423 * @return bool
424 */
425 public function getLog() {
426 return self::$_log;
427 }
428
429 /**
430 * Returns the list of fields that can be imported
431 *
432 * @param bool $prefix
433 *
434 * @return array
435 */
436 public static function &import($prefix = FALSE) {
437 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'saved_search', $prefix, []);
438 return $r;
439 }
440
441 /**
442 * Returns the list of fields that can be exported
443 *
444 * @param bool $prefix
445 *
446 * @return array
447 */
448 public static function &export($prefix = FALSE) {
449 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'saved_search', $prefix, []);
450 return $r;
451 }
452
453 /**
454 * Returns the list of indices
455 *
456 * @param bool $localize
457 *
458 * @return array
459 */
460 public static function indices($localize = TRUE) {
461 $indices = [
462 'UI_name' => [
463 'name' => 'UI_name',
464 'field' => [
465 0 => 'name',
466 ],
467 'localizable' => FALSE,
468 'unique' => TRUE,
469 'sig' => 'civicrm_saved_search::1::name',
470 ],
471 ];
472 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
473 }
474
475 }