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