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