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:8fec5a0ffb4667af4f00820de74aa577)
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;
56 * Title of the Survey.
63 * Foreign key to the Campaign.
70 * Implicit FK to civicrm_option_value where option_group = activity_type
74 public $activity_type_id;
77 * Recontact intervals for each status.
81 public $recontact_interval;
84 * Script instructions for volunteers to use for the survey.
91 * Number of days for recurrence of release.
95 public $release_frequency;
98 * Maximum number of contacts to allow for survey.
102 public $max_number_of_contacts;
105 * Default number of contacts to allow for survey.
109 public $default_number_of_contacts;
112 * Is this survey enabled or disabled/cancelled?
119 * Is this default survey?
126 * FK to civicrm_contact, who created this Survey.
133 * Date and time that Survey was created.
137 public $created_date;
140 * FK to civicrm_contact, who recently edited this Survey.
144 public $last_modified_id;
147 * Date and time that Survey was edited last time.
151 public $last_modified_date;
154 * Used to store option group id.
161 * Bypass the email verification.
165 public $bypass_confirm;
168 * Title for Thank-you page (header title tag, and display at the top of the page).
172 public $thankyou_title;
175 * text and html allowed. displayed above result on success page
179 public $thankyou_text;
182 * Can people share the petition through social media?
191 public function __construct() {
192 $this->__table
= 'civicrm_survey';
193 parent
::__construct();
197 * Returns localized title of this entity.
199 * @param bool $plural
200 * Whether to return the plural version of the title.
202 public static function getEntityTitle($plural = FALSE) {
203 return $plural ?
ts('Surveys') : ts('Survey');
207 * Returns foreign keys and entity references.
210 * [CRM_Core_Reference_Interface]
212 public static function getReferenceColumns() {
213 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
214 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
215 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
216 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'created_id', 'civicrm_contact', 'id');
217 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'last_modified_id', 'civicrm_contact', 'id');
218 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
220 return Civi
::$statics[__CLASS__
]['links'];
224 * Returns all the column names of this table
228 public static function &fields() {
229 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
230 Civi
::$statics[__CLASS__
]['fields'] = [
233 'type' => CRM_Utils_Type
::T_INT
,
234 'title' => ts('Survey ID'),
235 'description' => ts('Survey id.'),
237 'where' => 'civicrm_survey.id',
238 'table_name' => 'civicrm_survey',
239 'entity' => 'Survey',
240 'bao' => 'CRM_Campaign_BAO_Survey',
250 'type' => CRM_Utils_Type
::T_STRING
,
251 'title' => ts('Survey Title'),
252 'description' => ts('Title of the Survey.'),
255 'size' => CRM_Utils_Type
::HUGE
,
257 'where' => 'civicrm_survey.title',
259 'table_name' => 'civicrm_survey',
260 'entity' => 'Survey',
261 'bao' => 'CRM_Campaign_BAO_Survey',
266 'name' => 'campaign_id',
267 'type' => CRM_Utils_Type
::T_INT
,
268 'title' => ts('Campaign ID'),
269 'description' => ts('Foreign key to the Campaign.'),
270 'where' => 'civicrm_survey.campaign_id',
272 'table_name' => 'civicrm_survey',
273 'entity' => 'Survey',
274 'bao' => 'CRM_Campaign_BAO_Survey',
276 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
278 'type' => 'EntityRef',
279 'label' => ts("Campaign"),
281 'pseudoconstant' => [
282 'table' => 'civicrm_campaign',
284 'labelColumn' => 'title',
285 'prefetch' => 'FALSE',
289 'activity_type_id' => [
290 'name' => 'activity_type_id',
291 'type' => CRM_Utils_Type
::T_INT
,
292 'title' => ts('Activity Type'),
293 'description' => ts('Implicit FK to civicrm_option_value where option_group = activity_type'),
295 'where' => 'civicrm_survey.activity_type_id',
298 'table_name' => 'civicrm_survey',
299 'entity' => 'Survey',
300 'bao' => 'CRM_Campaign_BAO_Survey',
305 'pseudoconstant' => [
306 'optionGroupName' => 'activity_type',
307 'optionEditPath' => 'civicrm/admin/options/activity_type',
311 'recontact_interval' => [
312 'name' => 'recontact_interval',
313 'type' => CRM_Utils_Type
::T_TEXT
,
314 'title' => ts('Follow up Interval'),
315 'description' => ts('Recontact intervals for each status.'),
318 'where' => 'civicrm_survey.recontact_interval',
319 'table_name' => 'civicrm_survey',
320 'entity' => 'Survey',
321 'bao' => 'CRM_Campaign_BAO_Survey',
324 'type' => 'TextArea',
329 'name' => 'instructions',
330 'type' => CRM_Utils_Type
::T_TEXT
,
331 'title' => ts('Instructions'),
332 'description' => ts('Script instructions for volunteers to use for the survey.'),
335 'where' => 'civicrm_survey.instructions',
336 'table_name' => 'civicrm_survey',
337 'entity' => 'Survey',
338 'bao' => 'CRM_Campaign_BAO_Survey',
341 'type' => 'TextArea',
345 'release_frequency' => [
346 'name' => 'release_frequency',
347 'type' => CRM_Utils_Type
::T_INT
,
348 'title' => ts('Survey Hold Duration'),
349 'description' => ts('Number of days for recurrence of release.'),
350 'where' => 'civicrm_survey.release_frequency',
352 'table_name' => 'civicrm_survey',
353 'entity' => 'Survey',
354 'bao' => 'CRM_Campaign_BAO_Survey',
358 'max_number_of_contacts' => [
359 'name' => 'max_number_of_contacts',
360 'type' => CRM_Utils_Type
::T_INT
,
361 'title' => ts('Maximum number of contacts'),
362 'description' => ts('Maximum number of contacts to allow for survey.'),
363 'where' => 'civicrm_survey.max_number_of_contacts',
365 'table_name' => 'civicrm_survey',
366 'entity' => 'Survey',
367 'bao' => 'CRM_Campaign_BAO_Survey',
371 'default_number_of_contacts' => [
372 'name' => 'default_number_of_contacts',
373 'type' => CRM_Utils_Type
::T_INT
,
374 'title' => ts('Default number of contacts'),
375 'description' => ts('Default number of contacts to allow for survey.'),
376 'where' => 'civicrm_survey.default_number_of_contacts',
378 'table_name' => 'civicrm_survey',
379 'entity' => 'Survey',
380 'bao' => 'CRM_Campaign_BAO_Survey',
385 'name' => 'is_active',
386 'type' => CRM_Utils_Type
::T_BOOLEAN
,
387 'title' => ts('Survey Is Active'),
388 'description' => ts('Is this survey enabled or disabled/cancelled?'),
389 'where' => 'civicrm_survey.is_active',
391 'table_name' => 'civicrm_survey',
392 'entity' => 'Survey',
393 'bao' => 'CRM_Campaign_BAO_Survey',
398 'name' => 'is_default',
399 'type' => CRM_Utils_Type
::T_BOOLEAN
,
400 'title' => ts('Is Default Survey'),
401 'description' => ts('Is this default survey?'),
402 'where' => 'civicrm_survey.is_default',
404 'table_name' => 'civicrm_survey',
405 'entity' => 'Survey',
406 'bao' => 'CRM_Campaign_BAO_Survey',
411 'name' => 'created_id',
412 'type' => CRM_Utils_Type
::T_INT
,
413 'title' => ts('Created By Contact ID'),
414 'description' => ts('FK to civicrm_contact, who created this Survey.'),
415 'where' => 'civicrm_survey.created_id',
416 'table_name' => 'civicrm_survey',
417 'entity' => 'Survey',
418 'bao' => 'CRM_Campaign_BAO_Survey',
420 'FKClassName' => 'CRM_Contact_DAO_Contact',
422 'label' => ts("Created By"),
427 'name' => 'created_date',
428 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
429 'title' => ts('Campaign Created Date'),
430 'description' => ts('Date and time that Survey was created.'),
431 'where' => 'civicrm_survey.created_date',
432 'table_name' => 'civicrm_survey',
433 'entity' => 'Survey',
434 'bao' => 'CRM_Campaign_BAO_Survey',
438 'last_modified_id' => [
439 'name' => 'last_modified_id',
440 'type' => CRM_Utils_Type
::T_INT
,
441 'title' => ts('Modified By Contact ID'),
442 'description' => ts('FK to civicrm_contact, who recently edited this Survey.'),
443 'where' => 'civicrm_survey.last_modified_id',
444 'table_name' => 'civicrm_survey',
445 'entity' => 'Survey',
446 'bao' => 'CRM_Campaign_BAO_Survey',
448 'FKClassName' => 'CRM_Contact_DAO_Contact',
450 'label' => ts("Modified By"),
454 'last_modified_date' => [
455 'name' => 'last_modified_date',
456 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
457 'title' => ts('Survey Modified On'),
458 'description' => ts('Date and time that Survey was edited last time.'),
459 'where' => 'civicrm_survey.last_modified_date',
460 'table_name' => 'civicrm_survey',
461 'entity' => 'Survey',
462 'bao' => 'CRM_Campaign_BAO_Survey',
467 'name' => 'result_id',
468 'type' => CRM_Utils_Type
::T_INT
,
469 'title' => ts('Survey Result'),
470 'description' => ts('Used to store option group id.'),
471 'where' => 'civicrm_survey.result_id',
473 'table_name' => 'civicrm_survey',
474 'entity' => 'Survey',
475 'bao' => 'CRM_Campaign_BAO_Survey',
477 'pseudoconstant' => [
478 'table' => 'civicrm_option_group',
480 'labelColumn' => 'title',
481 'nameColumn' => 'name',
482 'condition' => 'name LIKE "civicrm_survey_%"',
486 'bypass_confirm' => [
487 'name' => 'bypass_confirm',
488 'type' => CRM_Utils_Type
::T_BOOLEAN
,
489 'title' => ts('No Email Verification'),
490 'description' => ts('Bypass the email verification.'),
491 'where' => 'civicrm_survey.bypass_confirm',
493 'table_name' => 'civicrm_survey',
494 'entity' => 'Survey',
495 'bao' => 'CRM_Campaign_BAO_Survey',
499 'thankyou_title' => [
500 'name' => 'thankyou_title',
501 'type' => CRM_Utils_Type
::T_STRING
,
502 'title' => ts('Thank-you Title'),
503 'description' => ts('Title for Thank-you page (header title tag, and display at the top of the page).'),
505 'size' => CRM_Utils_Type
::HUGE
,
506 'where' => 'civicrm_survey.thankyou_title',
507 'table_name' => 'civicrm_survey',
508 'entity' => 'Survey',
509 'bao' => 'CRM_Campaign_BAO_Survey',
514 'name' => 'thankyou_text',
515 'type' => CRM_Utils_Type
::T_TEXT
,
516 'title' => ts('Thank-you Text'),
517 'description' => ts('text and html allowed. displayed above result on success page'),
520 'where' => 'civicrm_survey.thankyou_text',
521 'table_name' => 'civicrm_survey',
522 'entity' => 'Survey',
523 'bao' => 'CRM_Campaign_BAO_Survey',
526 'type' => 'TextArea',
531 'name' => 'is_share',
532 'type' => CRM_Utils_Type
::T_BOOLEAN
,
533 'title' => ts('Is shared through social media'),
534 'description' => ts('Can people share the petition through social media?'),
535 'where' => 'civicrm_survey.is_share',
537 'table_name' => 'civicrm_survey',
538 'entity' => 'Survey',
539 'bao' => 'CRM_Campaign_BAO_Survey',
544 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
546 return Civi
::$statics[__CLASS__
]['fields'];
550 * Return a mapping from field-name to the corresponding key (as used in fields()).
553 * Array(string $name => string $uniqueName).
555 public static function &fieldKeys() {
556 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
557 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
559 return Civi
::$statics[__CLASS__
]['fieldKeys'];
563 * Returns the names of this table
567 public static function getTableName() {
568 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
572 * Returns if this table needs to be logged
576 public function getLog() {
581 * Returns the list of fields that can be imported
583 * @param bool $prefix
587 public static function &import($prefix = FALSE) {
588 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'survey', $prefix, []);
593 * Returns the list of fields that can be exported
595 * @param bool $prefix
599 public static function &export($prefix = FALSE) {
600 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'survey', $prefix, []);
605 * Returns the list of indices
607 * @param bool $localize
611 public static function indices($localize = TRUE) {
613 'UI_activity_type_id' => [
614 'name' => 'UI_activity_type_id',
616 0 => 'activity_type_id',
618 'localizable' => FALSE,
619 'sig' => 'civicrm_survey::0::activity_type_id',
622 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;