5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Campaign/Survey.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:d0bc187a5dd2297f5c81a7a84460fc17)
13 * Database access object for the Survey entity.
15 class CRM_Campaign_DAO_Survey
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '3.2';
18 const COMPONENT
= 'CiviCampaign';
21 * Static instance to hold the table name.
25 public static $_tableName = 'civicrm_survey';
28 * Icon associated with this entity.
32 public static $_icon = 'fa-clipboard';
35 * Field to show when displaying a record.
39 public static $_labelField = 'title';
42 * Should CiviCRM log any modifications to this table in the civicrm_log table.
46 public static $_log = FALSE;
51 * @var int|string|null
52 * (SQL type: int unsigned)
53 * Note that values will be retrieved from the database as a string.
58 * Title of the Survey.
61 * (SQL type: varchar(255))
62 * Note that values will be retrieved from the database as a string.
67 * Foreign key to the Campaign.
69 * @var int|string|null
70 * (SQL type: int unsigned)
71 * Note that values will be retrieved from the database as a string.
76 * Implicit FK to civicrm_option_value where option_group = activity_type
78 * @var int|string|null
79 * (SQL type: int unsigned)
80 * Note that values will be retrieved from the database as a string.
82 public $activity_type_id;
85 * Recontact intervals for each status.
89 * Note that values will be retrieved from the database as a string.
91 public $recontact_interval;
94 * Script instructions for volunteers to use for the survey.
98 * Note that values will be retrieved from the database as a string.
100 public $instructions;
103 * Number of days for recurrence of release.
105 * @var int|string|null
106 * (SQL type: int unsigned)
107 * Note that values will be retrieved from the database as a string.
109 public $release_frequency;
112 * Maximum number of contacts to allow for survey.
114 * @var int|string|null
115 * (SQL type: int unsigned)
116 * Note that values will be retrieved from the database as a string.
118 public $max_number_of_contacts;
121 * Default number of contacts to allow for survey.
123 * @var int|string|null
124 * (SQL type: int unsigned)
125 * Note that values will be retrieved from the database as a string.
127 public $default_number_of_contacts;
130 * Is this survey enabled or disabled/cancelled?
132 * @var bool|string|null
133 * (SQL type: tinyint)
134 * Note that values will be retrieved from the database as a string.
139 * Is this default survey?
141 * @var bool|string|null
142 * (SQL type: tinyint)
143 * Note that values will be retrieved from the database as a string.
148 * FK to civicrm_contact, who created this Survey.
150 * @var int|string|null
151 * (SQL type: int unsigned)
152 * Note that values will be retrieved from the database as a string.
157 * Date and time that Survey was created.
160 * (SQL type: datetime)
161 * Note that values will be retrieved from the database as a string.
163 public $created_date;
166 * FK to civicrm_contact, who recently edited this Survey.
168 * @var int|string|null
169 * (SQL type: int unsigned)
170 * Note that values will be retrieved from the database as a string.
172 public $last_modified_id;
175 * Date and time that Survey was edited last time.
178 * (SQL type: datetime)
179 * Note that values will be retrieved from the database as a string.
181 public $last_modified_date;
184 * Used to store option group id.
186 * @var int|string|null
187 * (SQL type: int unsigned)
188 * Note that values will be retrieved from the database as a string.
193 * Bypass the email verification.
195 * @var bool|string|null
196 * (SQL type: tinyint)
197 * Note that values will be retrieved from the database as a string.
199 public $bypass_confirm;
202 * Title for Thank-you page (header title tag, and display at the top of the page).
205 * (SQL type: varchar(255))
206 * Note that values will be retrieved from the database as a string.
208 public $thankyou_title;
211 * text and html allowed. displayed above result on success page
215 * Note that values will be retrieved from the database as a string.
217 public $thankyou_text;
220 * Can people share the petition through social media?
222 * @var bool|string|null
223 * (SQL type: tinyint)
224 * Note that values will be retrieved from the database as a string.
231 public function __construct() {
232 $this->__table
= 'civicrm_survey';
233 parent
::__construct();
237 * Returns localized title of this entity.
239 * @param bool $plural
240 * Whether to return the plural version of the title.
242 public static function getEntityTitle($plural = FALSE) {
243 return $plural ?
ts('Surveys') : ts('Survey');
247 * Returns foreign keys and entity references.
250 * [CRM_Core_Reference_Interface]
252 public static function getReferenceColumns() {
253 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
254 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
255 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
256 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'created_id', 'civicrm_contact', 'id');
257 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'last_modified_id', 'civicrm_contact', 'id');
258 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
260 return Civi
::$statics[__CLASS__
]['links'];
264 * Returns all the column names of this table
268 public static function &fields() {
269 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
270 Civi
::$statics[__CLASS__
]['fields'] = [
273 'type' => CRM_Utils_Type
::T_INT
,
274 'title' => ts('Survey ID'),
275 'description' => ts('Survey id.'),
277 'where' => 'civicrm_survey.id',
278 'table_name' => 'civicrm_survey',
279 'entity' => 'Survey',
280 'bao' => 'CRM_Campaign_BAO_Survey',
290 'type' => CRM_Utils_Type
::T_STRING
,
291 'title' => ts('Survey Title'),
292 'description' => ts('Title of the Survey.'),
295 'size' => CRM_Utils_Type
::HUGE
,
297 'where' => 'civicrm_survey.title',
299 'table_name' => 'civicrm_survey',
300 'entity' => 'Survey',
301 'bao' => 'CRM_Campaign_BAO_Survey',
306 'name' => 'campaign_id',
307 'type' => CRM_Utils_Type
::T_INT
,
308 'title' => ts('Campaign ID'),
309 'description' => ts('Foreign key to the Campaign.'),
310 'where' => 'civicrm_survey.campaign_id',
312 'table_name' => 'civicrm_survey',
313 'entity' => 'Survey',
314 'bao' => 'CRM_Campaign_BAO_Survey',
316 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
318 'type' => 'EntityRef',
319 'label' => ts("Campaign"),
321 'pseudoconstant' => [
322 'table' => 'civicrm_campaign',
324 'labelColumn' => 'title',
325 'prefetch' => 'FALSE',
329 'activity_type_id' => [
330 'name' => 'activity_type_id',
331 'type' => CRM_Utils_Type
::T_INT
,
332 'title' => ts('Activity Type'),
333 'description' => ts('Implicit FK to civicrm_option_value where option_group = activity_type'),
335 'where' => 'civicrm_survey.activity_type_id',
338 'table_name' => 'civicrm_survey',
339 'entity' => 'Survey',
340 'bao' => 'CRM_Campaign_BAO_Survey',
345 'pseudoconstant' => [
346 'optionGroupName' => 'activity_type',
347 'optionEditPath' => 'civicrm/admin/options/activity_type',
351 'recontact_interval' => [
352 'name' => 'recontact_interval',
353 'type' => CRM_Utils_Type
::T_TEXT
,
354 'title' => ts('Follow up Interval'),
355 'description' => ts('Recontact intervals for each status.'),
358 'where' => 'civicrm_survey.recontact_interval',
359 'table_name' => 'civicrm_survey',
360 'entity' => 'Survey',
361 'bao' => 'CRM_Campaign_BAO_Survey',
364 'type' => 'TextArea',
369 'name' => 'instructions',
370 'type' => CRM_Utils_Type
::T_TEXT
,
371 'title' => ts('Instructions'),
372 'description' => ts('Script instructions for volunteers to use for the survey.'),
375 'where' => 'civicrm_survey.instructions',
376 'table_name' => 'civicrm_survey',
377 'entity' => 'Survey',
378 'bao' => 'CRM_Campaign_BAO_Survey',
381 'type' => 'TextArea',
385 'release_frequency' => [
386 'name' => 'release_frequency',
387 'type' => CRM_Utils_Type
::T_INT
,
388 'title' => ts('Survey Hold Duration'),
389 'description' => ts('Number of days for recurrence of release.'),
390 'where' => 'civicrm_survey.release_frequency',
392 'table_name' => 'civicrm_survey',
393 'entity' => 'Survey',
394 'bao' => 'CRM_Campaign_BAO_Survey',
398 'max_number_of_contacts' => [
399 'name' => 'max_number_of_contacts',
400 'type' => CRM_Utils_Type
::T_INT
,
401 'title' => ts('Maximum number of contacts'),
402 'description' => ts('Maximum number of contacts to allow for survey.'),
403 'where' => 'civicrm_survey.max_number_of_contacts',
405 'table_name' => 'civicrm_survey',
406 'entity' => 'Survey',
407 'bao' => 'CRM_Campaign_BAO_Survey',
411 'default_number_of_contacts' => [
412 'name' => 'default_number_of_contacts',
413 'type' => CRM_Utils_Type
::T_INT
,
414 'title' => ts('Default number of contacts'),
415 'description' => ts('Default number of contacts to allow for survey.'),
416 'where' => 'civicrm_survey.default_number_of_contacts',
418 'table_name' => 'civicrm_survey',
419 'entity' => 'Survey',
420 'bao' => 'CRM_Campaign_BAO_Survey',
425 'name' => 'is_active',
426 'type' => CRM_Utils_Type
::T_BOOLEAN
,
427 'title' => ts('Survey Is Active'),
428 'description' => ts('Is this survey enabled or disabled/cancelled?'),
429 'where' => 'civicrm_survey.is_active',
431 'table_name' => 'civicrm_survey',
432 'entity' => 'Survey',
433 'bao' => 'CRM_Campaign_BAO_Survey',
438 'name' => 'is_default',
439 'type' => CRM_Utils_Type
::T_BOOLEAN
,
440 'title' => ts('Is Default Survey'),
441 'description' => ts('Is this default survey?'),
442 'where' => 'civicrm_survey.is_default',
444 'table_name' => 'civicrm_survey',
445 'entity' => 'Survey',
446 'bao' => 'CRM_Campaign_BAO_Survey',
451 'name' => 'created_id',
452 'type' => CRM_Utils_Type
::T_INT
,
453 'title' => ts('Created By Contact ID'),
454 'description' => ts('FK to civicrm_contact, who created this Survey.'),
455 'where' => 'civicrm_survey.created_id',
456 'table_name' => 'civicrm_survey',
457 'entity' => 'Survey',
458 'bao' => 'CRM_Campaign_BAO_Survey',
460 'FKClassName' => 'CRM_Contact_DAO_Contact',
462 'label' => ts("Created By"),
467 'name' => 'created_date',
468 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
469 'title' => ts('Campaign Created Date'),
470 'description' => ts('Date and time that Survey was created.'),
471 'where' => 'civicrm_survey.created_date',
472 'table_name' => 'civicrm_survey',
473 'entity' => 'Survey',
474 'bao' => 'CRM_Campaign_BAO_Survey',
478 'last_modified_id' => [
479 'name' => 'last_modified_id',
480 'type' => CRM_Utils_Type
::T_INT
,
481 'title' => ts('Modified By Contact ID'),
482 'description' => ts('FK to civicrm_contact, who recently edited this Survey.'),
483 'where' => 'civicrm_survey.last_modified_id',
484 'table_name' => 'civicrm_survey',
485 'entity' => 'Survey',
486 'bao' => 'CRM_Campaign_BAO_Survey',
488 'FKClassName' => 'CRM_Contact_DAO_Contact',
490 'label' => ts("Modified By"),
494 'last_modified_date' => [
495 'name' => 'last_modified_date',
496 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
497 'title' => ts('Survey Modified On'),
498 'description' => ts('Date and time that Survey was edited last time.'),
499 'where' => 'civicrm_survey.last_modified_date',
500 'table_name' => 'civicrm_survey',
501 'entity' => 'Survey',
502 'bao' => 'CRM_Campaign_BAO_Survey',
507 'name' => 'result_id',
508 'type' => CRM_Utils_Type
::T_INT
,
509 'title' => ts('Survey Result'),
510 'description' => ts('Used to store option group id.'),
511 'where' => 'civicrm_survey.result_id',
513 'table_name' => 'civicrm_survey',
514 'entity' => 'Survey',
515 'bao' => 'CRM_Campaign_BAO_Survey',
517 'pseudoconstant' => [
518 'table' => 'civicrm_option_group',
520 'labelColumn' => 'title',
521 'nameColumn' => 'name',
522 'condition' => 'name LIKE "civicrm_survey_%"',
526 'bypass_confirm' => [
527 'name' => 'bypass_confirm',
528 'type' => CRM_Utils_Type
::T_BOOLEAN
,
529 'title' => ts('No Email Verification'),
530 'description' => ts('Bypass the email verification.'),
531 'where' => 'civicrm_survey.bypass_confirm',
533 'table_name' => 'civicrm_survey',
534 'entity' => 'Survey',
535 'bao' => 'CRM_Campaign_BAO_Survey',
539 'thankyou_title' => [
540 'name' => 'thankyou_title',
541 'type' => CRM_Utils_Type
::T_STRING
,
542 'title' => ts('Thank-you Title'),
543 'description' => ts('Title for Thank-you page (header title tag, and display at the top of the page).'),
545 'size' => CRM_Utils_Type
::HUGE
,
546 'where' => 'civicrm_survey.thankyou_title',
547 'table_name' => 'civicrm_survey',
548 'entity' => 'Survey',
549 'bao' => 'CRM_Campaign_BAO_Survey',
554 'name' => 'thankyou_text',
555 'type' => CRM_Utils_Type
::T_TEXT
,
556 'title' => ts('Thank-you Text'),
557 'description' => ts('text and html allowed. displayed above result on success page'),
560 'where' => 'civicrm_survey.thankyou_text',
561 'table_name' => 'civicrm_survey',
562 'entity' => 'Survey',
563 'bao' => 'CRM_Campaign_BAO_Survey',
566 'type' => 'TextArea',
571 'name' => 'is_share',
572 'type' => CRM_Utils_Type
::T_BOOLEAN
,
573 'title' => ts('Is shared through social media'),
574 'description' => ts('Can people share the petition through social media?'),
575 'where' => 'civicrm_survey.is_share',
577 'table_name' => 'civicrm_survey',
578 'entity' => 'Survey',
579 'bao' => 'CRM_Campaign_BAO_Survey',
584 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
586 return Civi
::$statics[__CLASS__
]['fields'];
590 * Return a mapping from field-name to the corresponding key (as used in fields()).
593 * Array(string $name => string $uniqueName).
595 public static function &fieldKeys() {
596 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
597 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
599 return Civi
::$statics[__CLASS__
]['fieldKeys'];
603 * Returns the names of this table
607 public static function getTableName() {
608 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
612 * Returns if this table needs to be logged
616 public function getLog() {
621 * Returns the list of fields that can be imported
623 * @param bool $prefix
627 public static function &import($prefix = FALSE) {
628 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'survey', $prefix, []);
633 * Returns the list of fields that can be exported
635 * @param bool $prefix
639 public static function &export($prefix = FALSE) {
640 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'survey', $prefix, []);
645 * Returns the list of indices
647 * @param bool $localize
651 public static function indices($localize = TRUE) {
653 'UI_activity_type_id' => [
654 'name' => 'UI_activity_type_id',
656 0 => 'activity_type_id',
658 'localizable' => FALSE,
659 'sig' => 'civicrm_survey::0::activity_type_id',
662 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;