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