Respect '0' as a default when generating DAOs
[civicrm-core.git] / CRM / Campaign / DAO / Survey.php
CommitLineData
e501603b 1<?php
c3fc2621 2
e501603b
TO
3/**
4 * @package CRM
8c9251b3 5 * @copyright CiviCRM LLC (c) 2004-2018
e501603b
TO
6 *
7 * Generated from xml/schema/CRM/Campaign/Survey.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
e7a6b91a 9 * (GenCodeChecksum:55aa9d31d08f8b5353d42dde1278b7f2)
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 */
22 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 */
c3fc2621
CW
29 static $_log = FALSE;
30
e501603b
TO
31 /**
32 * Survey id.
33 *
34 * @var int unsigned
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 *
48 * @var int unsigned
49 */
50 public $campaign_id;
c3fc2621 51
e501603b
TO
52 /**
53 * Implicit FK to civicrm_option_value where option_group = activity_type
54 *
55 * @var int unsigned
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 *
76 * @var int unsigned
77 */
78 public $release_frequency;
c3fc2621 79
e501603b
TO
80 /**
81 * Maximum number of contacts to allow for survey.
82 *
83 * @var int unsigned
84 */
85 public $max_number_of_contacts;
c3fc2621 86
e501603b
TO
87 /**
88 * Default number of contacts to allow for survey.
89 *
90 * @var int unsigned
91 */
92 public $default_number_of_contacts;
c3fc2621 93
e501603b
TO
94 /**
95 * Is this survey enabled or disabled/cancelled?
96 *
97 * @var boolean
98 */
99 public $is_active;
c3fc2621 100
e501603b
TO
101 /**
102 * Is this default survey?
103 *
104 * @var boolean
105 */
106 public $is_default;
c3fc2621 107
e501603b
TO
108 /**
109 * FK to civicrm_contact, who created this Survey.
110 *
111 * @var int unsigned
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 *
125 * @var int unsigned
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 *
139 * @var int unsigned
140 */
141 public $result_id;
c3fc2621 142
e501603b
TO
143 /**
144 * Bypass the email verification.
145 *
146 * @var boolean
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 *
167 * @var boolean
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
TO
186 if (!isset(Civi::$statics[__CLASS__]['links'])) {
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'),
e501603b 208 'description' => 'Survey id.',
c3fc2621 209 'required' => TRUE,
522a26c9 210 'table_name' => 'civicrm_survey',
211 'entity' => 'Survey',
212 'bao' => 'CRM_Campaign_BAO_Survey',
6a7e5e5d 213 'localizable' => 0,
c3fc2621
CW
214 ],
215 'title' => [
e501603b
TO
216 'name' => 'title',
217 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 218 'title' => ts('Survey Title'),
e501603b 219 'description' => 'Title of the Survey.',
c3fc2621 220 'required' => TRUE,
e501603b
TO
221 'maxlength' => 255,
222 'size' => CRM_Utils_Type::HUGE,
c3fc2621 223 'import' => TRUE,
e501603b
TO
224 'where' => 'civicrm_survey.title',
225 'headerPattern' => '',
226 'dataPattern' => '',
c3fc2621 227 'export' => TRUE,
522a26c9 228 'table_name' => 'civicrm_survey',
229 'entity' => 'Survey',
230 'bao' => 'CRM_Campaign_BAO_Survey',
6a7e5e5d 231 'localizable' => 1,
c3fc2621
CW
232 ],
233 'campaign_id' => [
e501603b
TO
234 'name' => 'campaign_id',
235 'type' => CRM_Utils_Type::T_INT,
c3fc2621 236 'title' => ts('Survey Campaign ID'),
e501603b
TO
237 'description' => 'Foreign key to the Campaign.',
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',
c3fc2621
CW
248 ]
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'),
e501603b 254 'description' => 'Implicit FK to civicrm_option_value where option_group = activity_type',
c3fc2621 255 'import' => TRUE,
e501603b
TO
256 'where' => 'civicrm_survey.activity_type_id',
257 'headerPattern' => '',
258 'dataPattern' => '',
c3fc2621 259 'export' => TRUE,
e501603b 260 'default' => 'NULL',
522a26c9 261 'table_name' => 'civicrm_survey',
262 'entity' => 'Survey',
263 'bao' => 'CRM_Campaign_BAO_Survey',
6a7e5e5d 264 'localizable' => 0,
c3fc2621 265 'html' => [
e501603b 266 'type' => 'Select',
c3fc2621
CW
267 ],
268 'pseudoconstant' => [
e501603b
TO
269 'optionGroupName' => 'activity_type',
270 'optionEditPath' => 'civicrm/admin/options/activity_type',
c3fc2621
CW
271 ]
272 ],
273 'recontact_interval' => [
e501603b
TO
274 'name' => 'recontact_interval',
275 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 276 'title' => ts('Follow up Interval'),
e501603b
TO
277 'description' => 'Recontact intervals for each status.',
278 'rows' => 20,
279 'cols' => 80,
522a26c9 280 'table_name' => 'civicrm_survey',
281 'entity' => 'Survey',
282 'bao' => 'CRM_Campaign_BAO_Survey',
6a7e5e5d 283 'localizable' => 0,
c3fc2621 284 'html' => [
e501603b 285 'type' => 'TextArea',
c3fc2621
CW
286 ],
287 ],
288 'instructions' => [
e501603b
TO
289 'name' => 'instructions',
290 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 291 'title' => ts('Instructions'),
e501603b
TO
292 'description' => 'Script instructions for volunteers to use for the survey.',
293 'rows' => 20,
294 'cols' => 80,
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'),
e501603b
TO
307 'description' => 'Number of days for recurrence of release.',
308 'default' => 'NULL',
522a26c9 309 'table_name' => 'civicrm_survey',
310 'entity' => 'Survey',
311 'bao' => 'CRM_Campaign_BAO_Survey',
6a7e5e5d 312 'localizable' => 0,
c3fc2621
CW
313 ],
314 'max_number_of_contacts' => [
e501603b
TO
315 'name' => 'max_number_of_contacts',
316 'type' => CRM_Utils_Type::T_INT,
c3fc2621 317 'title' => ts('Maximum number of contacts'),
e501603b
TO
318 'description' => 'Maximum number of contacts to allow for survey.',
319 'default' => 'NULL',
522a26c9 320 'table_name' => 'civicrm_survey',
321 'entity' => 'Survey',
322 'bao' => 'CRM_Campaign_BAO_Survey',
6a7e5e5d 323 'localizable' => 0,
c3fc2621
CW
324 ],
325 'default_number_of_contacts' => [
e501603b
TO
326 'name' => 'default_number_of_contacts',
327 'type' => CRM_Utils_Type::T_INT,
c3fc2621 328 'title' => ts('Default number of contacts'),
e501603b
TO
329 'description' => 'Default number of contacts to allow for survey.',
330 'default' => 'NULL',
522a26c9 331 'table_name' => 'civicrm_survey',
332 'entity' => 'Survey',
333 'bao' => 'CRM_Campaign_BAO_Survey',
6a7e5e5d 334 'localizable' => 0,
c3fc2621
CW
335 ],
336 'is_active' => [
e501603b
TO
337 'name' => 'is_active',
338 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 339 'title' => ts('Survey Is Active'),
e501603b
TO
340 'description' => 'Is this survey enabled or disabled/cancelled?',
341 'default' => '1',
522a26c9 342 'table_name' => 'civicrm_survey',
343 'entity' => 'Survey',
344 'bao' => 'CRM_Campaign_BAO_Survey',
6a7e5e5d 345 'localizable' => 0,
c3fc2621
CW
346 ],
347 'is_default' => [
e501603b
TO
348 'name' => 'is_default',
349 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 350 'title' => ts('Is Default Survey'),
e501603b 351 'description' => 'Is this default survey?',
45a83e42 352 'default' => '0',
522a26c9 353 'table_name' => 'civicrm_survey',
354 'entity' => 'Survey',
355 'bao' => 'CRM_Campaign_BAO_Survey',
6a7e5e5d 356 'localizable' => 0,
c3fc2621
CW
357 ],
358 'created_id' => [
e501603b
TO
359 'name' => 'created_id',
360 'type' => CRM_Utils_Type::T_INT,
c3fc2621 361 'title' => ts('Survey Created By'),
e501603b 362 'description' => 'FK to civicrm_contact, who created this Survey.',
522a26c9 363 'table_name' => 'civicrm_survey',
364 'entity' => 'Survey',
365 'bao' => 'CRM_Campaign_BAO_Survey',
6a7e5e5d 366 'localizable' => 0,
e501603b 367 'FKClassName' => 'CRM_Contact_DAO_Contact',
c3fc2621
CW
368 ],
369 'created_date' => [
e501603b
TO
370 'name' => 'created_date',
371 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
c3fc2621 372 'title' => ts('Campaign Created Date'),
e501603b 373 'description' => 'Date and time that Survey was created.',
522a26c9 374 'table_name' => 'civicrm_survey',
375 'entity' => 'Survey',
376 'bao' => 'CRM_Campaign_BAO_Survey',
6a7e5e5d 377 'localizable' => 0,
c3fc2621
CW
378 ],
379 'last_modified_id' => [
e501603b
TO
380 'name' => 'last_modified_id',
381 'type' => CRM_Utils_Type::T_INT,
c3fc2621 382 'title' => ts('Survey Modified'),
e501603b 383 'description' => 'FK to civicrm_contact, who recently edited this Survey.',
522a26c9 384 'table_name' => 'civicrm_survey',
385 'entity' => 'Survey',
386 'bao' => 'CRM_Campaign_BAO_Survey',
6a7e5e5d 387 'localizable' => 0,
e501603b 388 'FKClassName' => 'CRM_Contact_DAO_Contact',
c3fc2621
CW
389 ],
390 'last_modified_date' => [
e501603b
TO
391 'name' => 'last_modified_date',
392 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
c3fc2621 393 'title' => ts('Survey Modified On'),
e501603b 394 'description' => 'Date and time that Survey was edited last time.',
522a26c9 395 'table_name' => 'civicrm_survey',
396 'entity' => 'Survey',
397 'bao' => 'CRM_Campaign_BAO_Survey',
6a7e5e5d 398 'localizable' => 0,
c3fc2621
CW
399 ],
400 'result_id' => [
e501603b
TO
401 'name' => 'result_id',
402 'type' => CRM_Utils_Type::T_INT,
c3fc2621 403 'title' => ts('Survey Result'),
e501603b
TO
404 'description' => 'Used to store option group id.',
405 'default' => 'NULL',
522a26c9 406 'table_name' => 'civicrm_survey',
407 'entity' => 'Survey',
408 'bao' => 'CRM_Campaign_BAO_Survey',
6a7e5e5d 409 'localizable' => 0,
c3fc2621
CW
410 ],
411 'bypass_confirm' => [
e501603b
TO
412 'name' => 'bypass_confirm',
413 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 414 'title' => ts('No Email Verification'),
e501603b 415 'description' => 'Bypass the email verification.',
45a83e42 416 'default' => '0',
522a26c9 417 'table_name' => 'civicrm_survey',
418 'entity' => 'Survey',
419 'bao' => 'CRM_Campaign_BAO_Survey',
6a7e5e5d 420 'localizable' => 0,
c3fc2621
CW
421 ],
422 'thankyou_title' => [
e501603b
TO
423 'name' => 'thankyou_title',
424 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 425 'title' => ts('Thank-you Title'),
e501603b
TO
426 'description' => 'Title for Thank-you page (header title tag, and display at the top of the page).',
427 'maxlength' => 255,
428 'size' => CRM_Utils_Type::HUGE,
522a26c9 429 'table_name' => 'civicrm_survey',
430 'entity' => 'Survey',
431 'bao' => 'CRM_Campaign_BAO_Survey',
6a7e5e5d 432 'localizable' => 1,
c3fc2621
CW
433 ],
434 'thankyou_text' => [
e501603b
TO
435 'name' => 'thankyou_text',
436 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 437 'title' => ts('Thank-you Text'),
e501603b
TO
438 'description' => 'text and html allowed. displayed above result on success page',
439 'rows' => 8,
440 'cols' => 60,
522a26c9 441 'table_name' => 'civicrm_survey',
442 'entity' => 'Survey',
443 'bao' => 'CRM_Campaign_BAO_Survey',
6a7e5e5d 444 'localizable' => 1,
c3fc2621 445 'html' => [
e501603b 446 'type' => 'TextArea',
c3fc2621
CW
447 ],
448 ],
449 'is_share' => [
e501603b
TO
450 'name' => 'is_share',
451 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 452 'title' => ts('Is shared through social media'),
e501603b
TO
453 'description' => 'Can people share the petition through social media?',
454 'default' => '1',
522a26c9 455 'table_name' => 'civicrm_survey',
456 'entity' => 'Survey',
457 'bao' => 'CRM_Campaign_BAO_Survey',
6a7e5e5d 458 'localizable' => 0,
c3fc2621
CW
459 ],
460 ];
346aaaba 461 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 462 }
346aaaba 463 return Civi::$statics[__CLASS__]['fields'];
e501603b 464 }
c3fc2621 465
e501603b 466 /**
bd8e0b14 467 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
468 *
469 * @return array
bd8e0b14 470 * Array(string $name => string $uniqueName).
e501603b 471 */
c3fc2621 472 public static function &fieldKeys() {
bd8e0b14
TO
473 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
474 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 475 }
bd8e0b14 476 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 477 }
c3fc2621 478
e501603b
TO
479 /**
480 * Returns the names of this table
481 *
482 * @return string
483 */
c3fc2621 484 public static function getTableName() {
e501603b
TO
485 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
486 }
c3fc2621 487
e501603b
TO
488 /**
489 * Returns if this table needs to be logged
490 *
c3fc2621 491 * @return bool
e501603b 492 */
c3fc2621 493 public function getLog() {
e501603b
TO
494 return self::$_log;
495 }
c3fc2621 496
e501603b
TO
497 /**
498 * Returns the list of fields that can be imported
499 *
500 * @param bool $prefix
501 *
502 * @return array
503 */
c3fc2621
CW
504 public static function &import($prefix = FALSE) {
505 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'survey', $prefix, []);
60808919 506 return $r;
e501603b 507 }
c3fc2621 508
e501603b
TO
509 /**
510 * Returns the list of fields that can be exported
511 *
512 * @param bool $prefix
513 *
514 * @return array
515 */
c3fc2621
CW
516 public static function &export($prefix = FALSE) {
517 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'survey', $prefix, []);
60808919 518 return $r;
e501603b 519 }
c3fc2621 520
e7a6b91a
AS
521 /**
522 * Returns the list of indices
c3fc2621
CW
523 *
524 * @param bool $localize
525 *
526 * @return array
e7a6b91a
AS
527 */
528 public static function indices($localize = TRUE) {
c3fc2621
CW
529 $indices = [
530 'UI_activity_type_id' => [
e7a6b91a 531 'name' => 'UI_activity_type_id',
c3fc2621 532 'field' => [
e7a6b91a 533 0 => 'activity_type_id',
c3fc2621
CW
534 ],
535 'localizable' => FALSE,
e7a6b91a 536 'sig' => 'civicrm_survey::0::activity_type_id',
c3fc2621
CW
537 ],
538 ];
e7a6b91a
AS
539 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
540 }
c3fc2621 541
e501603b 542}