Merge pull request #20077 from eileenmcnaughton/mem_order
[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
88c31c05 9 * (GenCodeChecksum:3e86dd56976cbc807306691e8fa94b0d)
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,
2cbbebe8
A
296 'html' => [
297 'type' => 'Number',
298 ],
1fe423d6 299 'readonly' => TRUE,
a9d0587b 300 'add' => '1.1',
c3fc2621
CW
301 ],
302 'source_record_id' => [
e501603b
TO
303 'name' => 'source_record_id',
304 'type' => CRM_Utils_Type::T_INT,
c3fc2621 305 'title' => ts('Source Record'),
215b423e 306 '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 307 'where' => 'civicrm_activity.source_record_id',
522a26c9 308 'table_name' => 'civicrm_activity',
309 'entity' => 'Activity',
310 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 311 'localizable' => 0,
58b0bf5a 312 'readonly' => TRUE,
a9d0587b 313 'add' => '2.0',
c3fc2621
CW
314 ],
315 'activity_type_id' => [
e501603b
TO
316 'name' => 'activity_type_id',
317 'type' => CRM_Utils_Type::T_INT,
a1d226d6 318 'title' => ts('Activity Type ID'),
215b423e 319 'description' => ts('FK to civicrm_option_value.id, that has to be valid, registered activity type.'),
c3fc2621
CW
320 'required' => TRUE,
321 'import' => TRUE,
e501603b
TO
322 'where' => 'civicrm_activity.activity_type_id',
323 'headerPattern' => '/(activity.)?type(.id$)/i',
c3fc2621 324 'export' => TRUE,
e501603b 325 'default' => '1',
522a26c9 326 'table_name' => 'civicrm_activity',
327 'entity' => 'Activity',
328 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 329 'localizable' => 0,
c3fc2621 330 'html' => [
e501603b 331 'type' => 'Select',
a1d226d6 332 'label' => ts("Activity Type"),
c3fc2621
CW
333 ],
334 'pseudoconstant' => [
e501603b
TO
335 'optionGroupName' => 'activity_type',
336 'optionEditPath' => 'civicrm/admin/options/activity_type',
e6ca0a57 337 ],
a9d0587b 338 'add' => '1.1',
c3fc2621
CW
339 ],
340 'activity_subject' => [
e501603b
TO
341 'name' => 'subject',
342 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 343 'title' => ts('Subject'),
215b423e 344 'description' => ts('The subject/purpose/short description of the activity.'),
e501603b
TO
345 'maxlength' => 255,
346 'size' => CRM_Utils_Type::HUGE,
c3fc2621 347 'import' => TRUE,
e501603b
TO
348 'where' => 'civicrm_activity.subject',
349 'headerPattern' => '/(activity.)?subject/i',
c3fc2621 350 'export' => TRUE,
522a26c9 351 'table_name' => 'civicrm_activity',
352 'entity' => 'Activity',
353 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 354 'localizable' => 0,
c3fc2621 355 'html' => [
e501603b 356 'type' => 'Text',
c3fc2621 357 ],
a9d0587b 358 'add' => '1.1',
c3fc2621
CW
359 ],
360 'activity_date_time' => [
e501603b
TO
361 'name' => 'activity_date_time',
362 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
c3fc2621 363 'title' => ts('Activity Date'),
215b423e 364 'description' => ts('Date and time this activity is scheduled to occur. Formerly named scheduled_date_time.'),
487813ab 365 'required' => FALSE,
c3fc2621 366 'import' => TRUE,
e501603b
TO
367 'where' => 'civicrm_activity.activity_date_time',
368 'headerPattern' => '/(activity.)?date(.time$)?/i',
c3fc2621 369 'export' => TRUE,
487813ab 370 'default' => 'CURRENT_TIMESTAMP',
522a26c9 371 'table_name' => 'civicrm_activity',
372 'entity' => 'Activity',
373 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 374 'localizable' => 0,
c3fc2621 375 'html' => [
e501603b 376 'type' => 'Select Date',
24317d89 377 'formatType' => 'activityDateTime',
c3fc2621 378 ],
a9d0587b 379 'add' => '2.0',
c3fc2621
CW
380 ],
381 'activity_duration' => [
e501603b
TO
382 'name' => 'duration',
383 'type' => CRM_Utils_Type::T_INT,
c3fc2621 384 'title' => ts('Duration'),
215b423e 385 'description' => ts('Planned or actual duration of activity expressed in minutes. Conglomerate of former duration_hours and duration_minutes.'),
c3fc2621 386 'import' => TRUE,
e501603b
TO
387 'where' => 'civicrm_activity.duration',
388 'headerPattern' => '/(activity.)?duration(s)?$/i',
c3fc2621 389 'export' => TRUE,
522a26c9 390 'table_name' => 'civicrm_activity',
391 'entity' => 'Activity',
392 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 393 'localizable' => 0,
c3fc2621 394 'html' => [
3542118f 395 'type' => 'Number',
c3fc2621 396 ],
a9d0587b 397 'add' => '2.0',
c3fc2621
CW
398 ],
399 'activity_location' => [
e501603b
TO
400 'name' => 'location',
401 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 402 'title' => ts('Location'),
215b423e 403 'description' => ts('Location of the activity (optional, open text).'),
e501603b
TO
404 'maxlength' => 255,
405 'size' => CRM_Utils_Type::HUGE,
c3fc2621 406 'import' => TRUE,
e501603b
TO
407 'where' => 'civicrm_activity.location',
408 'headerPattern' => '/(activity.)?location$/i',
c3fc2621 409 'export' => TRUE,
522a26c9 410 'table_name' => 'civicrm_activity',
411 'entity' => 'Activity',
412 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 413 'localizable' => 0,
c3fc2621 414 'html' => [
e501603b 415 'type' => 'Text',
c3fc2621 416 ],
a9d0587b 417 'add' => '1.1',
c3fc2621
CW
418 ],
419 'phone_id' => [
e501603b
TO
420 'name' => 'phone_id',
421 'type' => CRM_Utils_Type::T_INT,
2cbbebe8 422 'title' => ts('Phone ID (called)'),
215b423e 423 'description' => ts('Phone ID of the number called (optional - used if an existing phone number is selected).'),
a36434b9 424 'where' => 'civicrm_activity.phone_id',
522a26c9 425 'table_name' => 'civicrm_activity',
426 'entity' => 'Activity',
427 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 428 'localizable' => 0,
e501603b 429 'FKClassName' => 'CRM_Core_DAO_Phone',
c3fc2621 430 'html' => [
e501603b 431 'type' => 'EntityRef',
a1d226d6 432 'label' => ts("Phone (called)"),
c3fc2621 433 ],
a9d0587b 434 'add' => '2.0',
c3fc2621
CW
435 ],
436 'phone_number' => [
e501603b
TO
437 'name' => 'phone_number',
438 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 439 'title' => ts('Phone (called) Number'),
215b423e 440 'description' => ts('Phone number in case the number does not exist in the civicrm_phone table.'),
e501603b
TO
441 'maxlength' => 64,
442 'size' => CRM_Utils_Type::BIG,
a36434b9 443 'where' => 'civicrm_activity.phone_number',
522a26c9 444 'table_name' => 'civicrm_activity',
445 'entity' => 'Activity',
446 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 447 'localizable' => 0,
c3fc2621 448 'html' => [
e501603b 449 'type' => 'Text',
c3fc2621 450 ],
a9d0587b 451 'add' => '2.0',
c3fc2621
CW
452 ],
453 'activity_details' => [
e501603b
TO
454 'name' => 'details',
455 'type' => CRM_Utils_Type::T_LONGTEXT,
c3fc2621 456 'title' => ts('Details'),
215b423e 457 'description' => ts('Details about the activity (agenda, notes, etc).'),
c3fc2621 458 'import' => TRUE,
e501603b
TO
459 'where' => 'civicrm_activity.details',
460 'headerPattern' => '/(activity.)?detail(s)?$/i',
c3fc2621 461 'export' => TRUE,
522a26c9 462 'table_name' => 'civicrm_activity',
463 'entity' => 'Activity',
464 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 465 'localizable' => 0,
c3fc2621 466 'html' => [
e501603b 467 'type' => 'RichTextEditor',
c3fc2621 468 ],
a9d0587b 469 'add' => '1.1',
c3fc2621
CW
470 ],
471 'activity_status_id' => [
e501603b
TO
472 'name' => 'status_id',
473 'type' => CRM_Utils_Type::T_INT,
c3fc2621 474 'title' => ts('Activity Status'),
215b423e 475 'description' => ts('ID of the status this activity is currently in. Foreign key to civicrm_option_value.'),
c3fc2621 476 'import' => TRUE,
e501603b
TO
477 'where' => 'civicrm_activity.status_id',
478 'headerPattern' => '/(activity.)?status(.label$)?/i',
c3fc2621 479 'export' => TRUE,
522a26c9 480 'table_name' => 'civicrm_activity',
481 'entity' => 'Activity',
482 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 483 'localizable' => 0,
c3fc2621 484 'html' => [
e501603b 485 'type' => 'Select',
c3fc2621
CW
486 ],
487 'pseudoconstant' => [
e501603b
TO
488 'optionGroupName' => 'activity_status',
489 'optionEditPath' => 'civicrm/admin/options/activity_status',
e6ca0a57 490 ],
a9d0587b 491 'add' => '2.0',
c3fc2621
CW
492 ],
493 'priority_id' => [
e501603b
TO
494 'name' => 'priority_id',
495 'type' => CRM_Utils_Type::T_INT,
c3fc2621 496 'title' => ts('Priority'),
215b423e 497 'description' => ts('ID of the priority given to this activity. Foreign key to civicrm_option_value.'),
6c0c4ac7 498 'import' => TRUE,
a36434b9 499 'where' => 'civicrm_activity.priority_id',
6c0c4ac7 500 'export' => TRUE,
522a26c9 501 'table_name' => 'civicrm_activity',
502 'entity' => 'Activity',
503 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 504 'localizable' => 0,
c3fc2621 505 'html' => [
e501603b 506 'type' => 'Select',
c3fc2621
CW
507 ],
508 'pseudoconstant' => [
e501603b
TO
509 'optionGroupName' => 'priority',
510 'optionEditPath' => 'civicrm/admin/options/priority',
e6ca0a57 511 ],
a9d0587b 512 'add' => '2.0',
c3fc2621
CW
513 ],
514 'parent_id' => [
e501603b
TO
515 'name' => 'parent_id',
516 'type' => CRM_Utils_Type::T_INT,
2cbbebe8 517 'title' => ts('Parent Activity ID'),
215b423e 518 'description' => ts('Parent meeting ID (if this is a follow-up item). This is not currently implemented'),
a36434b9 519 'where' => 'civicrm_activity.parent_id',
522a26c9 520 'table_name' => 'civicrm_activity',
521 'entity' => 'Activity',
522 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 523 'localizable' => 0,
e501603b 524 'FKClassName' => 'CRM_Activity_DAO_Activity',
2cbbebe8
A
525 'html' => [
526 'label' => ts("Parent Activity"),
527 ],
58b0bf5a 528 'readonly' => TRUE,
a9d0587b 529 'add' => '1.1',
c3fc2621
CW
530 ],
531 'activity_is_test' => [
e501603b
TO
532 'name' => 'is_test',
533 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621
CW
534 'title' => ts('Test'),
535 'import' => TRUE,
e501603b
TO
536 'where' => 'civicrm_activity.is_test',
537 'headerPattern' => '/(is.)?test(.activity)?/i',
c3fc2621 538 'export' => TRUE,
45a83e42 539 'default' => '0',
522a26c9 540 'table_name' => 'civicrm_activity',
541 'entity' => 'Activity',
542 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 543 'localizable' => 0,
c3fc2621 544 'html' => [
3542118f 545 'type' => 'CheckBox',
c3fc2621 546 ],
a9d0587b 547 'add' => '2.0',
c3fc2621
CW
548 ],
549 'activity_medium_id' => [
e501603b
TO
550 'name' => 'medium_id',
551 'type' => CRM_Utils_Type::T_INT,
c3fc2621 552 'title' => ts('Activity Medium'),
215b423e 553 'description' => ts('Activity Medium, Implicit FK to civicrm_option_value where option_group = encounter_medium.'),
a36434b9 554 'where' => 'civicrm_activity.medium_id',
e501603b 555 'default' => 'NULL',
522a26c9 556 'table_name' => 'civicrm_activity',
557 'entity' => 'Activity',
558 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 559 'localizable' => 0,
c3fc2621 560 'html' => [
e501603b 561 'type' => 'Select',
c3fc2621
CW
562 ],
563 'pseudoconstant' => [
e501603b
TO
564 'optionGroupName' => 'encounter_medium',
565 'optionEditPath' => 'civicrm/admin/options/encounter_medium',
e6ca0a57 566 ],
a9d0587b 567 'add' => '2.2',
c3fc2621
CW
568 ],
569 'is_auto' => [
e501603b
TO
570 'name' => 'is_auto',
571 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 572 'title' => ts('Auto'),
a36434b9 573 'where' => 'civicrm_activity.is_auto',
45a83e42 574 'default' => '0',
522a26c9 575 'table_name' => 'civicrm_activity',
576 'entity' => 'Activity',
577 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 578 'localizable' => 0,
a9d0587b 579 'add' => '2.2',
c3fc2621
CW
580 ],
581 'relationship_id' => [
e501603b
TO
582 'name' => 'relationship_id',
583 'type' => CRM_Utils_Type::T_INT,
2cbbebe8 584 'title' => ts('Relationship ID'),
215b423e 585 'description' => ts('FK to Relationship ID'),
a36434b9 586 'where' => 'civicrm_activity.relationship_id',
e501603b 587 'default' => 'NULL',
522a26c9 588 'table_name' => 'civicrm_activity',
589 'entity' => 'Activity',
590 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 591 'localizable' => 0,
e501603b 592 'FKClassName' => 'CRM_Contact_DAO_Relationship',
2cbbebe8
A
593 'html' => [
594 'label' => ts("Relationship"),
595 ],
a9d0587b 596 'add' => '2.2',
c3fc2621
CW
597 ],
598 'is_current_revision' => [
e501603b
TO
599 'name' => 'is_current_revision',
600 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621
CW
601 'title' => ts('Is this activity a current revision in versioning chain?'),
602 'import' => TRUE,
e501603b
TO
603 'where' => 'civicrm_activity.is_current_revision',
604 'headerPattern' => '/(is.)?(current.)?(revision|version(ing)?)/i',
c3fc2621 605 'export' => TRUE,
e501603b 606 'default' => '1',
522a26c9 607 'table_name' => 'civicrm_activity',
608 'entity' => 'Activity',
609 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 610 'localizable' => 0,
a9d0587b 611 'add' => '2.2',
c3fc2621
CW
612 ],
613 'original_id' => [
e501603b
TO
614 'name' => 'original_id',
615 'type' => CRM_Utils_Type::T_INT,
2cbbebe8 616 'title' => ts('Original Activity ID'),
215b423e 617 'description' => ts('Activity ID of the first activity record in versioning chain.'),
a36434b9 618 'where' => 'civicrm_activity.original_id',
522a26c9 619 'table_name' => 'civicrm_activity',
620 'entity' => 'Activity',
621 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 622 'localizable' => 0,
e501603b 623 'FKClassName' => 'CRM_Activity_DAO_Activity',
2cbbebe8
A
624 'html' => [
625 'label' => ts("Original Activity"),
626 ],
58b0bf5a 627 'readonly' => TRUE,
a9d0587b 628 'add' => '2.2',
c3fc2621
CW
629 ],
630 'activity_result' => [
e501603b
TO
631 'name' => 'result',
632 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 633 'title' => ts('Result'),
215b423e 634 'description' => ts('Currently being used to store result id for survey activity, FK to option value.'),
e501603b
TO
635 'maxlength' => 255,
636 'size' => CRM_Utils_Type::HUGE,
a36434b9 637 'where' => 'civicrm_activity.result',
522a26c9 638 'table_name' => 'civicrm_activity',
639 'entity' => 'Activity',
640 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 641 'localizable' => 0,
a9d0587b 642 'add' => '3.3',
c3fc2621
CW
643 ],
644 'activity_is_deleted' => [
e501603b
TO
645 'name' => 'is_deleted',
646 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621
CW
647 'title' => ts('Activity is in the Trash'),
648 'import' => TRUE,
e501603b
TO
649 'where' => 'civicrm_activity.is_deleted',
650 'headerPattern' => '/(activity.)?(trash|deleted)/i',
c3fc2621 651 'export' => TRUE,
45a83e42 652 'default' => '0',
522a26c9 653 'table_name' => 'civicrm_activity',
654 'entity' => 'Activity',
655 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 656 'localizable' => 0,
c3fc2621 657 'html' => [
3542118f 658 'type' => 'CheckBox',
c3fc2621 659 ],
a9d0587b 660 'add' => '2.2',
c3fc2621
CW
661 ],
662 'activity_campaign_id' => [
e501603b
TO
663 'name' => 'campaign_id',
664 'type' => CRM_Utils_Type::T_INT,
2cbbebe8 665 'title' => ts('Campaign ID'),
215b423e 666 'description' => ts('The campaign for which this activity has been triggered.'),
c3fc2621 667 'import' => TRUE,
e501603b 668 'where' => 'civicrm_activity.campaign_id',
c3fc2621 669 'export' => TRUE,
522a26c9 670 'table_name' => 'civicrm_activity',
671 'entity' => 'Activity',
672 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 673 'localizable' => 0,
e501603b 674 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
88c31c05 675 'component' => 'CiviCampaign',
c3fc2621 676 'html' => [
8813f972 677 'type' => 'EntityRef',
2cbbebe8 678 'label' => ts("Campaign"),
c3fc2621 679 ],
a9d0587b 680 'add' => '3.4',
c3fc2621
CW
681 ],
682 'activity_engagement_level' => [
e501603b
TO
683 'name' => 'engagement_level',
684 'type' => CRM_Utils_Type::T_INT,
c3fc2621 685 'title' => ts('Engagement Index'),
215b423e 686 'description' => ts('Assign a specific level of engagement to this activity. Used for tracking constituents in ladder of engagement.'),
c3fc2621 687 'import' => TRUE,
e501603b 688 'where' => 'civicrm_activity.engagement_level',
c3fc2621 689 'export' => TRUE,
522a26c9 690 'table_name' => 'civicrm_activity',
691 'entity' => 'Activity',
692 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 693 'localizable' => 0,
c3fc2621 694 'html' => [
e501603b 695 'type' => 'Select',
c3fc2621
CW
696 ],
697 'pseudoconstant' => [
e501603b
TO
698 'optionGroupName' => 'engagement_index',
699 'optionEditPath' => 'civicrm/admin/options/engagement_index',
e6ca0a57 700 ],
a9d0587b 701 'add' => '3.4',
c3fc2621
CW
702 ],
703 'weight' => [
e501603b
TO
704 'name' => 'weight',
705 'type' => CRM_Utils_Type::T_INT,
c3fc2621 706 'title' => ts('Order'),
a36434b9 707 'where' => 'civicrm_activity.weight',
522a26c9 708 'table_name' => 'civicrm_activity',
709 'entity' => 'Activity',
710 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 711 'localizable' => 0,
a9d0587b 712 'add' => '4.1',
c3fc2621
CW
713 ],
714 'is_star' => [
cd063b10
CW
715 'name' => 'is_star',
716 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 717 'title' => ts('Is Starred'),
215b423e 718 'description' => ts('Activity marked as favorite.'),
c3fc2621 719 'import' => TRUE,
cd063b10
CW
720 'where' => 'civicrm_activity.is_star',
721 'headerPattern' => '/(activity.)?(star|favorite)/i',
c3fc2621 722 'export' => TRUE,
45a83e42 723 'default' => '0',
522a26c9 724 'table_name' => 'civicrm_activity',
725 'entity' => 'Activity',
726 'bao' => 'CRM_Activity_BAO_Activity',
6a7e5e5d 727 'localizable' => 0,
3542118f
CW
728 'html' => [
729 'type' => 'Checkbox',
730 ],
a9d0587b 731 'add' => '4.7',
c3fc2621
CW
732 ],
733 'activity_created_date' => [
3ed77291
TO
734 'name' => 'created_date',
735 'type' => CRM_Utils_Type::T_TIMESTAMP,
c3fc2621 736 'title' => ts('Created Date'),
215b423e 737 'description' => ts('When was the activity was created.'),
c3fc2621 738 'required' => FALSE,
3ed77291 739 'where' => 'civicrm_activity.created_date',
a36434b9 740 'export' => TRUE,
487813ab 741 'default' => 'CURRENT_TIMESTAMP',
3ed77291
TO
742 'table_name' => 'civicrm_activity',
743 'entity' => 'Activity',
744 'bao' => 'CRM_Activity_BAO_Activity',
745 'localizable' => 0,
c23563e3
SL
746 'html' => [
747 'label' => ts("Created Date"),
748 ],
a9d0587b 749 'add' => '4.7',
c3fc2621
CW
750 ],
751 'activity_modified_date' => [
3ed77291
TO
752 'name' => 'modified_date',
753 'type' => CRM_Utils_Type::T_TIMESTAMP,
c3fc2621 754 'title' => ts('Modified Date'),
215b423e 755 'description' => ts('When was the activity (or closely related entity) was created or modified or deleted.'),
c3fc2621 756 'required' => FALSE,
3ed77291 757 'where' => 'civicrm_activity.modified_date',
a36434b9 758 'export' => TRUE,
3ed77291
TO
759 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
760 'table_name' => 'civicrm_activity',
761 'entity' => 'Activity',
762 'bao' => 'CRM_Activity_BAO_Activity',
763 'localizable' => 0,
c23563e3
SL
764 'html' => [
765 'label' => ts("Modified Date"),
766 ],
a0e733f3 767 'readonly' => TRUE,
a9d0587b 768 'add' => '4.7',
c3fc2621
CW
769 ],
770 ];
346aaaba 771 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 772 }
346aaaba 773 return Civi::$statics[__CLASS__]['fields'];
e501603b 774 }
c3fc2621 775
e501603b 776 /**
bd8e0b14 777 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
778 *
779 * @return array
bd8e0b14 780 * Array(string $name => string $uniqueName).
e501603b 781 */
c3fc2621 782 public static function &fieldKeys() {
bd8e0b14
TO
783 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
784 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 785 }
bd8e0b14 786 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 787 }
c3fc2621 788
e501603b
TO
789 /**
790 * Returns the names of this table
791 *
792 * @return string
793 */
c3fc2621 794 public static function getTableName() {
e501603b
TO
795 return self::$_tableName;
796 }
c3fc2621 797
e501603b
TO
798 /**
799 * Returns if this table needs to be logged
800 *
c3fc2621 801 * @return bool
e501603b 802 */
c3fc2621 803 public function getLog() {
e501603b
TO
804 return self::$_log;
805 }
c3fc2621 806
e501603b
TO
807 /**
808 * Returns the list of fields that can be imported
809 *
810 * @param bool $prefix
811 *
812 * @return array
813 */
c3fc2621
CW
814 public static function &import($prefix = FALSE) {
815 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'activity', $prefix, []);
60808919 816 return $r;
e501603b 817 }
c3fc2621 818
e501603b
TO
819 /**
820 * Returns the list of fields that can be exported
821 *
822 * @param bool $prefix
823 *
824 * @return array
825 */
c3fc2621
CW
826 public static function &export($prefix = FALSE) {
827 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'activity', $prefix, []);
60808919 828 return $r;
e501603b 829 }
c3fc2621 830
e7a6b91a
AS
831 /**
832 * Returns the list of indices
c3fc2621
CW
833 *
834 * @param bool $localize
835 *
836 * @return array
e7a6b91a
AS
837 */
838 public static function indices($localize = TRUE) {
c3fc2621
CW
839 $indices = [
840 'UI_source_record_id' => [
e7a6b91a 841 'name' => 'UI_source_record_id',
c3fc2621 842 'field' => [
e7a6b91a 843 0 => 'source_record_id',
c3fc2621
CW
844 ],
845 'localizable' => FALSE,
e7a6b91a 846 'sig' => 'civicrm_activity::0::source_record_id',
c3fc2621
CW
847 ],
848 'UI_activity_type_id' => [
e7a6b91a 849 'name' => 'UI_activity_type_id',
c3fc2621 850 'field' => [
e7a6b91a 851 0 => 'activity_type_id',
c3fc2621
CW
852 ],
853 'localizable' => FALSE,
e7a6b91a 854 'sig' => 'civicrm_activity::0::activity_type_id',
c3fc2621
CW
855 ],
856 'index_activity_date_time' => [
ab49600a 857 'name' => 'index_activity_date_time',
c3fc2621 858 'field' => [
ab49600a 859 0 => 'activity_date_time',
c3fc2621
CW
860 ],
861 'localizable' => FALSE,
ab49600a 862 'sig' => 'civicrm_activity::0::activity_date_time',
c3fc2621
CW
863 ],
864 'index_status_id' => [
5b3543ce 865 'name' => 'index_status_id',
c3fc2621 866 'field' => [
5b3543ce 867 0 => 'status_id',
c3fc2621
CW
868 ],
869 'localizable' => FALSE,
5b3543ce 870 'sig' => 'civicrm_activity::0::status_id',
c3fc2621 871 ],
c3fc2621 872 'index_is_current_revision' => [
e7a6b91a 873 'name' => 'index_is_current_revision',
c3fc2621 874 'field' => [
e7a6b91a 875 0 => 'is_current_revision',
c3fc2621
CW
876 ],
877 'localizable' => FALSE,
e7a6b91a 878 'sig' => 'civicrm_activity::0::is_current_revision',
c3fc2621
CW
879 ],
880 'index_is_deleted' => [
e7a6b91a 881 'name' => 'index_is_deleted',
c3fc2621 882 'field' => [
e7a6b91a 883 0 => 'is_deleted',
c3fc2621
CW
884 ],
885 'localizable' => FALSE,
e7a6b91a 886 'sig' => 'civicrm_activity::0::is_deleted',
c3fc2621
CW
887 ],
888 ];
e7a6b91a
AS
889 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
890 }
c3fc2621 891
e501603b 892}