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