curious
[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:8fec5a0ffb4667af4f00820de74aa577)
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 'type' => 'EntityRef',
279 'label' => ts("Campaign"),
280 ],
281 'pseudoconstant' => [
282 'table' => 'civicrm_campaign',
283 'keyColumn' => 'id',
284 'labelColumn' => 'title',
285 'prefetch' => 'FALSE',
286 ],
287 'add' => '3.3',
288 ],
289 'activity_type_id' => [
290 'name' => 'activity_type_id',
291 'type' => CRM_Utils_Type::T_INT,
292 'title' => ts('Activity Type'),
293 'description' => ts('Implicit FK to civicrm_option_value where option_group = activity_type'),
294 'import' => TRUE,
295 'where' => 'civicrm_survey.activity_type_id',
296 'export' => TRUE,
297 'default' => NULL,
298 'table_name' => 'civicrm_survey',
299 'entity' => 'Survey',
300 'bao' => 'CRM_Campaign_BAO_Survey',
301 'localizable' => 0,
302 'html' => [
303 'type' => 'Select',
304 ],
305 'pseudoconstant' => [
306 'optionGroupName' => 'activity_type',
307 'optionEditPath' => 'civicrm/admin/options/activity_type',
308 ],
309 'add' => '3.3',
310 ],
311 'recontact_interval' => [
312 'name' => 'recontact_interval',
313 'type' => CRM_Utils_Type::T_TEXT,
314 'title' => ts('Follow up Interval'),
315 'description' => ts('Recontact intervals for each status.'),
316 'rows' => 20,
317 'cols' => 80,
318 'where' => 'civicrm_survey.recontact_interval',
319 'table_name' => 'civicrm_survey',
320 'entity' => 'Survey',
321 'bao' => 'CRM_Campaign_BAO_Survey',
322 'localizable' => 0,
323 'html' => [
324 'type' => 'TextArea',
325 ],
326 'add' => '3.3',
327 ],
328 'instructions' => [
329 'name' => 'instructions',
330 'type' => CRM_Utils_Type::T_TEXT,
331 'title' => ts('Instructions'),
332 'description' => ts('Script instructions for volunteers to use for the survey.'),
333 'rows' => 20,
334 'cols' => 80,
335 'where' => 'civicrm_survey.instructions',
336 'table_name' => 'civicrm_survey',
337 'entity' => 'Survey',
338 'bao' => 'CRM_Campaign_BAO_Survey',
339 'localizable' => 1,
340 'html' => [
341 'type' => 'TextArea',
342 ],
343 'add' => '3.3',
344 ],
345 'release_frequency' => [
346 'name' => 'release_frequency',
347 'type' => CRM_Utils_Type::T_INT,
348 'title' => ts('Survey Hold Duration'),
349 'description' => ts('Number of days for recurrence of release.'),
350 'where' => 'civicrm_survey.release_frequency',
351 'default' => NULL,
352 'table_name' => 'civicrm_survey',
353 'entity' => 'Survey',
354 'bao' => 'CRM_Campaign_BAO_Survey',
355 'localizable' => 0,
356 'add' => '3.3',
357 ],
358 'max_number_of_contacts' => [
359 'name' => 'max_number_of_contacts',
360 'type' => CRM_Utils_Type::T_INT,
361 'title' => ts('Maximum number of contacts'),
362 'description' => ts('Maximum number of contacts to allow for survey.'),
363 'where' => 'civicrm_survey.max_number_of_contacts',
364 'default' => NULL,
365 'table_name' => 'civicrm_survey',
366 'entity' => 'Survey',
367 'bao' => 'CRM_Campaign_BAO_Survey',
368 'localizable' => 0,
369 'add' => '3.3',
370 ],
371 'default_number_of_contacts' => [
372 'name' => 'default_number_of_contacts',
373 'type' => CRM_Utils_Type::T_INT,
374 'title' => ts('Default number of contacts'),
375 'description' => ts('Default number of contacts to allow for survey.'),
376 'where' => 'civicrm_survey.default_number_of_contacts',
377 'default' => NULL,
378 'table_name' => 'civicrm_survey',
379 'entity' => 'Survey',
380 'bao' => 'CRM_Campaign_BAO_Survey',
381 'localizable' => 0,
382 'add' => '3.3',
383 ],
384 'is_active' => [
385 'name' => 'is_active',
386 'type' => CRM_Utils_Type::T_BOOLEAN,
387 'title' => ts('Survey Is Active'),
388 'description' => ts('Is this survey enabled or disabled/cancelled?'),
389 'where' => 'civicrm_survey.is_active',
390 'default' => '1',
391 'table_name' => 'civicrm_survey',
392 'entity' => 'Survey',
393 'bao' => 'CRM_Campaign_BAO_Survey',
394 'localizable' => 0,
395 'add' => '3.3',
396 ],
397 'is_default' => [
398 'name' => 'is_default',
399 'type' => CRM_Utils_Type::T_BOOLEAN,
400 'title' => ts('Is Default Survey'),
401 'description' => ts('Is this default survey?'),
402 'where' => 'civicrm_survey.is_default',
403 'default' => '0',
404 'table_name' => 'civicrm_survey',
405 'entity' => 'Survey',
406 'bao' => 'CRM_Campaign_BAO_Survey',
407 'localizable' => 0,
408 'add' => '3.3',
409 ],
410 'created_id' => [
411 'name' => 'created_id',
412 'type' => CRM_Utils_Type::T_INT,
413 'title' => ts('Created By Contact ID'),
414 'description' => ts('FK to civicrm_contact, who created this Survey.'),
415 'where' => 'civicrm_survey.created_id',
416 'table_name' => 'civicrm_survey',
417 'entity' => 'Survey',
418 'bao' => 'CRM_Campaign_BAO_Survey',
419 'localizable' => 0,
420 'FKClassName' => 'CRM_Contact_DAO_Contact',
421 'html' => [
422 'label' => ts("Created By"),
423 ],
424 'add' => '3.3',
425 ],
426 'created_date' => [
427 'name' => 'created_date',
428 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
429 'title' => ts('Campaign Created Date'),
430 'description' => ts('Date and time that Survey was created.'),
431 'where' => 'civicrm_survey.created_date',
432 'table_name' => 'civicrm_survey',
433 'entity' => 'Survey',
434 'bao' => 'CRM_Campaign_BAO_Survey',
435 'localizable' => 0,
436 'add' => '3.3',
437 ],
438 'last_modified_id' => [
439 'name' => 'last_modified_id',
440 'type' => CRM_Utils_Type::T_INT,
441 'title' => ts('Modified By Contact ID'),
442 'description' => ts('FK to civicrm_contact, who recently edited this Survey.'),
443 'where' => 'civicrm_survey.last_modified_id',
444 'table_name' => 'civicrm_survey',
445 'entity' => 'Survey',
446 'bao' => 'CRM_Campaign_BAO_Survey',
447 'localizable' => 0,
448 'FKClassName' => 'CRM_Contact_DAO_Contact',
449 'html' => [
450 'label' => ts("Modified By"),
451 ],
452 'add' => '3.3',
453 ],
454 'last_modified_date' => [
455 'name' => 'last_modified_date',
456 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
457 'title' => ts('Survey Modified On'),
458 'description' => ts('Date and time that Survey was edited last time.'),
459 'where' => 'civicrm_survey.last_modified_date',
460 'table_name' => 'civicrm_survey',
461 'entity' => 'Survey',
462 'bao' => 'CRM_Campaign_BAO_Survey',
463 'localizable' => 0,
464 'add' => '3.3',
465 ],
466 'result_id' => [
467 'name' => 'result_id',
468 'type' => CRM_Utils_Type::T_INT,
469 'title' => ts('Survey Result'),
470 'description' => ts('Used to store option group id.'),
471 'where' => 'civicrm_survey.result_id',
472 'default' => NULL,
473 'table_name' => 'civicrm_survey',
474 'entity' => 'Survey',
475 'bao' => 'CRM_Campaign_BAO_Survey',
476 'localizable' => 0,
477 'pseudoconstant' => [
478 'table' => 'civicrm_option_group',
479 'keyColumn' => 'id',
480 'labelColumn' => 'title',
481 'nameColumn' => 'name',
482 'condition' => 'name LIKE "civicrm_survey_%"',
483 ],
484 'add' => '3.3',
485 ],
486 'bypass_confirm' => [
487 'name' => 'bypass_confirm',
488 'type' => CRM_Utils_Type::T_BOOLEAN,
489 'title' => ts('No Email Verification'),
490 'description' => ts('Bypass the email verification.'),
491 'where' => 'civicrm_survey.bypass_confirm',
492 'default' => '0',
493 'table_name' => 'civicrm_survey',
494 'entity' => 'Survey',
495 'bao' => 'CRM_Campaign_BAO_Survey',
496 'localizable' => 0,
497 'add' => '4.2',
498 ],
499 'thankyou_title' => [
500 'name' => 'thankyou_title',
501 'type' => CRM_Utils_Type::T_STRING,
502 'title' => ts('Thank-you Title'),
503 'description' => ts('Title for Thank-you page (header title tag, and display at the top of the page).'),
504 'maxlength' => 255,
505 'size' => CRM_Utils_Type::HUGE,
506 'where' => 'civicrm_survey.thankyou_title',
507 'table_name' => 'civicrm_survey',
508 'entity' => 'Survey',
509 'bao' => 'CRM_Campaign_BAO_Survey',
510 'localizable' => 1,
511 'add' => '4.2',
512 ],
513 'thankyou_text' => [
514 'name' => 'thankyou_text',
515 'type' => CRM_Utils_Type::T_TEXT,
516 'title' => ts('Thank-you Text'),
517 'description' => ts('text and html allowed. displayed above result on success page'),
518 'rows' => 8,
519 'cols' => 60,
520 'where' => 'civicrm_survey.thankyou_text',
521 'table_name' => 'civicrm_survey',
522 'entity' => 'Survey',
523 'bao' => 'CRM_Campaign_BAO_Survey',
524 'localizable' => 1,
525 'html' => [
526 'type' => 'TextArea',
527 ],
528 'add' => '4.2',
529 ],
530 'is_share' => [
531 'name' => 'is_share',
532 'type' => CRM_Utils_Type::T_BOOLEAN,
533 'title' => ts('Is shared through social media'),
534 'description' => ts('Can people share the petition through social media?'),
535 'where' => 'civicrm_survey.is_share',
536 'default' => '1',
537 'table_name' => 'civicrm_survey',
538 'entity' => 'Survey',
539 'bao' => 'CRM_Campaign_BAO_Survey',
540 'localizable' => 0,
541 'add' => '4.4',
542 ],
543 ];
544 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
545 }
546 return Civi::$statics[__CLASS__]['fields'];
547 }
548
549 /**
550 * Return a mapping from field-name to the corresponding key (as used in fields()).
551 *
552 * @return array
553 * Array(string $name => string $uniqueName).
554 */
555 public static function &fieldKeys() {
556 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
557 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
558 }
559 return Civi::$statics[__CLASS__]['fieldKeys'];
560 }
561
562 /**
563 * Returns the names of this table
564 *
565 * @return string
566 */
567 public static function getTableName() {
568 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
569 }
570
571 /**
572 * Returns if this table needs to be logged
573 *
574 * @return bool
575 */
576 public function getLog() {
577 return self::$_log;
578 }
579
580 /**
581 * Returns the list of fields that can be imported
582 *
583 * @param bool $prefix
584 *
585 * @return array
586 */
587 public static function &import($prefix = FALSE) {
588 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'survey', $prefix, []);
589 return $r;
590 }
591
592 /**
593 * Returns the list of fields that can be exported
594 *
595 * @param bool $prefix
596 *
597 * @return array
598 */
599 public static function &export($prefix = FALSE) {
600 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'survey', $prefix, []);
601 return $r;
602 }
603
604 /**
605 * Returns the list of indices
606 *
607 * @param bool $localize
608 *
609 * @return array
610 */
611 public static function indices($localize = TRUE) {
612 $indices = [
613 'UI_activity_type_id' => [
614 'name' => 'UI_activity_type_id',
615 'field' => [
616 0 => 'activity_type_id',
617 ],
618 'localizable' => FALSE,
619 'sig' => 'civicrm_survey::0::activity_type_id',
620 ],
621 ];
622 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
623 }
624
625 }