5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Activity/Activity.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:3724c8dbc64bff361edd263e78780dbe)
13 * Database access object for the Activity entity.
15 class CRM_Activity_DAO_Activity
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '1.1';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_activity';
27 * Icon associated with this entity.
31 public static $_icon = 'fa-tasks';
34 * Field to show when displaying a record.
38 public static $_labelField = 'subject';
41 * Should CiviCRM log any modifications to this table in the civicrm_log table.
45 public static $_log = TRUE;
48 * Paths for accessing this entity in the UI.
52 protected static $_paths = [
53 'add' => 'civicrm/activity?reset=1&action=add&context=standalone',
54 'view' => 'civicrm/activity?reset=1&action=view&id=[id]',
55 'update' => 'civicrm/activity/add?reset=1&action=update&id=[id]',
56 'delete' => 'civicrm/activity?reset=1&action=delete&id=[id]',
60 * Unique Other Activity ID
67 * Artificial FK to original transaction (e.g. contribution) IF it is not an Activity. Table can be figured out through activity_type_id, and further through component registry.
71 public $source_record_id;
74 * FK to civicrm_option_value.id, that has to be valid, registered activity type.
78 public $activity_type_id;
81 * The subject/purpose/short description of the activity.
88 * Date and time this activity is scheduled to occur. Formerly named scheduled_date_time.
92 public $activity_date_time;
95 * Planned or actual duration of activity expressed in minutes. Conglomerate of former duration_hours and duration_minutes.
102 * Location of the activity (optional, open text).
109 * Phone ID of the number called (optional - used if an existing phone number is selected).
116 * Phone number in case the number does not exist in the civicrm_phone table.
120 public $phone_number;
123 * Details about the activity (agenda, notes, etc).
130 * ID of the status this activity is currently in. Foreign key to civicrm_option_value.
137 * ID of the priority given to this activity. Foreign key to civicrm_option_value.
144 * Parent meeting ID (if this is a follow-up item). This is not currently implemented
156 * Activity Medium, Implicit FK to civicrm_option_value where option_group = encounter_medium.
168 * FK to Relationship ID
172 public $relationship_id;
177 public $is_current_revision;
180 * Activity ID of the first activity record in versioning chain.
187 * Currently being used to store result id for survey activity, FK to option value.
199 * The campaign for which this activity has been triggered.
206 * Assign a specific level of engagement to this activity. Used for tracking constituents in ladder of engagement.
210 public $engagement_level;
218 * Activity marked as favorite.
225 * When was the activity was created.
229 public $created_date;
232 * When was the activity (or closely related entity) was created or modified or deleted.
236 public $modified_date;
241 public function __construct() {
242 $this->__table
= 'civicrm_activity';
243 parent
::__construct();
247 * Returns localized title of this entity.
249 * @param bool $plural
250 * Whether to return the plural version of the title.
252 public static function getEntityTitle($plural = FALSE) {
253 return $plural ?
ts('Activities') : ts('Activity');
257 * Returns user-friendly description of this entity.
261 public static function getEntityDescription() {
262 return ts('Past or future actions concerning one or more contacts.');
266 * Returns foreign keys and entity references.
269 * [CRM_Core_Reference_Interface]
271 public static function getReferenceColumns() {
272 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
273 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
274 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'phone_id', 'civicrm_phone', 'id');
275 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'parent_id', 'civicrm_activity', 'id');
276 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'relationship_id', 'civicrm_relationship', 'id');
277 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'original_id', 'civicrm_activity', 'id');
278 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
279 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
281 return Civi
::$statics[__CLASS__
]['links'];
285 * Returns all the column names of this table
289 public static function &fields() {
290 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
291 Civi
::$statics[__CLASS__
]['fields'] = [
294 'type' => CRM_Utils_Type
::T_INT
,
295 'title' => ts('Activity ID'),
296 'description' => ts('Unique Other Activity ID'),
299 'where' => 'civicrm_activity.id',
301 'table_name' => 'civicrm_activity',
302 'entity' => 'Activity',
303 'bao' => 'CRM_Activity_BAO_Activity',
311 'source_record_id' => [
312 'name' => 'source_record_id',
313 'type' => CRM_Utils_Type
::T_INT
,
314 'title' => ts('Source Record'),
315 'description' => ts('Artificial FK to original transaction (e.g. contribution) IF it is not an Activity. Table can be figured out through activity_type_id, and further through component registry.'),
316 'where' => 'civicrm_activity.source_record_id',
317 'table_name' => 'civicrm_activity',
318 'entity' => 'Activity',
319 'bao' => 'CRM_Activity_BAO_Activity',
324 'activity_type_id' => [
325 'name' => 'activity_type_id',
326 'type' => CRM_Utils_Type
::T_INT
,
327 'title' => ts('Activity Type ID'),
328 'description' => ts('FK to civicrm_option_value.id, that has to be valid, registered activity type.'),
331 'where' => 'civicrm_activity.activity_type_id',
332 'headerPattern' => '/(activity.)?type(.id$)/i',
335 'table_name' => 'civicrm_activity',
336 'entity' => 'Activity',
337 'bao' => 'CRM_Activity_BAO_Activity',
341 'label' => ts("Activity Type"),
343 'pseudoconstant' => [
344 'optionGroupName' => 'activity_type',
345 'optionEditPath' => 'civicrm/admin/options/activity_type',
349 'activity_subject' => [
351 'type' => CRM_Utils_Type
::T_STRING
,
352 'title' => ts('Subject'),
353 'description' => ts('The subject/purpose/short description of the activity.'),
355 'size' => CRM_Utils_Type
::HUGE
,
357 'where' => 'civicrm_activity.subject',
358 'headerPattern' => '/(activity.)?subject/i',
360 'table_name' => 'civicrm_activity',
361 'entity' => 'Activity',
362 'bao' => 'CRM_Activity_BAO_Activity',
369 'activity_date_time' => [
370 'name' => 'activity_date_time',
371 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
372 'title' => ts('Activity Date'),
373 'description' => ts('Date and time this activity is scheduled to occur. Formerly named scheduled_date_time.'),
376 'where' => 'civicrm_activity.activity_date_time',
377 'headerPattern' => '/(activity.)?date(.time$)?/i',
379 'default' => 'CURRENT_TIMESTAMP',
380 'table_name' => 'civicrm_activity',
381 'entity' => 'Activity',
382 'bao' => 'CRM_Activity_BAO_Activity',
385 'type' => 'Select Date',
386 'formatType' => 'activityDateTime',
390 'activity_duration' => [
391 'name' => 'duration',
392 'type' => CRM_Utils_Type
::T_INT
,
393 'title' => ts('Duration'),
394 'description' => ts('Planned or actual duration of activity expressed in minutes. Conglomerate of former duration_hours and duration_minutes.'),
396 'where' => 'civicrm_activity.duration',
397 'headerPattern' => '/(activity.)?duration(s)?$/i',
399 'table_name' => 'civicrm_activity',
400 'entity' => 'Activity',
401 'bao' => 'CRM_Activity_BAO_Activity',
408 'activity_location' => [
409 'name' => 'location',
410 'type' => CRM_Utils_Type
::T_STRING
,
411 'title' => ts('Location'),
412 'description' => ts('Location of the activity (optional, open text).'),
414 'size' => CRM_Utils_Type
::HUGE
,
416 'where' => 'civicrm_activity.location',
417 'headerPattern' => '/(activity.)?location$/i',
419 'table_name' => 'civicrm_activity',
420 'entity' => 'Activity',
421 'bao' => 'CRM_Activity_BAO_Activity',
429 'name' => 'phone_id',
430 'type' => CRM_Utils_Type
::T_INT
,
431 'title' => ts('Phone ID (called)'),
432 'description' => ts('Phone ID of the number called (optional - used if an existing phone number is selected).'),
433 'where' => 'civicrm_activity.phone_id',
434 'table_name' => 'civicrm_activity',
435 'entity' => 'Activity',
436 'bao' => 'CRM_Activity_BAO_Activity',
438 'FKClassName' => 'CRM_Core_DAO_Phone',
440 'type' => 'EntityRef',
441 'label' => ts("Phone (called)"),
446 'name' => 'phone_number',
447 'type' => CRM_Utils_Type
::T_STRING
,
448 'title' => ts('Phone (called) Number'),
449 'description' => ts('Phone number in case the number does not exist in the civicrm_phone table.'),
451 'size' => CRM_Utils_Type
::BIG
,
452 'where' => 'civicrm_activity.phone_number',
453 'table_name' => 'civicrm_activity',
454 'entity' => 'Activity',
455 'bao' => 'CRM_Activity_BAO_Activity',
462 'activity_details' => [
464 'type' => CRM_Utils_Type
::T_LONGTEXT
,
465 'title' => ts('Details'),
466 'description' => ts('Details about the activity (agenda, notes, etc).'),
468 'where' => 'civicrm_activity.details',
469 'headerPattern' => '/(activity.)?detail(s)?$/i',
471 'table_name' => 'civicrm_activity',
472 'entity' => 'Activity',
473 'bao' => 'CRM_Activity_BAO_Activity',
476 'type' => 'RichTextEditor',
480 'activity_status_id' => [
481 'name' => 'status_id',
482 'type' => CRM_Utils_Type
::T_INT
,
483 'title' => ts('Activity Status'),
484 'description' => ts('ID of the status this activity is currently in. Foreign key to civicrm_option_value.'),
486 'where' => 'civicrm_activity.status_id',
487 'headerPattern' => '/(activity.)?status(.label$)?/i',
489 'table_name' => 'civicrm_activity',
490 'entity' => 'Activity',
491 'bao' => 'CRM_Activity_BAO_Activity',
496 'pseudoconstant' => [
497 'optionGroupName' => 'activity_status',
498 'optionEditPath' => 'civicrm/admin/options/activity_status',
503 'name' => 'priority_id',
504 'type' => CRM_Utils_Type
::T_INT
,
505 'title' => ts('Priority'),
506 'description' => ts('ID of the priority given to this activity. Foreign key to civicrm_option_value.'),
508 'where' => 'civicrm_activity.priority_id',
510 'table_name' => 'civicrm_activity',
511 'entity' => 'Activity',
512 'bao' => 'CRM_Activity_BAO_Activity',
517 'pseudoconstant' => [
518 'optionGroupName' => 'priority',
519 'optionEditPath' => 'civicrm/admin/options/priority',
524 'name' => 'parent_id',
525 'type' => CRM_Utils_Type
::T_INT
,
526 'title' => ts('Parent Activity ID'),
527 'description' => ts('Parent meeting ID (if this is a follow-up item). This is not currently implemented'),
528 'where' => 'civicrm_activity.parent_id',
529 'table_name' => 'civicrm_activity',
530 'entity' => 'Activity',
531 'bao' => 'CRM_Activity_BAO_Activity',
533 'FKClassName' => 'CRM_Activity_DAO_Activity',
535 'label' => ts("Parent Activity"),
540 'activity_is_test' => [
542 'type' => CRM_Utils_Type
::T_BOOLEAN
,
543 'title' => ts('Test'),
545 'where' => 'civicrm_activity.is_test',
546 'headerPattern' => '/(is.)?test(.activity)?/i',
549 'table_name' => 'civicrm_activity',
550 'entity' => 'Activity',
551 'bao' => 'CRM_Activity_BAO_Activity',
554 'type' => 'CheckBox',
558 'activity_medium_id' => [
559 'name' => 'medium_id',
560 'type' => CRM_Utils_Type
::T_INT
,
561 'title' => ts('Activity Medium'),
562 'description' => ts('Activity Medium, Implicit FK to civicrm_option_value where option_group = encounter_medium.'),
563 'where' => 'civicrm_activity.medium_id',
565 'table_name' => 'civicrm_activity',
566 'entity' => 'Activity',
567 'bao' => 'CRM_Activity_BAO_Activity',
572 'pseudoconstant' => [
573 'optionGroupName' => 'encounter_medium',
574 'optionEditPath' => 'civicrm/admin/options/encounter_medium',
580 'type' => CRM_Utils_Type
::T_BOOLEAN
,
581 'title' => ts('Auto'),
582 'where' => 'civicrm_activity.is_auto',
584 'table_name' => 'civicrm_activity',
585 'entity' => 'Activity',
586 'bao' => 'CRM_Activity_BAO_Activity',
590 'relationship_id' => [
591 'name' => 'relationship_id',
592 'type' => CRM_Utils_Type
::T_INT
,
593 'title' => ts('Relationship ID'),
594 'description' => ts('FK to Relationship ID'),
595 'where' => 'civicrm_activity.relationship_id',
597 'table_name' => 'civicrm_activity',
598 'entity' => 'Activity',
599 'bao' => 'CRM_Activity_BAO_Activity',
601 'FKClassName' => 'CRM_Contact_DAO_Relationship',
603 'label' => ts("Relationship"),
607 'is_current_revision' => [
608 'name' => 'is_current_revision',
609 'type' => CRM_Utils_Type
::T_BOOLEAN
,
610 'title' => ts('Is this activity a current revision in versioning chain?'),
612 'where' => 'civicrm_activity.is_current_revision',
613 'headerPattern' => '/(is.)?(current.)?(revision|version(ing)?)/i',
616 'table_name' => 'civicrm_activity',
617 'entity' => 'Activity',
618 'bao' => 'CRM_Activity_BAO_Activity',
623 'name' => 'original_id',
624 'type' => CRM_Utils_Type
::T_INT
,
625 'title' => ts('Original Activity ID'),
626 'description' => ts('Activity ID of the first activity record in versioning chain.'),
627 'where' => 'civicrm_activity.original_id',
628 'table_name' => 'civicrm_activity',
629 'entity' => 'Activity',
630 'bao' => 'CRM_Activity_BAO_Activity',
632 'FKClassName' => 'CRM_Activity_DAO_Activity',
634 'label' => ts("Original Activity"),
639 'activity_result' => [
641 'type' => CRM_Utils_Type
::T_STRING
,
642 'title' => ts('Result'),
643 'description' => ts('Currently being used to store result id for survey activity, FK to option value.'),
645 'size' => CRM_Utils_Type
::HUGE
,
646 'where' => 'civicrm_activity.result',
647 'table_name' => 'civicrm_activity',
648 'entity' => 'Activity',
649 'bao' => 'CRM_Activity_BAO_Activity',
653 'activity_is_deleted' => [
654 'name' => 'is_deleted',
655 'type' => CRM_Utils_Type
::T_BOOLEAN
,
656 'title' => ts('Activity is in the Trash'),
658 'where' => 'civicrm_activity.is_deleted',
659 'headerPattern' => '/(activity.)?(trash|deleted)/i',
662 'table_name' => 'civicrm_activity',
663 'entity' => 'Activity',
664 'bao' => 'CRM_Activity_BAO_Activity',
667 'type' => 'CheckBox',
671 'activity_campaign_id' => [
672 'name' => 'campaign_id',
673 'type' => CRM_Utils_Type
::T_INT
,
674 'title' => ts('Campaign ID'),
675 'description' => ts('The campaign for which this activity has been triggered.'),
677 'where' => 'civicrm_activity.campaign_id',
679 'table_name' => 'civicrm_activity',
680 'entity' => 'Activity',
681 'bao' => 'CRM_Activity_BAO_Activity',
683 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
684 'component' => 'CiviCampaign',
686 'type' => 'EntityRef',
687 'label' => ts("Campaign"),
691 'activity_engagement_level' => [
692 'name' => 'engagement_level',
693 'type' => CRM_Utils_Type
::T_INT
,
694 'title' => ts('Engagement Index'),
695 'description' => ts('Assign a specific level of engagement to this activity. Used for tracking constituents in ladder of engagement.'),
697 'where' => 'civicrm_activity.engagement_level',
699 'table_name' => 'civicrm_activity',
700 'entity' => 'Activity',
701 'bao' => 'CRM_Activity_BAO_Activity',
706 'pseudoconstant' => [
707 'optionGroupName' => 'engagement_index',
708 'optionEditPath' => 'civicrm/admin/options/engagement_index',
714 'type' => CRM_Utils_Type
::T_INT
,
715 'title' => ts('Order'),
716 'where' => 'civicrm_activity.weight',
717 'table_name' => 'civicrm_activity',
718 'entity' => 'Activity',
719 'bao' => 'CRM_Activity_BAO_Activity',
725 'type' => CRM_Utils_Type
::T_BOOLEAN
,
726 'title' => ts('Is Starred'),
727 'description' => ts('Activity marked as favorite.'),
729 'where' => 'civicrm_activity.is_star',
730 'headerPattern' => '/(activity.)?(star|favorite)/i',
733 'table_name' => 'civicrm_activity',
734 'entity' => 'Activity',
735 'bao' => 'CRM_Activity_BAO_Activity',
738 'type' => 'Checkbox',
742 'activity_created_date' => [
743 'name' => 'created_date',
744 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
745 'title' => ts('Created Date'),
746 'description' => ts('When was the activity was created.'),
748 'where' => 'civicrm_activity.created_date',
750 'default' => 'CURRENT_TIMESTAMP',
751 'table_name' => 'civicrm_activity',
752 'entity' => 'Activity',
753 'bao' => 'CRM_Activity_BAO_Activity',
756 'label' => ts("Created Date"),
760 'activity_modified_date' => [
761 'name' => 'modified_date',
762 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
763 'title' => ts('Modified Date'),
764 'description' => ts('When was the activity (or closely related entity) was created or modified or deleted.'),
766 'where' => 'civicrm_activity.modified_date',
768 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
769 'table_name' => 'civicrm_activity',
770 'entity' => 'Activity',
771 'bao' => 'CRM_Activity_BAO_Activity',
774 'label' => ts("Modified Date"),
780 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
782 return Civi
::$statics[__CLASS__
]['fields'];
786 * Return a mapping from field-name to the corresponding key (as used in fields()).
789 * Array(string $name => string $uniqueName).
791 public static function &fieldKeys() {
792 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
793 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
795 return Civi
::$statics[__CLASS__
]['fieldKeys'];
799 * Returns the names of this table
803 public static function getTableName() {
804 return self
::$_tableName;
808 * Returns if this table needs to be logged
812 public function getLog() {
817 * Returns the list of fields that can be imported
819 * @param bool $prefix
823 public static function &import($prefix = FALSE) {
824 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'activity', $prefix, []);
829 * Returns the list of fields that can be exported
831 * @param bool $prefix
835 public static function &export($prefix = FALSE) {
836 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'activity', $prefix, []);
841 * Returns the list of indices
843 * @param bool $localize
847 public static function indices($localize = TRUE) {
849 'UI_source_record_id' => [
850 'name' => 'UI_source_record_id',
852 0 => 'source_record_id',
854 'localizable' => FALSE,
855 'sig' => 'civicrm_activity::0::source_record_id',
857 'UI_activity_type_id' => [
858 'name' => 'UI_activity_type_id',
860 0 => 'activity_type_id',
862 'localizable' => FALSE,
863 'sig' => 'civicrm_activity::0::activity_type_id',
865 'index_activity_date_time' => [
866 'name' => 'index_activity_date_time',
868 0 => 'activity_date_time',
870 'localizable' => FALSE,
871 'sig' => 'civicrm_activity::0::activity_date_time',
873 'index_status_id' => [
874 'name' => 'index_status_id',
878 'localizable' => FALSE,
879 'sig' => 'civicrm_activity::0::status_id',
881 'index_is_current_revision' => [
882 'name' => 'index_is_current_revision',
884 0 => 'is_current_revision',
886 'localizable' => FALSE,
887 'sig' => 'civicrm_activity::0::is_current_revision',
889 'index_is_deleted' => [
890 'name' => 'index_is_deleted',
894 'localizable' => FALSE,
895 'sig' => 'civicrm_activity::0::is_deleted',
898 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;