SearchKit - Add translatable descriptions to entities
[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:c884fe02dfd203d381429f83672e1a9e)
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 ],
223 'add' => '5.32',
224 ],
225 'form_values' => [
226 'name' => 'form_values',
227 'type' => CRM_Utils_Type::T_TEXT,
228 'title' => ts('Submitted Form Values'),
229 'description' => ts('Submitted form values for this search'),
230 'import' => TRUE,
231 'where' => 'civicrm_saved_search.form_values',
232 'export' => TRUE,
233 'table_name' => 'civicrm_saved_search',
234 'entity' => 'SavedSearch',
235 'bao' => 'CRM_Contact_BAO_SavedSearch',
236 'localizable' => 0,
237 'serialize' => self::SERIALIZE_PHP,
238 'add' => '1.1',
239 ],
240 'mapping_id' => [
241 'name' => 'mapping_id',
242 'type' => CRM_Utils_Type::T_INT,
243 'title' => ts('Mapping ID'),
244 'description' => ts('Foreign key to civicrm_mapping used for saved search-builder searches.'),
245 'where' => 'civicrm_saved_search.mapping_id',
246 'table_name' => 'civicrm_saved_search',
247 'entity' => 'SavedSearch',
248 'bao' => 'CRM_Contact_BAO_SavedSearch',
249 'localizable' => 0,
250 'FKClassName' => 'CRM_Core_DAO_Mapping',
251 'html' => [
252 'label' => ts("Mapping"),
253 ],
254 'add' => '1.5',
255 ],
256 'search_custom_id' => [
257 'name' => 'search_custom_id',
258 'type' => CRM_Utils_Type::T_INT,
259 'title' => ts('Option Value ID'),
260 'description' => ts('Foreign key to civicrm_option value table used for saved custom searches.'),
261 'where' => 'civicrm_saved_search.search_custom_id',
262 'table_name' => 'civicrm_saved_search',
263 'entity' => 'SavedSearch',
264 'bao' => 'CRM_Contact_BAO_SavedSearch',
265 'localizable' => 0,
266 'add' => '2.0',
267 ],
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,
280 'add' => '5.24',
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,
293 'add' => '5.24',
294 ],
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 ],
309 'readonly' => TRUE,
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 ],
326 'readonly' => TRUE,
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,
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,
354 'readonly' => TRUE,
355 'add' => '5.36',
356 ],
357 'modified_date' => [
358 'name' => 'modified_date',
359 'type' => CRM_Utils_Type::T_TIMESTAMP,
360 'title' => ts('Modified Date'),
361 'description' => ts('When the search was last modified.'),
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,
369 'readonly' => TRUE,
370 'add' => '5.36',
371 ],
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 ],
388 ];
389 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
390 }
391 return Civi::$statics[__CLASS__]['fields'];
392 }
393
394 /**
395 * Return a mapping from field-name to the corresponding key (as used in fields()).
396 *
397 * @return array
398 * Array(string $name => string $uniqueName).
399 */
400 public static function &fieldKeys() {
401 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
402 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
403 }
404 return Civi::$statics[__CLASS__]['fieldKeys'];
405 }
406
407 /**
408 * Returns the names of this table
409 *
410 * @return string
411 */
412 public static function getTableName() {
413 return self::$_tableName;
414 }
415
416 /**
417 * Returns if this table needs to be logged
418 *
419 * @return bool
420 */
421 public function getLog() {
422 return self::$_log;
423 }
424
425 /**
426 * Returns the list of fields that can be imported
427 *
428 * @param bool $prefix
429 *
430 * @return array
431 */
432 public static function &import($prefix = FALSE) {
433 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'saved_search', $prefix, []);
434 return $r;
435 }
436
437 /**
438 * Returns the list of fields that can be exported
439 *
440 * @param bool $prefix
441 *
442 * @return array
443 */
444 public static function &export($prefix = FALSE) {
445 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'saved_search', $prefix, []);
446 return $r;
447 }
448
449 /**
450 * Returns the list of indices
451 *
452 * @param bool $localize
453 *
454 * @return array
455 */
456 public static function indices($localize = TRUE) {
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 ];
468 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
469 }
470
471 }