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