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