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