Merge pull request #19695 from civicrm/5.35
[civicrm-core.git] / CRM / Campaign / DAO / Survey.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Campaign/Survey.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:1c74399d67561c75f39d8db59b04737d)
10 */
11
12 /**
13 * Database access object for the Survey entity.
14 */
15 class CRM_Campaign_DAO_Survey extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '3.2';
18 const COMPONENT = 'CiviCampaign';
19
20 /**
21 * Static instance to hold the table name.
22 *
23 * @var string
24 */
25 public static $_tableName = 'civicrm_survey';
26
27 /**
28 * Icon associated with this entity.
29 *
30 * @var string
31 */
32 public static $_icon = 'fa-clipboard';
33
34 /**
35 * Field to show when displaying a record.
36 *
37 * @var string
38 */
39 public static $_labelField = 'title';
40
41 /**
42 * Should CiviCRM log any modifications to this table in the civicrm_log table.
43 *
44 * @var bool
45 */
46 public static $_log = FALSE;
47
48 /**
49 * Survey id.
50 *
51 * @var int
52 */
53 public $id;
54
55 /**
56 * Title of the Survey.
57 *
58 * @var string
59 */
60 public $title;
61
62 /**
63 * Foreign key to the Campaign.
64 *
65 * @var int
66 */
67 public $campaign_id;
68
69 /**
70 * Implicit FK to civicrm_option_value where option_group = activity_type
71 *
72 * @var int
73 */
74 public $activity_type_id;
75
76 /**
77 * Recontact intervals for each status.
78 *
79 * @var text
80 */
81 public $recontact_interval;
82
83 /**
84 * Script instructions for volunteers to use for the survey.
85 *
86 * @var text
87 */
88 public $instructions;
89
90 /**
91 * Number of days for recurrence of release.
92 *
93 * @var int
94 */
95 public $release_frequency;
96
97 /**
98 * Maximum number of contacts to allow for survey.
99 *
100 * @var int
101 */
102 public $max_number_of_contacts;
103
104 /**
105 * Default number of contacts to allow for survey.
106 *
107 * @var int
108 */
109 public $default_number_of_contacts;
110
111 /**
112 * Is this survey enabled or disabled/cancelled?
113 *
114 * @var bool
115 */
116 public $is_active;
117
118 /**
119 * Is this default survey?
120 *
121 * @var bool
122 */
123 public $is_default;
124
125 /**
126 * FK to civicrm_contact, who created this Survey.
127 *
128 * @var int
129 */
130 public $created_id;
131
132 /**
133 * Date and time that Survey was created.
134 *
135 * @var datetime
136 */
137 public $created_date;
138
139 /**
140 * FK to civicrm_contact, who recently edited this Survey.
141 *
142 * @var int
143 */
144 public $last_modified_id;
145
146 /**
147 * Date and time that Survey was edited last time.
148 *
149 * @var datetime
150 */
151 public $last_modified_date;
152
153 /**
154 * Used to store option group id.
155 *
156 * @var int
157 */
158 public $result_id;
159
160 /**
161 * Bypass the email verification.
162 *
163 * @var bool
164 */
165 public $bypass_confirm;
166
167 /**
168 * Title for Thank-you page (header title tag, and display at the top of the page).
169 *
170 * @var string
171 */
172 public $thankyou_title;
173
174 /**
175 * text and html allowed. displayed above result on success page
176 *
177 * @var text
178 */
179 public $thankyou_text;
180
181 /**
182 * Can people share the petition through social media?
183 *
184 * @var bool
185 */
186 public $is_share;
187
188 /**
189 * Class constructor.
190 */
191 public function __construct() {
192 $this->__table = 'civicrm_survey';
193 parent::__construct();
194 }
195
196 /**
197 * Returns localized title of this entity.
198 *
199 * @param bool $plural
200 * Whether to return the plural version of the title.
201 */
202 public static function getEntityTitle($plural = FALSE) {
203 return $plural ? ts('Surveys') : ts('Survey');
204 }
205
206 /**
207 * Returns foreign keys and entity references.
208 *
209 * @return array
210 * [CRM_Core_Reference_Interface]
211 */
212 public static function getReferenceColumns() {
213 if (!isset(Civi::$statics[__CLASS__]['links'])) {
214 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
215 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
216 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id');
217 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'last_modified_id', 'civicrm_contact', 'id');
218 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
219 }
220 return Civi::$statics[__CLASS__]['links'];
221 }
222
223 /**
224 * Returns all the column names of this table
225 *
226 * @return array
227 */
228 public static function &fields() {
229 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
230 Civi::$statics[__CLASS__]['fields'] = [
231 'id' => [
232 'name' => 'id',
233 'type' => CRM_Utils_Type::T_INT,
234 'title' => ts('Survey ID'),
235 'description' => ts('Survey id.'),
236 'required' => TRUE,
237 'where' => 'civicrm_survey.id',
238 'table_name' => 'civicrm_survey',
239 'entity' => 'Survey',
240 'bao' => 'CRM_Campaign_BAO_Survey',
241 'localizable' => 0,
242 'html' => [
243 'type' => 'Number',
244 ],
245 'readonly' => TRUE,
246 'add' => '3.3',
247 ],
248 'title' => [
249 'name' => 'title',
250 'type' => CRM_Utils_Type::T_STRING,
251 'title' => ts('Survey Title'),
252 'description' => ts('Title of the Survey.'),
253 'required' => TRUE,
254 'maxlength' => 255,
255 'size' => CRM_Utils_Type::HUGE,
256 'import' => TRUE,
257 'where' => 'civicrm_survey.title',
258 'export' => TRUE,
259 'table_name' => 'civicrm_survey',
260 'entity' => 'Survey',
261 'bao' => 'CRM_Campaign_BAO_Survey',
262 'localizable' => 1,
263 'add' => '3.3',
264 ],
265 'campaign_id' => [
266 'name' => 'campaign_id',
267 'type' => CRM_Utils_Type::T_INT,
268 'title' => ts('Campaign ID'),
269 'description' => ts('Foreign key to the Campaign.'),
270 'where' => 'civicrm_survey.campaign_id',
271 'default' => 'NULL',
272 'table_name' => 'civicrm_survey',
273 'entity' => 'Survey',
274 'bao' => 'CRM_Campaign_BAO_Survey',
275 'localizable' => 0,
276 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
277 'html' => [
278 'label' => ts("Campaign"),
279 ],
280 'add' => '3.3',
281 ],
282 'activity_type_id' => [
283 'name' => 'activity_type_id',
284 'type' => CRM_Utils_Type::T_INT,
285 'title' => ts('Activity Type'),
286 'description' => ts('Implicit FK to civicrm_option_value where option_group = activity_type'),
287 'import' => TRUE,
288 'where' => 'civicrm_survey.activity_type_id',
289 'export' => TRUE,
290 'default' => 'NULL',
291 'table_name' => 'civicrm_survey',
292 'entity' => 'Survey',
293 'bao' => 'CRM_Campaign_BAO_Survey',
294 'localizable' => 0,
295 'html' => [
296 'type' => 'Select',
297 ],
298 'pseudoconstant' => [
299 'optionGroupName' => 'activity_type',
300 'optionEditPath' => 'civicrm/admin/options/activity_type',
301 ],
302 'add' => '3.3',
303 ],
304 'recontact_interval' => [
305 'name' => 'recontact_interval',
306 'type' => CRM_Utils_Type::T_TEXT,
307 'title' => ts('Follow up Interval'),
308 'description' => ts('Recontact intervals for each status.'),
309 'rows' => 20,
310 'cols' => 80,
311 'where' => 'civicrm_survey.recontact_interval',
312 'table_name' => 'civicrm_survey',
313 'entity' => 'Survey',
314 'bao' => 'CRM_Campaign_BAO_Survey',
315 'localizable' => 0,
316 'html' => [
317 'type' => 'TextArea',
318 ],
319 'add' => '3.3',
320 ],
321 'instructions' => [
322 'name' => 'instructions',
323 'type' => CRM_Utils_Type::T_TEXT,
324 'title' => ts('Instructions'),
325 'description' => ts('Script instructions for volunteers to use for the survey.'),
326 'rows' => 20,
327 'cols' => 80,
328 'where' => 'civicrm_survey.instructions',
329 'table_name' => 'civicrm_survey',
330 'entity' => 'Survey',
331 'bao' => 'CRM_Campaign_BAO_Survey',
332 'localizable' => 1,
333 'html' => [
334 'type' => 'TextArea',
335 ],
336 'add' => '3.3',
337 ],
338 'release_frequency' => [
339 'name' => 'release_frequency',
340 'type' => CRM_Utils_Type::T_INT,
341 'title' => ts('Survey Hold Duration'),
342 'description' => ts('Number of days for recurrence of release.'),
343 'where' => 'civicrm_survey.release_frequency',
344 'default' => 'NULL',
345 'table_name' => 'civicrm_survey',
346 'entity' => 'Survey',
347 'bao' => 'CRM_Campaign_BAO_Survey',
348 'localizable' => 0,
349 'add' => '3.3',
350 ],
351 'max_number_of_contacts' => [
352 'name' => 'max_number_of_contacts',
353 'type' => CRM_Utils_Type::T_INT,
354 'title' => ts('Maximum number of contacts'),
355 'description' => ts('Maximum number of contacts to allow for survey.'),
356 'where' => 'civicrm_survey.max_number_of_contacts',
357 'default' => 'NULL',
358 'table_name' => 'civicrm_survey',
359 'entity' => 'Survey',
360 'bao' => 'CRM_Campaign_BAO_Survey',
361 'localizable' => 0,
362 'add' => '3.3',
363 ],
364 'default_number_of_contacts' => [
365 'name' => 'default_number_of_contacts',
366 'type' => CRM_Utils_Type::T_INT,
367 'title' => ts('Default number of contacts'),
368 'description' => ts('Default number of contacts to allow for survey.'),
369 'where' => 'civicrm_survey.default_number_of_contacts',
370 'default' => 'NULL',
371 'table_name' => 'civicrm_survey',
372 'entity' => 'Survey',
373 'bao' => 'CRM_Campaign_BAO_Survey',
374 'localizable' => 0,
375 'add' => '3.3',
376 ],
377 'is_active' => [
378 'name' => 'is_active',
379 'type' => CRM_Utils_Type::T_BOOLEAN,
380 'title' => ts('Survey Is Active'),
381 'description' => ts('Is this survey enabled or disabled/cancelled?'),
382 'where' => 'civicrm_survey.is_active',
383 'default' => '1',
384 'table_name' => 'civicrm_survey',
385 'entity' => 'Survey',
386 'bao' => 'CRM_Campaign_BAO_Survey',
387 'localizable' => 0,
388 'add' => '3.3',
389 ],
390 'is_default' => [
391 'name' => 'is_default',
392 'type' => CRM_Utils_Type::T_BOOLEAN,
393 'title' => ts('Is Default Survey'),
394 'description' => ts('Is this default survey?'),
395 'where' => 'civicrm_survey.is_default',
396 'default' => '0',
397 'table_name' => 'civicrm_survey',
398 'entity' => 'Survey',
399 'bao' => 'CRM_Campaign_BAO_Survey',
400 'localizable' => 0,
401 'add' => '3.3',
402 ],
403 'created_id' => [
404 'name' => 'created_id',
405 'type' => CRM_Utils_Type::T_INT,
406 'title' => ts('Created By Contact ID'),
407 'description' => ts('FK to civicrm_contact, who created this Survey.'),
408 'where' => 'civicrm_survey.created_id',
409 'table_name' => 'civicrm_survey',
410 'entity' => 'Survey',
411 'bao' => 'CRM_Campaign_BAO_Survey',
412 'localizable' => 0,
413 'FKClassName' => 'CRM_Contact_DAO_Contact',
414 'html' => [
415 'label' => ts("Created By"),
416 ],
417 'add' => '3.3',
418 ],
419 'created_date' => [
420 'name' => 'created_date',
421 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
422 'title' => ts('Campaign Created Date'),
423 'description' => ts('Date and time that Survey was created.'),
424 'where' => 'civicrm_survey.created_date',
425 'table_name' => 'civicrm_survey',
426 'entity' => 'Survey',
427 'bao' => 'CRM_Campaign_BAO_Survey',
428 'localizable' => 0,
429 'add' => '3.3',
430 ],
431 'last_modified_id' => [
432 'name' => 'last_modified_id',
433 'type' => CRM_Utils_Type::T_INT,
434 'title' => ts('Modified By Contact ID'),
435 'description' => ts('FK to civicrm_contact, who recently edited this Survey.'),
436 'where' => 'civicrm_survey.last_modified_id',
437 'table_name' => 'civicrm_survey',
438 'entity' => 'Survey',
439 'bao' => 'CRM_Campaign_BAO_Survey',
440 'localizable' => 0,
441 'FKClassName' => 'CRM_Contact_DAO_Contact',
442 'html' => [
443 'label' => ts("Modified By"),
444 ],
445 'add' => '3.3',
446 ],
447 'last_modified_date' => [
448 'name' => 'last_modified_date',
449 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
450 'title' => ts('Survey Modified On'),
451 'description' => ts('Date and time that Survey was edited last time.'),
452 'where' => 'civicrm_survey.last_modified_date',
453 'table_name' => 'civicrm_survey',
454 'entity' => 'Survey',
455 'bao' => 'CRM_Campaign_BAO_Survey',
456 'localizable' => 0,
457 'add' => '3.3',
458 ],
459 'result_id' => [
460 'name' => 'result_id',
461 'type' => CRM_Utils_Type::T_INT,
462 'title' => ts('Survey Result'),
463 'description' => ts('Used to store option group id.'),
464 'where' => 'civicrm_survey.result_id',
465 'default' => 'NULL',
466 'table_name' => 'civicrm_survey',
467 'entity' => 'Survey',
468 'bao' => 'CRM_Campaign_BAO_Survey',
469 'localizable' => 0,
470 'add' => '3.3',
471 ],
472 'bypass_confirm' => [
473 'name' => 'bypass_confirm',
474 'type' => CRM_Utils_Type::T_BOOLEAN,
475 'title' => ts('No Email Verification'),
476 'description' => ts('Bypass the email verification.'),
477 'where' => 'civicrm_survey.bypass_confirm',
478 'default' => '0',
479 'table_name' => 'civicrm_survey',
480 'entity' => 'Survey',
481 'bao' => 'CRM_Campaign_BAO_Survey',
482 'localizable' => 0,
483 'add' => '4.2',
484 ],
485 'thankyou_title' => [
486 'name' => 'thankyou_title',
487 'type' => CRM_Utils_Type::T_STRING,
488 'title' => ts('Thank-you Title'),
489 'description' => ts('Title for Thank-you page (header title tag, and display at the top of the page).'),
490 'maxlength' => 255,
491 'size' => CRM_Utils_Type::HUGE,
492 'where' => 'civicrm_survey.thankyou_title',
493 'table_name' => 'civicrm_survey',
494 'entity' => 'Survey',
495 'bao' => 'CRM_Campaign_BAO_Survey',
496 'localizable' => 1,
497 'add' => '4.2',
498 ],
499 'thankyou_text' => [
500 'name' => 'thankyou_text',
501 'type' => CRM_Utils_Type::T_TEXT,
502 'title' => ts('Thank-you Text'),
503 'description' => ts('text and html allowed. displayed above result on success page'),
504 'rows' => 8,
505 'cols' => 60,
506 'where' => 'civicrm_survey.thankyou_text',
507 'table_name' => 'civicrm_survey',
508 'entity' => 'Survey',
509 'bao' => 'CRM_Campaign_BAO_Survey',
510 'localizable' => 1,
511 'html' => [
512 'type' => 'TextArea',
513 ],
514 'add' => '4.2',
515 ],
516 'is_share' => [
517 'name' => 'is_share',
518 'type' => CRM_Utils_Type::T_BOOLEAN,
519 'title' => ts('Is shared through social media'),
520 'description' => ts('Can people share the petition through social media?'),
521 'where' => 'civicrm_survey.is_share',
522 'default' => '1',
523 'table_name' => 'civicrm_survey',
524 'entity' => 'Survey',
525 'bao' => 'CRM_Campaign_BAO_Survey',
526 'localizable' => 0,
527 'add' => '4.4',
528 ],
529 ];
530 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
531 }
532 return Civi::$statics[__CLASS__]['fields'];
533 }
534
535 /**
536 * Return a mapping from field-name to the corresponding key (as used in fields()).
537 *
538 * @return array
539 * Array(string $name => string $uniqueName).
540 */
541 public static function &fieldKeys() {
542 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
543 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
544 }
545 return Civi::$statics[__CLASS__]['fieldKeys'];
546 }
547
548 /**
549 * Returns the names of this table
550 *
551 * @return string
552 */
553 public static function getTableName() {
554 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
555 }
556
557 /**
558 * Returns if this table needs to be logged
559 *
560 * @return bool
561 */
562 public function getLog() {
563 return self::$_log;
564 }
565
566 /**
567 * Returns the list of fields that can be imported
568 *
569 * @param bool $prefix
570 *
571 * @return array
572 */
573 public static function &import($prefix = FALSE) {
574 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'survey', $prefix, []);
575 return $r;
576 }
577
578 /**
579 * Returns the list of fields that can be exported
580 *
581 * @param bool $prefix
582 *
583 * @return array
584 */
585 public static function &export($prefix = FALSE) {
586 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'survey', $prefix, []);
587 return $r;
588 }
589
590 /**
591 * Returns the list of indices
592 *
593 * @param bool $localize
594 *
595 * @return array
596 */
597 public static function indices($localize = TRUE) {
598 $indices = [
599 'UI_activity_type_id' => [
600 'name' => 'UI_activity_type_id',
601 'field' => [
602 0 => 'activity_type_id',
603 ],
604 'localizable' => FALSE,
605 'sig' => 'civicrm_survey::0::activity_type_id',
606 ],
607 ];
608 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
609 }
610
611 }