Merge pull request #19508 from mattwire/loadmemlineitems
[civicrm-core.git] / CRM / Activity / DAO / Activity.php
CommitLineData
e501603b 1<?php
c3fc2621 2
e501603b
TO
3/**
4 * @package CRM
ca5cec67 5 * @copyright CiviCRM LLC https://civicrm.org/licensing
e501603b
TO
6 *
7 * Generated from xml/schema/CRM/Activity/Activity.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
83225dce 9 * (GenCodeChecksum:e40c263d7d030dc0c6d6e714317a3970)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the Activity entity.
f41f0342 14 */
e501603b 15class CRM_Activity_DAO_Activity extends CRM_Core_DAO {
929a1c14
CW
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.1';
c3fc2621 18
e501603b 19 /**
f41f0342 20 * Static instance to hold the table name.
e501603b
TO
21 *
22 * @var string
23 */
fa45b5b9 24 public static $_tableName = 'civicrm_activity';
c3fc2621 25
449c4e6b
CW
26 /**
27 * Icon associated with this entity.
28 *
29 * @var string
30 */
31 public static $_icon = 'fa-tasks';
32
8ab43c93
CW
33 /**
34 * Field to show when displaying a record.
35 *
36 * @var string
37 */
38 public static $_labelField = 'subject';
39
e501603b 40 /**
f41f0342 41 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b 42 *
c3fc2621 43 * @var bool
e501603b 44 */
fa45b5b9 45 public static $_log = TRUE;
c3fc2621 46
a7bd99ff
CW
47 /**
48 * Paths for accessing this entity in the UI.
49 *
50 * @var string[]
51 */
52 protected static $_paths = [
5c385299 53 'add' => 'civicrm/activity?reset=1&action=add&context=standalone',
a7bd99ff 54 'view' => 'civicrm/activity?reset=1&action=view&id=[id]',
5c385299 55 'update' => 'civicrm/activity/add?reset=1&action=update&id=[id]',
a7bd99ff
CW
56 'delete' => 'civicrm/activity?reset=1&action=delete&id=[id]',
57 ];
58
e501603b
TO
59 /**
60 * Unique Other Activity ID
61 *
e6ca0a57 62 * @var int
e501603b
TO
63 */
64 public $id;
c3fc2621 65
e501603b
TO
66 /**
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.
68 *
e6ca0a57 69 * @var int
e501603b
TO
70 */
71 public $source_record_id;
c3fc2621 72
e501603b
TO
73 /**
74 * FK to civicrm_option_value.id, that has to be valid, registered activity type.
75 *
e6ca0a57 76 * @var int
e501603b
TO
77 */
78 public $activity_type_id;
c3fc2621 79
e501603b
TO
80 /**
81 * The subject/purpose/short description of the activity.
82 *
83 * @var string
84 */
85 public $subject;
c3fc2621 86
e501603b
TO
87 /**
88 * Date and time this activity is scheduled to occur. Formerly named scheduled_date_time.
89 *
90 * @var datetime
91 */
92 public $activity_date_time;
c3fc2621 93
e501603b
TO
94 /**
95 * Planned or actual duration of activity expressed in minutes. Conglomerate of former duration_hours and duration_minutes.
96 *
e6ca0a57 97 * @var int
e501603b
TO
98 */
99 public $duration;
c3fc2621 100
e501603b
TO
101 /**
102 * Location of the activity (optional, open text).
103 *
104 * @var string
105 */
106 public $location;
c3fc2621 107
e501603b
TO
108 /**
109 * Phone ID of the number called (optional - used if an existing phone number is selected).
110 *
e6ca0a57 111 * @var int
e501603b
TO
112 */
113 public $phone_id;
c3fc2621 114
e501603b
TO
115 /**
116 * Phone number in case the number does not exist in the civicrm_phone table.
117 *
118 * @var string
119 */
120 public $phone_number;
c3fc2621 121
e501603b
TO
122 /**
123 * Details about the activity (agenda, notes, etc).
124 *
125 * @var longtext
126 */
127 public $details;
c3fc2621 128
e501603b
TO
129 /**
130 * ID of the status this activity is currently in. Foreign key to civicrm_option_value.
131 *
e6ca0a57 132 * @var int
e501603b
TO
133 */
134 public $status_id;
c3fc2621 135
e501603b
TO
136 /**
137 * ID of the priority given to this activity. Foreign key to civicrm_option_value.
138 *
e6ca0a57 139 * @var int
e501603b
TO
140 */
141 public $priority_id;
c3fc2621 142
e501603b
TO
143 /**
144 * Parent meeting ID (if this is a follow-up item). This is not currently implemented
145 *
e6ca0a57 146 * @var int
e501603b
TO
147 */
148 public $parent_id;
c3fc2621 149
e501603b 150 /**
e6ca0a57 151 * @var bool
e501603b
TO
152 */
153 public $is_test;
c3fc2621 154
e501603b
TO
155 /**
156 * Activity Medium, Implicit FK to civicrm_option_value where option_group = encounter_medium.
157 *
e6ca0a57 158 * @var int
e501603b
TO
159 */
160 public $medium_id;
c3fc2621 161
e501603b 162 /**
e6ca0a57 163 * @var bool
e501603b
TO
164 */
165 public $is_auto;
c3fc2621 166
e501603b
TO
167 /**
168 * FK to Relationship ID
169 *
e6ca0a57 170 * @var int
e501603b
TO
171 */
172 public $relationship_id;
c3fc2621 173
e501603b 174 /**
e6ca0a57 175 * @var bool
e501603b
TO
176 */
177 public $is_current_revision;
c3fc2621 178
e501603b
TO
179 /**
180 * Activity ID of the first activity record in versioning chain.
181 *
e6ca0a57 182 * @var int
e501603b
TO
183 */
184 public $original_id;
c3fc2621 185
e501603b
TO
186 /**
187 * Currently being used to store result id for survey activity, FK to option value.
188 *
189 * @var string
190 */
191 public $result;
c3fc2621 192
e501603b 193 /**
e6ca0a57 194 * @var bool
e501603b
TO
195 */
196 public $is_deleted;
c3fc2621 197
e501603b
TO
198 /**
199 * The campaign for which this activity has been triggered.
200 *
e6ca0a57 201 * @var int
e501603b
TO
202 */
203 public $campaign_id;
c3fc2621 204
e501603b
TO
205 /**
206 * Assign a specific level of engagement to this activity. Used for tracking constituents in ladder of engagement.
207 *
e6ca0a57 208 * @var int
e501603b
TO
209 */
210 public $engagement_level;
c3fc2621 211
e501603b 212 /**
e501603b
TO
213 * @var int
214 */
215 public $weight;
c3fc2621 216
cd063b10
CW
217 /**
218 * Activity marked as favorite.
219 *
e6ca0a57 220 * @var bool
cd063b10
CW
221 */
222 public $is_star;
c3fc2621 223
3ed77291
TO
224 /**
225 * When was the activity was created.
226 *
227 * @var timestamp
228 */
229 public $created_date;
c3fc2621 230
3ed77291
TO
231 /**
232 * When was the activity (or closely related entity) was created or modified or deleted.
233 *
234 * @var timestamp
235 */
236 public $modified_date;
c3fc2621 237
e501603b 238 /**
f41f0342 239 * Class constructor.
e501603b 240 */
c3fc2621 241 public function __construct() {
e501603b
TO
242 $this->__table = 'civicrm_activity';
243 parent::__construct();
244 }
c3fc2621 245
449c4e6b
CW
246 /**
247 * Returns localized title of this entity.
7b66c3b5
AH
248 *
249 * @param bool $plural
250 * Whether to return the plural version of the title.
449c4e6b 251 */
7b66c3b5
AH
252 public static function getEntityTitle($plural = FALSE) {
253 return $plural ? ts('Activities') : ts('Activity');
449c4e6b
CW
254 }
255
e501603b 256 /**
f41f0342 257 * Returns foreign keys and entity references.
e501603b
TO
258 *
259 * @return array
260 * [CRM_Core_Reference_Interface]
261 */
c3fc2621 262 public static function getReferenceColumns() {
346aaaba 263 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 264 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621
CW
265 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'phone_id', 'civicrm_phone', 'id');
266 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'parent_id', 'civicrm_activity', 'id');
267 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'relationship_id', 'civicrm_relationship', 'id');
268 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'original_id', 'civicrm_activity', 'id');
269 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
346aaaba 270 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 271 }
346aaaba 272 return Civi::$statics[__CLASS__]['links'];
e501603b 273 }
c3fc2621 274
e501603b
TO
275 /**
276 * Returns all the column names of this table
277 *
278 * @return array
279 */
c3fc2621 280 public static function &fields() {
346aaaba 281 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
282 Civi::$statics[__CLASS__]['fields'] = [
283 'activity_id' => [
e501603b
TO
284 'name' => 'id',
285 'type' => CRM_Utils_Type::T_INT,
c3fc2621 286 'title' => ts('Activity ID'),
215b423e 287 'description' => ts('Unique Other Activity ID'),
c3fc2621
CW
288 'required' => TRUE,
289 'import' => TRUE,
e501603b 290 'where' => 'civicrm_activity.id',
c3fc2621 291 'export' => TRUE,
522a26c9 292 'table_name' => 'civicrm_activity',
293 'entity' => 'Activity',
294 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 295 'localizable' => 0,
a9d0587b 296 'add' => '1.1',
c3fc2621
CW
297 ],
298 'source_record_id' => [
e501603b
TO
299 'name' => 'source_record_id',
300 'type' => CRM_Utils_Type::T_INT,
c3fc2621 301 'title' => ts('Source Record'),
215b423e 302 '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.'),
a36434b9 303 'where' => 'civicrm_activity.source_record_id',
522a26c9 304 'table_name' => 'civicrm_activity',
305 'entity' => 'Activity',
306 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 307 'localizable' => 0,
a9d0587b 308 'add' => '2.0',
c3fc2621
CW
309 ],
310 'activity_type_id' => [
e501603b
TO
311 'name' => 'activity_type_id',
312 'type' => CRM_Utils_Type::T_INT,
a1d226d6 313 'title' => ts('Activity Type ID'),
215b423e 314 'description' => ts('FK to civicrm_option_value.id, that has to be valid, registered activity type.'),
c3fc2621
CW
315 'required' => TRUE,
316 'import' => TRUE,
e501603b
TO
317 'where' => 'civicrm_activity.activity_type_id',
318 'headerPattern' => '/(activity.)?type(.id$)/i',
c3fc2621 319 'export' => TRUE,
e501603b 320 'default' => '1',
522a26c9 321 'table_name' => 'civicrm_activity',
322 'entity' => 'Activity',
323 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 324 'localizable' => 0,
c3fc2621 325 'html' => [
e501603b 326 'type' => 'Select',
a1d226d6 327 'label' => ts("Activity Type"),
c3fc2621
CW
328 ],
329 'pseudoconstant' => [
e501603b
TO
330 'optionGroupName' => 'activity_type',
331 'optionEditPath' => 'civicrm/admin/options/activity_type',
e6ca0a57 332 ],
a9d0587b 333 'add' => '1.1',
c3fc2621
CW
334 ],
335 'activity_subject' => [
e501603b
TO
336 'name' => 'subject',
337 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 338 'title' => ts('Subject'),
215b423e 339 'description' => ts('The subject/purpose/short description of the activity.'),
e501603b
TO
340 'maxlength' => 255,
341 'size' => CRM_Utils_Type::HUGE,
c3fc2621 342 'import' => TRUE,
e501603b
TO
343 'where' => 'civicrm_activity.subject',
344 'headerPattern' => '/(activity.)?subject/i',
c3fc2621 345 'export' => TRUE,
522a26c9 346 'table_name' => 'civicrm_activity',
347 'entity' => 'Activity',
348 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 349 'localizable' => 0,
c3fc2621 350 'html' => [
e501603b 351 'type' => 'Text',
c3fc2621 352 ],
a9d0587b 353 'add' => '1.1',
c3fc2621
CW
354 ],
355 'activity_date_time' => [
e501603b
TO
356 'name' => 'activity_date_time',
357 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
c3fc2621 358 'title' => ts('Activity Date'),
215b423e 359 'description' => ts('Date and time this activity is scheduled to occur. Formerly named scheduled_date_time.'),
487813ab 360 'required' => FALSE,
c3fc2621 361 'import' => TRUE,
e501603b
TO
362 'where' => 'civicrm_activity.activity_date_time',
363 'headerPattern' => '/(activity.)?date(.time$)?/i',
c3fc2621 364 'export' => TRUE,
487813ab 365 'default' => 'CURRENT_TIMESTAMP',
522a26c9 366 'table_name' => 'civicrm_activity',
367 'entity' => 'Activity',
368 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 369 'localizable' => 0,
c3fc2621 370 'html' => [
e501603b 371 'type' => 'Select Date',
24317d89 372 'formatType' => 'activityDateTime',
c3fc2621 373 ],
a9d0587b 374 'add' => '2.0',
c3fc2621
CW
375 ],
376 'activity_duration' => [
e501603b
TO
377 'name' => 'duration',
378 'type' => CRM_Utils_Type::T_INT,
c3fc2621 379 'title' => ts('Duration'),
215b423e 380 'description' => ts('Planned or actual duration of activity expressed in minutes. Conglomerate of former duration_hours and duration_minutes.'),
c3fc2621 381 'import' => TRUE,
e501603b
TO
382 'where' => 'civicrm_activity.duration',
383 'headerPattern' => '/(activity.)?duration(s)?$/i',
c3fc2621 384 'export' => TRUE,
522a26c9 385 'table_name' => 'civicrm_activity',
386 'entity' => 'Activity',
387 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 388 'localizable' => 0,
c3fc2621 389 'html' => [
3542118f 390 'type' => 'Number',
c3fc2621 391 ],
a9d0587b 392 'add' => '2.0',
c3fc2621
CW
393 ],
394 'activity_location' => [
e501603b
TO
395 'name' => 'location',
396 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 397 'title' => ts('Location'),
215b423e 398 'description' => ts('Location of the activity (optional, open text).'),
e501603b
TO
399 'maxlength' => 255,
400 'size' => CRM_Utils_Type::HUGE,
c3fc2621 401 'import' => TRUE,
e501603b
TO
402 'where' => 'civicrm_activity.location',
403 'headerPattern' => '/(activity.)?location$/i',
c3fc2621 404 'export' => TRUE,
522a26c9 405 'table_name' => 'civicrm_activity',
406 'entity' => 'Activity',
407 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 408 'localizable' => 0,
c3fc2621 409 'html' => [
e501603b 410 'type' => 'Text',
c3fc2621 411 ],
a9d0587b 412 'add' => '1.1',
c3fc2621
CW
413 ],
414 'phone_id' => [
e501603b
TO
415 'name' => 'phone_id',
416 'type' => CRM_Utils_Type::T_INT,
a1d226d6 417 'title' => ts('Phone (called) ID'),
215b423e 418 'description' => ts('Phone ID of the number called (optional - used if an existing phone number is selected).'),
a36434b9 419 'where' => 'civicrm_activity.phone_id',
522a26c9 420 'table_name' => 'civicrm_activity',
421 'entity' => 'Activity',
422 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 423 'localizable' => 0,
e501603b 424 'FKClassName' => 'CRM_Core_DAO_Phone',
c3fc2621 425 'html' => [
e501603b 426 'type' => 'EntityRef',
a1d226d6 427 'label' => ts("Phone (called)"),
c3fc2621 428 ],
a9d0587b 429 'add' => '2.0',
c3fc2621
CW
430 ],
431 'phone_number' => [
e501603b
TO
432 'name' => 'phone_number',
433 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 434 'title' => ts('Phone (called) Number'),
215b423e 435 'description' => ts('Phone number in case the number does not exist in the civicrm_phone table.'),
e501603b
TO
436 'maxlength' => 64,
437 'size' => CRM_Utils_Type::BIG,
a36434b9 438 'where' => 'civicrm_activity.phone_number',
522a26c9 439 'table_name' => 'civicrm_activity',
440 'entity' => 'Activity',
441 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 442 'localizable' => 0,
c3fc2621 443 'html' => [
e501603b 444 'type' => 'Text',
c3fc2621 445 ],
a9d0587b 446 'add' => '2.0',
c3fc2621
CW
447 ],
448 'activity_details' => [
e501603b
TO
449 'name' => 'details',
450 'type' => CRM_Utils_Type::T_LONGTEXT,
c3fc2621 451 'title' => ts('Details'),
215b423e 452 'description' => ts('Details about the activity (agenda, notes, etc).'),
c3fc2621 453 'import' => TRUE,
e501603b
TO
454 'where' => 'civicrm_activity.details',
455 'headerPattern' => '/(activity.)?detail(s)?$/i',
c3fc2621 456 'export' => TRUE,
522a26c9 457 'table_name' => 'civicrm_activity',
458 'entity' => 'Activity',
459 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 460 'localizable' => 0,
c3fc2621 461 'html' => [
e501603b 462 'type' => 'RichTextEditor',
c3fc2621 463 ],
a9d0587b 464 'add' => '1.1',
c3fc2621
CW
465 ],
466 'activity_status_id' => [
e501603b
TO
467 'name' => 'status_id',
468 'type' => CRM_Utils_Type::T_INT,
c3fc2621 469 'title' => ts('Activity Status'),
215b423e 470 'description' => ts('ID of the status this activity is currently in. Foreign key to civicrm_option_value.'),
c3fc2621 471 'import' => TRUE,
e501603b
TO
472 'where' => 'civicrm_activity.status_id',
473 'headerPattern' => '/(activity.)?status(.label$)?/i',
c3fc2621 474 'export' => TRUE,
522a26c9 475 'table_name' => 'civicrm_activity',
476 'entity' => 'Activity',
477 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 478 'localizable' => 0,
c3fc2621 479 'html' => [
e501603b 480 'type' => 'Select',
c3fc2621
CW
481 ],
482 'pseudoconstant' => [
e501603b
TO
483 'optionGroupName' => 'activity_status',
484 'optionEditPath' => 'civicrm/admin/options/activity_status',
e6ca0a57 485 ],
a9d0587b 486 'add' => '2.0',
c3fc2621
CW
487 ],
488 'priority_id' => [
e501603b
TO
489 'name' => 'priority_id',
490 'type' => CRM_Utils_Type::T_INT,
c3fc2621 491 'title' => ts('Priority'),
215b423e 492 'description' => ts('ID of the priority given to this activity. Foreign key to civicrm_option_value.'),
6c0c4ac7 493 'import' => TRUE,
a36434b9 494 'where' => 'civicrm_activity.priority_id',
6c0c4ac7 495 'export' => TRUE,
522a26c9 496 'table_name' => 'civicrm_activity',
497 'entity' => 'Activity',
498 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 499 'localizable' => 0,
c3fc2621 500 'html' => [
e501603b 501 'type' => 'Select',
c3fc2621
CW
502 ],
503 'pseudoconstant' => [
e501603b
TO
504 'optionGroupName' => 'priority',
505 'optionEditPath' => 'civicrm/admin/options/priority',
e6ca0a57 506 ],
a9d0587b 507 'add' => '2.0',
c3fc2621
CW
508 ],
509 'parent_id' => [
e501603b
TO
510 'name' => 'parent_id',
511 'type' => CRM_Utils_Type::T_INT,
c3fc2621 512 'title' => ts('Parent Activity Id'),
215b423e 513 'description' => ts('Parent meeting ID (if this is a follow-up item). This is not currently implemented'),
a36434b9 514 'where' => 'civicrm_activity.parent_id',
522a26c9 515 'table_name' => 'civicrm_activity',
516 'entity' => 'Activity',
517 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 518 'localizable' => 0,
e501603b 519 'FKClassName' => 'CRM_Activity_DAO_Activity',
a9d0587b 520 'add' => '1.1',
c3fc2621
CW
521 ],
522 'activity_is_test' => [
e501603b
TO
523 'name' => 'is_test',
524 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621
CW
525 'title' => ts('Test'),
526 'import' => TRUE,
e501603b
TO
527 'where' => 'civicrm_activity.is_test',
528 'headerPattern' => '/(is.)?test(.activity)?/i',
c3fc2621 529 'export' => TRUE,
45a83e42 530 'default' => '0',
522a26c9 531 'table_name' => 'civicrm_activity',
532 'entity' => 'Activity',
533 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 534 'localizable' => 0,
c3fc2621 535 'html' => [
3542118f 536 'type' => 'CheckBox',
c3fc2621 537 ],
a9d0587b 538 'add' => '2.0',
c3fc2621
CW
539 ],
540 'activity_medium_id' => [
e501603b
TO
541 'name' => 'medium_id',
542 'type' => CRM_Utils_Type::T_INT,
c3fc2621 543 'title' => ts('Activity Medium'),
215b423e 544 'description' => ts('Activity Medium, Implicit FK to civicrm_option_value where option_group = encounter_medium.'),
a36434b9 545 'where' => 'civicrm_activity.medium_id',
e501603b 546 'default' => 'NULL',
522a26c9 547 'table_name' => 'civicrm_activity',
548 'entity' => 'Activity',
549 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 550 'localizable' => 0,
c3fc2621 551 'html' => [
e501603b 552 'type' => 'Select',
c3fc2621
CW
553 ],
554 'pseudoconstant' => [
e501603b
TO
555 'optionGroupName' => 'encounter_medium',
556 'optionEditPath' => 'civicrm/admin/options/encounter_medium',
e6ca0a57 557 ],
a9d0587b 558 'add' => '2.2',
c3fc2621
CW
559 ],
560 'is_auto' => [
e501603b
TO
561 'name' => 'is_auto',
562 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 563 'title' => ts('Auto'),
a36434b9 564 'where' => 'civicrm_activity.is_auto',
45a83e42 565 'default' => '0',
522a26c9 566 'table_name' => 'civicrm_activity',
567 'entity' => 'Activity',
568 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 569 'localizable' => 0,
a9d0587b 570 'add' => '2.2',
c3fc2621
CW
571 ],
572 'relationship_id' => [
e501603b
TO
573 'name' => 'relationship_id',
574 'type' => CRM_Utils_Type::T_INT,
c3fc2621 575 'title' => ts('Relationship Id'),
215b423e 576 'description' => ts('FK to Relationship ID'),
a36434b9 577 'where' => 'civicrm_activity.relationship_id',
e501603b 578 'default' => 'NULL',
522a26c9 579 'table_name' => 'civicrm_activity',
580 'entity' => 'Activity',
581 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 582 'localizable' => 0,
e501603b 583 'FKClassName' => 'CRM_Contact_DAO_Relationship',
a9d0587b 584 'add' => '2.2',
c3fc2621
CW
585 ],
586 'is_current_revision' => [
e501603b
TO
587 'name' => 'is_current_revision',
588 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621
CW
589 'title' => ts('Is this activity a current revision in versioning chain?'),
590 'import' => TRUE,
e501603b
TO
591 'where' => 'civicrm_activity.is_current_revision',
592 'headerPattern' => '/(is.)?(current.)?(revision|version(ing)?)/i',
c3fc2621 593 'export' => TRUE,
e501603b 594 'default' => '1',
522a26c9 595 'table_name' => 'civicrm_activity',
596 'entity' => 'Activity',
597 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 598 'localizable' => 0,
a9d0587b 599 'add' => '2.2',
c3fc2621
CW
600 ],
601 'original_id' => [
e501603b
TO
602 'name' => 'original_id',
603 'type' => CRM_Utils_Type::T_INT,
c3fc2621 604 'title' => ts('Original Activity ID '),
215b423e 605 'description' => ts('Activity ID of the first activity record in versioning chain.'),
a36434b9 606 'where' => 'civicrm_activity.original_id',
522a26c9 607 'table_name' => 'civicrm_activity',
608 'entity' => 'Activity',
609 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 610 'localizable' => 0,
e501603b 611 'FKClassName' => 'CRM_Activity_DAO_Activity',
a9d0587b 612 'add' => '2.2',
c3fc2621
CW
613 ],
614 'activity_result' => [
e501603b
TO
615 'name' => 'result',
616 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 617 'title' => ts('Result'),
215b423e 618 'description' => ts('Currently being used to store result id for survey activity, FK to option value.'),
e501603b
TO
619 'maxlength' => 255,
620 'size' => CRM_Utils_Type::HUGE,
a36434b9 621 'where' => 'civicrm_activity.result',
522a26c9 622 'table_name' => 'civicrm_activity',
623 'entity' => 'Activity',
624 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 625 'localizable' => 0,
a9d0587b 626 'add' => '3.3',
c3fc2621
CW
627 ],
628 'activity_is_deleted' => [
e501603b
TO
629 'name' => 'is_deleted',
630 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621
CW
631 'title' => ts('Activity is in the Trash'),
632 'import' => TRUE,
e501603b
TO
633 'where' => 'civicrm_activity.is_deleted',
634 'headerPattern' => '/(activity.)?(trash|deleted)/i',
c3fc2621 635 'export' => TRUE,
45a83e42 636 'default' => '0',
522a26c9 637 'table_name' => 'civicrm_activity',
638 'entity' => 'Activity',
639 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 640 'localizable' => 0,
c3fc2621 641 'html' => [
3542118f 642 'type' => 'CheckBox',
c3fc2621 643 ],
a9d0587b 644 'add' => '2.2',
c3fc2621
CW
645 ],
646 'activity_campaign_id' => [
e501603b
TO
647 'name' => 'campaign_id',
648 'type' => CRM_Utils_Type::T_INT,
c3fc2621 649 'title' => ts('Campaign'),
215b423e 650 'description' => ts('The campaign for which this activity has been triggered.'),
c3fc2621 651 'import' => TRUE,
e501603b 652 'where' => 'civicrm_activity.campaign_id',
c3fc2621 653 'export' => TRUE,
522a26c9 654 'table_name' => 'civicrm_activity',
655 'entity' => 'Activity',
656 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 657 'localizable' => 0,
e501603b 658 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
c3fc2621 659 'html' => [
3542118f 660 'type' => 'Select',
c3fc2621 661 ],
a9d0587b 662 'add' => '3.4',
c3fc2621
CW
663 ],
664 'activity_engagement_level' => [
e501603b
TO
665 'name' => 'engagement_level',
666 'type' => CRM_Utils_Type::T_INT,
c3fc2621 667 'title' => ts('Engagement Index'),
215b423e 668 'description' => ts('Assign a specific level of engagement to this activity. Used for tracking constituents in ladder of engagement.'),
c3fc2621 669 'import' => TRUE,
e501603b 670 'where' => 'civicrm_activity.engagement_level',
c3fc2621 671 'export' => TRUE,
522a26c9 672 'table_name' => 'civicrm_activity',
673 'entity' => 'Activity',
674 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 675 'localizable' => 0,
c3fc2621 676 'html' => [
e501603b 677 'type' => 'Select',
c3fc2621
CW
678 ],
679 'pseudoconstant' => [
e501603b
TO
680 'optionGroupName' => 'engagement_index',
681 'optionEditPath' => 'civicrm/admin/options/engagement_index',
e6ca0a57 682 ],
a9d0587b 683 'add' => '3.4',
c3fc2621
CW
684 ],
685 'weight' => [
e501603b
TO
686 'name' => 'weight',
687 'type' => CRM_Utils_Type::T_INT,
c3fc2621 688 'title' => ts('Order'),
a36434b9 689 'where' => 'civicrm_activity.weight',
522a26c9 690 'table_name' => 'civicrm_activity',
691 'entity' => 'Activity',
692 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 693 'localizable' => 0,
a9d0587b 694 'add' => '4.1',
c3fc2621
CW
695 ],
696 'is_star' => [
cd063b10
CW
697 'name' => 'is_star',
698 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 699 'title' => ts('Is Starred'),
215b423e 700 'description' => ts('Activity marked as favorite.'),
c3fc2621 701 'import' => TRUE,
cd063b10
CW
702 'where' => 'civicrm_activity.is_star',
703 'headerPattern' => '/(activity.)?(star|favorite)/i',
c3fc2621 704 'export' => TRUE,
45a83e42 705 'default' => '0',
522a26c9 706 'table_name' => 'civicrm_activity',
707 'entity' => 'Activity',
708 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 709 'localizable' => 0,
3542118f
CW
710 'html' => [
711 'type' => 'Checkbox',
712 ],
a9d0587b 713 'add' => '4.7',
c3fc2621
CW
714 ],
715 'activity_created_date' => [
3ed77291
TO
716 'name' => 'created_date',
717 'type' => CRM_Utils_Type::T_TIMESTAMP,
c3fc2621 718 'title' => ts('Created Date'),
215b423e 719 'description' => ts('When was the activity was created.'),
c3fc2621 720 'required' => FALSE,
3ed77291 721 'where' => 'civicrm_activity.created_date',
a36434b9 722 'export' => TRUE,
487813ab 723 'default' => 'CURRENT_TIMESTAMP',
3ed77291
TO
724 'table_name' => 'civicrm_activity',
725 'entity' => 'Activity',
726 'bao' => 'CRM_Activity_BAO_Activity',
727 'localizable' => 0,
a9d0587b 728 'add' => '4.7',
c3fc2621
CW
729 ],
730 'activity_modified_date' => [
3ed77291
TO
731 'name' => 'modified_date',
732 'type' => CRM_Utils_Type::T_TIMESTAMP,
c3fc2621 733 'title' => ts('Modified Date'),
215b423e 734 'description' => ts('When was the activity (or closely related entity) was created or modified or deleted.'),
c3fc2621 735 'required' => FALSE,
3ed77291 736 'where' => 'civicrm_activity.modified_date',
a36434b9 737 'export' => TRUE,
3ed77291
TO
738 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
739 'table_name' => 'civicrm_activity',
740 'entity' => 'Activity',
741 'bao' => 'CRM_Activity_BAO_Activity',
742 'localizable' => 0,
a9d0587b 743 'add' => '4.7',
c3fc2621
CW
744 ],
745 ];
346aaaba 746 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 747 }
346aaaba 748 return Civi::$statics[__CLASS__]['fields'];
e501603b 749 }
c3fc2621 750
e501603b 751 /**
bd8e0b14 752 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
753 *
754 * @return array
bd8e0b14 755 * Array(string $name => string $uniqueName).
e501603b 756 */
c3fc2621 757 public static function &fieldKeys() {
bd8e0b14
TO
758 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
759 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 760 }
bd8e0b14 761 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 762 }
c3fc2621 763
e501603b
TO
764 /**
765 * Returns the names of this table
766 *
767 * @return string
768 */
c3fc2621 769 public static function getTableName() {
e501603b
TO
770 return self::$_tableName;
771 }
c3fc2621 772
e501603b
TO
773 /**
774 * Returns if this table needs to be logged
775 *
c3fc2621 776 * @return bool
e501603b 777 */
c3fc2621 778 public function getLog() {
e501603b
TO
779 return self::$_log;
780 }
c3fc2621 781
e501603b
TO
782 /**
783 * Returns the list of fields that can be imported
784 *
785 * @param bool $prefix
786 *
787 * @return array
788 */
c3fc2621
CW
789 public static function &import($prefix = FALSE) {
790 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'activity', $prefix, []);
60808919 791 return $r;
e501603b 792 }
c3fc2621 793
e501603b
TO
794 /**
795 * Returns the list of fields that can be exported
796 *
797 * @param bool $prefix
798 *
799 * @return array
800 */
c3fc2621
CW
801 public static function &export($prefix = FALSE) {
802 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'activity', $prefix, []);
60808919 803 return $r;
e501603b 804 }
c3fc2621 805
e7a6b91a
AS
806 /**
807 * Returns the list of indices
c3fc2621
CW
808 *
809 * @param bool $localize
810 *
811 * @return array
e7a6b91a
AS
812 */
813 public static function indices($localize = TRUE) {
c3fc2621
CW
814 $indices = [
815 'UI_source_record_id' => [
e7a6b91a 816 'name' => 'UI_source_record_id',
c3fc2621 817 'field' => [
e7a6b91a 818 0 => 'source_record_id',
c3fc2621
CW
819 ],
820 'localizable' => FALSE,
e7a6b91a 821 'sig' => 'civicrm_activity::0::source_record_id',
c3fc2621
CW
822 ],
823 'UI_activity_type_id' => [
e7a6b91a 824 'name' => 'UI_activity_type_id',
c3fc2621 825 'field' => [
e7a6b91a 826 0 => 'activity_type_id',
c3fc2621
CW
827 ],
828 'localizable' => FALSE,
e7a6b91a 829 'sig' => 'civicrm_activity::0::activity_type_id',
c3fc2621
CW
830 ],
831 'index_activity_date_time' => [
ab49600a 832 'name' => 'index_activity_date_time',
c3fc2621 833 'field' => [
ab49600a 834 0 => 'activity_date_time',
c3fc2621
CW
835 ],
836 'localizable' => FALSE,
ab49600a 837 'sig' => 'civicrm_activity::0::activity_date_time',
c3fc2621
CW
838 ],
839 'index_status_id' => [
5b3543ce 840 'name' => 'index_status_id',
c3fc2621 841 'field' => [
5b3543ce 842 0 => 'status_id',
c3fc2621
CW
843 ],
844 'localizable' => FALSE,
5b3543ce 845 'sig' => 'civicrm_activity::0::status_id',
c3fc2621 846 ],
c3fc2621 847 'index_is_current_revision' => [
e7a6b91a 848 'name' => 'index_is_current_revision',
c3fc2621 849 'field' => [
e7a6b91a 850 0 => 'is_current_revision',
c3fc2621
CW
851 ],
852 'localizable' => FALSE,
e7a6b91a 853 'sig' => 'civicrm_activity::0::is_current_revision',
c3fc2621
CW
854 ],
855 'index_is_deleted' => [
e7a6b91a 856 'name' => 'index_is_deleted',
c3fc2621 857 'field' => [
e7a6b91a 858 0 => 'is_deleted',
c3fc2621
CW
859 ],
860 'localizable' => FALSE,
e7a6b91a 861 'sig' => 'civicrm_activity::0::is_deleted',
c3fc2621
CW
862 ],
863 ];
e7a6b91a
AS
864 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
865 }
c3fc2621 866
e501603b 867}