Merge pull request #9990 from JMAConsulting/CRM-20277
[civicrm-core.git] / CRM / Activity / DAO / Activity.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2017 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
26 */
27 /**
28 * @package CRM
29 * @copyright CiviCRM LLC (c) 2004-2017
30 *
31 * Generated from xml/schema/CRM/Activity/Activity.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
33 * (GenCodeChecksum:930da5a4b8385e51634ab96640875dd5)
34 */
35 require_once 'CRM/Core/DAO.php';
36 require_once 'CRM/Utils/Type.php';
37 /**
38 * CRM_Activity_DAO_Activity constructor.
39 */
40 class CRM_Activity_DAO_Activity extends CRM_Core_DAO {
41 /**
42 * Static instance to hold the table name.
43 *
44 * @var string
45 */
46 static $_tableName = 'civicrm_activity';
47 /**
48 * Should CiviCRM log any modifications to this table in the civicrm_log table.
49 *
50 * @var boolean
51 */
52 static $_log = true;
53 /**
54 * Unique Other Activity ID
55 *
56 * @var int unsigned
57 */
58 public $id;
59 /**
60 * 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.
61 *
62 * @var int unsigned
63 */
64 public $source_record_id;
65 /**
66 * FK to civicrm_option_value.id, that has to be valid, registered activity type.
67 *
68 * @var int unsigned
69 */
70 public $activity_type_id;
71 /**
72 * The subject/purpose/short description of the activity.
73 *
74 * @var string
75 */
76 public $subject;
77 /**
78 * Date and time this activity is scheduled to occur. Formerly named scheduled_date_time.
79 *
80 * @var datetime
81 */
82 public $activity_date_time;
83 /**
84 * Planned or actual duration of activity expressed in minutes. Conglomerate of former duration_hours and duration_minutes.
85 *
86 * @var int unsigned
87 */
88 public $duration;
89 /**
90 * Location of the activity (optional, open text).
91 *
92 * @var string
93 */
94 public $location;
95 /**
96 * Phone ID of the number called (optional - used if an existing phone number is selected).
97 *
98 * @var int unsigned
99 */
100 public $phone_id;
101 /**
102 * Phone number in case the number does not exist in the civicrm_phone table.
103 *
104 * @var string
105 */
106 public $phone_number;
107 /**
108 * Details about the activity (agenda, notes, etc).
109 *
110 * @var longtext
111 */
112 public $details;
113 /**
114 * ID of the status this activity is currently in. Foreign key to civicrm_option_value.
115 *
116 * @var int unsigned
117 */
118 public $status_id;
119 /**
120 * ID of the priority given to this activity. Foreign key to civicrm_option_value.
121 *
122 * @var int unsigned
123 */
124 public $priority_id;
125 /**
126 * Parent meeting ID (if this is a follow-up item). This is not currently implemented
127 *
128 * @var int unsigned
129 */
130 public $parent_id;
131 /**
132 *
133 * @var boolean
134 */
135 public $is_test;
136 /**
137 * Activity Medium, Implicit FK to civicrm_option_value where option_group = encounter_medium.
138 *
139 * @var int unsigned
140 */
141 public $medium_id;
142 /**
143 *
144 * @var boolean
145 */
146 public $is_auto;
147 /**
148 * FK to Relationship ID
149 *
150 * @var int unsigned
151 */
152 public $relationship_id;
153 /**
154 *
155 * @var boolean
156 */
157 public $is_current_revision;
158 /**
159 * Activity ID of the first activity record in versioning chain.
160 *
161 * @var int unsigned
162 */
163 public $original_id;
164 /**
165 * Currently being used to store result id for survey activity, FK to option value.
166 *
167 * @var string
168 */
169 public $result;
170 /**
171 *
172 * @var boolean
173 */
174 public $is_deleted;
175 /**
176 * The campaign for which this activity has been triggered.
177 *
178 * @var int unsigned
179 */
180 public $campaign_id;
181 /**
182 * Assign a specific level of engagement to this activity. Used for tracking constituents in ladder of engagement.
183 *
184 * @var int unsigned
185 */
186 public $engagement_level;
187 /**
188 *
189 * @var int
190 */
191 public $weight;
192 /**
193 * Activity marked as favorite.
194 *
195 * @var boolean
196 */
197 public $is_star;
198 /**
199 * Class constructor.
200 */
201 function __construct() {
202 $this->__table = 'civicrm_activity';
203 parent::__construct();
204 }
205 /**
206 * Returns foreign keys and entity references.
207 *
208 * @return array
209 * [CRM_Core_Reference_Interface]
210 */
211 static function getReferenceColumns() {
212 if (!isset(Civi::$statics[__CLASS__]['links'])) {
213 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
214 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'phone_id', 'civicrm_phone', 'id');
215 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'parent_id', 'civicrm_activity', 'id');
216 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'relationship_id', 'civicrm_relationship', 'id');
217 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'original_id', 'civicrm_activity', 'id');
218 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'campaign_id', 'civicrm_campaign', 'id');
219 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
220 }
221 return Civi::$statics[__CLASS__]['links'];
222 }
223 /**
224 * Returns all the column names of this table
225 *
226 * @return array
227 */
228 static function &fields() {
229 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
230 Civi::$statics[__CLASS__]['fields'] = array(
231 'activity_id' => array(
232 'name' => 'id',
233 'type' => CRM_Utils_Type::T_INT,
234 'title' => ts('Activity ID') ,
235 'description' => 'Unique Other Activity ID',
236 'required' => true,
237 'import' => true,
238 'where' => 'civicrm_activity.id',
239 'headerPattern' => '',
240 'dataPattern' => '',
241 'export' => true,
242 'table_name' => 'civicrm_activity',
243 'entity' => 'Activity',
244 'bao' => 'CRM_Activity_BAO_Activity',
245 ) ,
246 'source_record_id' => array(
247 'name' => 'source_record_id',
248 'type' => CRM_Utils_Type::T_INT,
249 'title' => ts('Source Record') ,
250 'description' => '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.',
251 'table_name' => 'civicrm_activity',
252 'entity' => 'Activity',
253 'bao' => 'CRM_Activity_BAO_Activity',
254 ) ,
255 'activity_type_id' => array(
256 'name' => 'activity_type_id',
257 'type' => CRM_Utils_Type::T_INT,
258 'title' => ts('Activity Type ID') ,
259 'description' => 'FK to civicrm_option_value.id, that has to be valid, registered activity type.',
260 'required' => true,
261 'import' => true,
262 'where' => 'civicrm_activity.activity_type_id',
263 'headerPattern' => '/(activity.)?type(.id$)/i',
264 'dataPattern' => '',
265 'export' => true,
266 'default' => '1',
267 'table_name' => 'civicrm_activity',
268 'entity' => 'Activity',
269 'bao' => 'CRM_Activity_BAO_Activity',
270 'html' => array(
271 'type' => 'Select',
272 ) ,
273 'pseudoconstant' => array(
274 'optionGroupName' => 'activity_type',
275 'optionEditPath' => 'civicrm/admin/options/activity_type',
276 )
277 ) ,
278 'activity_subject' => array(
279 'name' => 'subject',
280 'type' => CRM_Utils_Type::T_STRING,
281 'title' => ts('Subject') ,
282 'description' => 'The subject/purpose/short description of the activity.',
283 'maxlength' => 255,
284 'size' => CRM_Utils_Type::HUGE,
285 'import' => true,
286 'where' => 'civicrm_activity.subject',
287 'headerPattern' => '/(activity.)?subject/i',
288 'dataPattern' => '',
289 'export' => true,
290 'table_name' => 'civicrm_activity',
291 'entity' => 'Activity',
292 'bao' => 'CRM_Activity_BAO_Activity',
293 'html' => array(
294 'type' => 'Text',
295 ) ,
296 ) ,
297 'activity_date_time' => array(
298 'name' => 'activity_date_time',
299 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
300 'title' => ts('Activity Date') ,
301 'description' => 'Date and time this activity is scheduled to occur. Formerly named scheduled_date_time.',
302 'import' => true,
303 'where' => 'civicrm_activity.activity_date_time',
304 'headerPattern' => '/(activity.)?date(.time$)?/i',
305 'dataPattern' => '',
306 'export' => true,
307 'table_name' => 'civicrm_activity',
308 'entity' => 'Activity',
309 'bao' => 'CRM_Activity_BAO_Activity',
310 'html' => array(
311 'type' => 'Select Date',
312 'formatType' => 'activityDateTime',
313 ) ,
314 ) ,
315 'activity_duration' => array(
316 'name' => 'duration',
317 'type' => CRM_Utils_Type::T_INT,
318 'title' => ts('Duration') ,
319 'description' => 'Planned or actual duration of activity expressed in minutes. Conglomerate of former duration_hours and duration_minutes.',
320 'import' => true,
321 'where' => 'civicrm_activity.duration',
322 'headerPattern' => '/(activity.)?duration(s)?$/i',
323 'dataPattern' => '',
324 'export' => true,
325 'table_name' => 'civicrm_activity',
326 'entity' => 'Activity',
327 'bao' => 'CRM_Activity_BAO_Activity',
328 'html' => array(
329 'type' => 'Text',
330 ) ,
331 ) ,
332 'activity_location' => array(
333 'name' => 'location',
334 'type' => CRM_Utils_Type::T_STRING,
335 'title' => ts('Location') ,
336 'description' => 'Location of the activity (optional, open text).',
337 'maxlength' => 255,
338 'size' => CRM_Utils_Type::HUGE,
339 'import' => true,
340 'where' => 'civicrm_activity.location',
341 'headerPattern' => '/(activity.)?location$/i',
342 'dataPattern' => '',
343 'export' => true,
344 'table_name' => 'civicrm_activity',
345 'entity' => 'Activity',
346 'bao' => 'CRM_Activity_BAO_Activity',
347 'html' => array(
348 'type' => 'Text',
349 ) ,
350 ) ,
351 'phone_id' => array(
352 'name' => 'phone_id',
353 'type' => CRM_Utils_Type::T_INT,
354 'title' => ts('Phone (called) ID') ,
355 'description' => 'Phone ID of the number called (optional - used if an existing phone number is selected).',
356 'table_name' => 'civicrm_activity',
357 'entity' => 'Activity',
358 'bao' => 'CRM_Activity_BAO_Activity',
359 'FKClassName' => 'CRM_Core_DAO_Phone',
360 'html' => array(
361 'type' => 'EntityRef',
362 ) ,
363 ) ,
364 'phone_number' => array(
365 'name' => 'phone_number',
366 'type' => CRM_Utils_Type::T_STRING,
367 'title' => ts('Phone (called) Number') ,
368 'description' => 'Phone number in case the number does not exist in the civicrm_phone table.',
369 'maxlength' => 64,
370 'size' => CRM_Utils_Type::BIG,
371 'table_name' => 'civicrm_activity',
372 'entity' => 'Activity',
373 'bao' => 'CRM_Activity_BAO_Activity',
374 'html' => array(
375 'type' => 'Text',
376 ) ,
377 ) ,
378 'activity_details' => array(
379 'name' => 'details',
380 'type' => CRM_Utils_Type::T_LONGTEXT,
381 'title' => ts('Details') ,
382 'description' => 'Details about the activity (agenda, notes, etc).',
383 'import' => true,
384 'where' => 'civicrm_activity.details',
385 'headerPattern' => '/(activity.)?detail(s)?$/i',
386 'dataPattern' => '',
387 'export' => true,
388 'table_name' => 'civicrm_activity',
389 'entity' => 'Activity',
390 'bao' => 'CRM_Activity_BAO_Activity',
391 'html' => array(
392 'type' => 'RichTextEditor',
393 ) ,
394 ) ,
395 'activity_status_id' => array(
396 'name' => 'status_id',
397 'type' => CRM_Utils_Type::T_INT,
398 'title' => ts('Activity Status') ,
399 'description' => 'ID of the status this activity is currently in. Foreign key to civicrm_option_value.',
400 'import' => true,
401 'where' => 'civicrm_activity.status_id',
402 'headerPattern' => '/(activity.)?status(.label$)?/i',
403 'dataPattern' => '',
404 'export' => false,
405 'table_name' => 'civicrm_activity',
406 'entity' => 'Activity',
407 'bao' => 'CRM_Activity_BAO_Activity',
408 'html' => array(
409 'type' => 'Select',
410 ) ,
411 'pseudoconstant' => array(
412 'optionGroupName' => 'activity_status',
413 'optionEditPath' => 'civicrm/admin/options/activity_status',
414 )
415 ) ,
416 'priority_id' => array(
417 'name' => 'priority_id',
418 'type' => CRM_Utils_Type::T_INT,
419 'title' => ts('Priority') ,
420 'description' => 'ID of the priority given to this activity. Foreign key to civicrm_option_value.',
421 'table_name' => 'civicrm_activity',
422 'entity' => 'Activity',
423 'bao' => 'CRM_Activity_BAO_Activity',
424 'html' => array(
425 'type' => 'Select',
426 ) ,
427 'pseudoconstant' => array(
428 'optionGroupName' => 'priority',
429 'optionEditPath' => 'civicrm/admin/options/priority',
430 )
431 ) ,
432 'parent_id' => array(
433 'name' => 'parent_id',
434 'type' => CRM_Utils_Type::T_INT,
435 'title' => ts('Parent Activity Id') ,
436 'description' => 'Parent meeting ID (if this is a follow-up item). This is not currently implemented',
437 'table_name' => 'civicrm_activity',
438 'entity' => 'Activity',
439 'bao' => 'CRM_Activity_BAO_Activity',
440 'FKClassName' => 'CRM_Activity_DAO_Activity',
441 ) ,
442 'activity_is_test' => array(
443 'name' => 'is_test',
444 'type' => CRM_Utils_Type::T_BOOLEAN,
445 'title' => ts('Test') ,
446 'import' => true,
447 'where' => 'civicrm_activity.is_test',
448 'headerPattern' => '/(is.)?test(.activity)?/i',
449 'dataPattern' => '',
450 'export' => true,
451 'table_name' => 'civicrm_activity',
452 'entity' => 'Activity',
453 'bao' => 'CRM_Activity_BAO_Activity',
454 'html' => array(
455 'type' => 'Select',
456 ) ,
457 ) ,
458 'activity_medium_id' => array(
459 'name' => 'medium_id',
460 'type' => CRM_Utils_Type::T_INT,
461 'title' => ts('Activity Medium') ,
462 'description' => 'Activity Medium, Implicit FK to civicrm_option_value where option_group = encounter_medium.',
463 'default' => 'NULL',
464 'table_name' => 'civicrm_activity',
465 'entity' => 'Activity',
466 'bao' => 'CRM_Activity_BAO_Activity',
467 'html' => array(
468 'type' => 'Select',
469 ) ,
470 'pseudoconstant' => array(
471 'optionGroupName' => 'encounter_medium',
472 'optionEditPath' => 'civicrm/admin/options/encounter_medium',
473 )
474 ) ,
475 'is_auto' => array(
476 'name' => 'is_auto',
477 'type' => CRM_Utils_Type::T_BOOLEAN,
478 'title' => ts('Auto') ,
479 'table_name' => 'civicrm_activity',
480 'entity' => 'Activity',
481 'bao' => 'CRM_Activity_BAO_Activity',
482 ) ,
483 'relationship_id' => array(
484 'name' => 'relationship_id',
485 'type' => CRM_Utils_Type::T_INT,
486 'title' => ts('Relationship Id') ,
487 'description' => 'FK to Relationship ID',
488 'default' => 'NULL',
489 'table_name' => 'civicrm_activity',
490 'entity' => 'Activity',
491 'bao' => 'CRM_Activity_BAO_Activity',
492 'FKClassName' => 'CRM_Contact_DAO_Relationship',
493 ) ,
494 'is_current_revision' => array(
495 'name' => 'is_current_revision',
496 'type' => CRM_Utils_Type::T_BOOLEAN,
497 'title' => ts('Is this activity a current revision in versioning chain?') ,
498 'import' => true,
499 'where' => 'civicrm_activity.is_current_revision',
500 'headerPattern' => '/(is.)?(current.)?(revision|version(ing)?)/i',
501 'dataPattern' => '',
502 'export' => true,
503 'default' => '1',
504 'table_name' => 'civicrm_activity',
505 'entity' => 'Activity',
506 'bao' => 'CRM_Activity_BAO_Activity',
507 'html' => array(
508 'type' => 'CheckBox',
509 ) ,
510 ) ,
511 'original_id' => array(
512 'name' => 'original_id',
513 'type' => CRM_Utils_Type::T_INT,
514 'title' => ts('Original Activity ID ') ,
515 'description' => 'Activity ID of the first activity record in versioning chain.',
516 'table_name' => 'civicrm_activity',
517 'entity' => 'Activity',
518 'bao' => 'CRM_Activity_BAO_Activity',
519 'FKClassName' => 'CRM_Activity_DAO_Activity',
520 ) ,
521 'activity_result' => array(
522 'name' => 'result',
523 'type' => CRM_Utils_Type::T_STRING,
524 'title' => ts('Result') ,
525 'description' => 'Currently being used to store result id for survey activity, FK to option value.',
526 'maxlength' => 255,
527 'size' => CRM_Utils_Type::HUGE,
528 'table_name' => 'civicrm_activity',
529 'entity' => 'Activity',
530 'bao' => 'CRM_Activity_BAO_Activity',
531 'html' => array(
532 'type' => 'Text',
533 ) ,
534 ) ,
535 'activity_is_deleted' => array(
536 'name' => 'is_deleted',
537 'type' => CRM_Utils_Type::T_BOOLEAN,
538 'title' => ts('Activity is in the Trash') ,
539 'import' => true,
540 'where' => 'civicrm_activity.is_deleted',
541 'headerPattern' => '/(activity.)?(trash|deleted)/i',
542 'dataPattern' => '',
543 'export' => true,
544 'table_name' => 'civicrm_activity',
545 'entity' => 'Activity',
546 'bao' => 'CRM_Activity_BAO_Activity',
547 'html' => array(
548 'type' => 'Text',
549 ) ,
550 ) ,
551 'activity_campaign_id' => array(
552 'name' => 'campaign_id',
553 'type' => CRM_Utils_Type::T_INT,
554 'title' => ts('Campaign') ,
555 'description' => 'The campaign for which this activity has been triggered.',
556 'import' => true,
557 'where' => 'civicrm_activity.campaign_id',
558 'headerPattern' => '',
559 'dataPattern' => '',
560 'export' => true,
561 'table_name' => 'civicrm_activity',
562 'entity' => 'Activity',
563 'bao' => 'CRM_Activity_BAO_Activity',
564 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
565 'html' => array(
566 'type' => 'CheckBox',
567 ) ,
568 'pseudoconstant' => array(
569 'table' => 'civicrm_campaign',
570 'keyColumn' => 'id',
571 'labelColumn' => 'title',
572 )
573 ) ,
574 'activity_engagement_level' => array(
575 'name' => 'engagement_level',
576 'type' => CRM_Utils_Type::T_INT,
577 'title' => ts('Engagement Index') ,
578 'description' => 'Assign a specific level of engagement to this activity. Used for tracking constituents in ladder of engagement.',
579 'import' => true,
580 'where' => 'civicrm_activity.engagement_level',
581 'headerPattern' => '',
582 'dataPattern' => '',
583 'export' => true,
584 'table_name' => 'civicrm_activity',
585 'entity' => 'Activity',
586 'bao' => 'CRM_Activity_BAO_Activity',
587 'html' => array(
588 'type' => 'Select',
589 ) ,
590 'pseudoconstant' => array(
591 'optionGroupName' => 'engagement_index',
592 'optionEditPath' => 'civicrm/admin/options/engagement_index',
593 )
594 ) ,
595 'weight' => array(
596 'name' => 'weight',
597 'type' => CRM_Utils_Type::T_INT,
598 'title' => ts('Order') ,
599 'table_name' => 'civicrm_activity',
600 'entity' => 'Activity',
601 'bao' => 'CRM_Activity_BAO_Activity',
602 'html' => array(
603 'type' => 'Text',
604 ) ,
605 ) ,
606 'is_star' => array(
607 'name' => 'is_star',
608 'type' => CRM_Utils_Type::T_BOOLEAN,
609 'title' => ts('Is Starred') ,
610 'description' => 'Activity marked as favorite.',
611 'import' => true,
612 'where' => 'civicrm_activity.is_star',
613 'headerPattern' => '/(activity.)?(star|favorite)/i',
614 'dataPattern' => '',
615 'export' => true,
616 'table_name' => 'civicrm_activity',
617 'entity' => 'Activity',
618 'bao' => 'CRM_Activity_BAO_Activity',
619 ) ,
620 );
621 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
622 }
623 return Civi::$statics[__CLASS__]['fields'];
624 }
625 /**
626 * Return a mapping from field-name to the corresponding key (as used in fields()).
627 *
628 * @return array
629 * Array(string $name => string $uniqueName).
630 */
631 static function &fieldKeys() {
632 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
633 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
634 }
635 return Civi::$statics[__CLASS__]['fieldKeys'];
636 }
637 /**
638 * Returns the names of this table
639 *
640 * @return string
641 */
642 static function getTableName() {
643 return self::$_tableName;
644 }
645 /**
646 * Returns if this table needs to be logged
647 *
648 * @return boolean
649 */
650 function getLog() {
651 return self::$_log;
652 }
653 /**
654 * Returns the list of fields that can be imported
655 *
656 * @param bool $prefix
657 *
658 * @return array
659 */
660 static function &import($prefix = false) {
661 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'activity', $prefix, array());
662 return $r;
663 }
664 /**
665 * Returns the list of fields that can be exported
666 *
667 * @param bool $prefix
668 *
669 * @return array
670 */
671 static function &export($prefix = false) {
672 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'activity', $prefix, array());
673 return $r;
674 }
675 }