[REF] Fix import signature on activity parser, add preliminary test
[civicrm-core.git] / CRM / Activity / DAO / ActivityContact.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/ActivityContact.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
d31fb4e3 9 * (GenCodeChecksum:3f147b2507b1e11a7df971be191161d1)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the ActivityContact entity.
f41f0342 14 */
e501603b 15class CRM_Activity_DAO_ActivityContact extends CRM_Core_DAO {
929a1c14
CW
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '4.4';
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_contact';
c3fc2621 25
e501603b 26 /**
f41f0342 27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b 28 *
c3fc2621 29 * @var bool
e501603b 30 */
fa45b5b9 31 public static $_log = TRUE;
c3fc2621 32
e501603b
TO
33 /**
34 * Activity contact id
35 *
e6ca0a57 36 * @var int
e501603b
TO
37 */
38 public $id;
c3fc2621 39
e501603b
TO
40 /**
41 * Foreign key to the activity for this record.
42 *
e6ca0a57 43 * @var int
e501603b
TO
44 */
45 public $activity_id;
c3fc2621 46
e501603b
TO
47 /**
48 * Foreign key to the contact for this record.
49 *
e6ca0a57 50 * @var int
e501603b
TO
51 */
52 public $contact_id;
c3fc2621 53
e501603b
TO
54 /**
55 * Nature of this contact's role in the activity: 1 assignee, 2 creator, 3 focus or target.
56 *
e6ca0a57 57 * @var int
e501603b
TO
58 */
59 public $record_type_id;
c3fc2621 60
e501603b 61 /**
f41f0342 62 * Class constructor.
e501603b 63 */
c3fc2621 64 public function __construct() {
e501603b
TO
65 $this->__table = 'civicrm_activity_contact';
66 parent::__construct();
67 }
c3fc2621 68
449c4e6b
CW
69 /**
70 * Returns localized title of this entity.
7b66c3b5
AH
71 *
72 * @param bool $plural
73 * Whether to return the plural version of the title.
449c4e6b 74 */
7b66c3b5
AH
75 public static function getEntityTitle($plural = FALSE) {
76 return $plural ? ts('Activity Contacts') : ts('Activity Contact');
449c4e6b
CW
77 }
78
e501603b 79 /**
f41f0342 80 * Returns foreign keys and entity references.
e501603b
TO
81 *
82 * @return array
83 * [CRM_Core_Reference_Interface]
84 */
c3fc2621 85 public static function getReferenceColumns() {
346aaaba 86 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 87 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621
CW
88 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'activity_id', 'civicrm_activity', 'id');
89 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
346aaaba 90 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 91 }
346aaaba 92 return Civi::$statics[__CLASS__]['links'];
e501603b 93 }
c3fc2621 94
e501603b
TO
95 /**
96 * Returns all the column names of this table
97 *
98 * @return array
99 */
c3fc2621 100 public static function &fields() {
346aaaba 101 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
102 Civi::$statics[__CLASS__]['fields'] = [
103 'id' => [
e501603b
TO
104 'name' => 'id',
105 'type' => CRM_Utils_Type::T_INT,
c3fc2621 106 'title' => ts('Activity Contact ID'),
215b423e 107 'description' => ts('Activity contact id'),
c3fc2621 108 'required' => TRUE,
a36434b9 109 'where' => 'civicrm_activity_contact.id',
522a26c9 110 'table_name' => 'civicrm_activity_contact',
111 'entity' => 'ActivityContact',
112 'bao' => 'CRM_Activity_BAO_ActivityContact',
6a7e5e5d 113 'localizable' => 0,
a9d0587b 114 'add' => '4.4',
c3fc2621
CW
115 ],
116 'activity_id' => [
e501603b
TO
117 'name' => 'activity_id',
118 'type' => CRM_Utils_Type::T_INT,
c3fc2621 119 'title' => ts('Activity ID'),
215b423e 120 'description' => ts('Foreign key to the activity for this record.'),
c3fc2621 121 'required' => TRUE,
a36434b9 122 'where' => 'civicrm_activity_contact.activity_id',
522a26c9 123 'table_name' => 'civicrm_activity_contact',
124 'entity' => 'ActivityContact',
125 'bao' => 'CRM_Activity_BAO_ActivityContact',
6a7e5e5d 126 'localizable' => 0,
e501603b 127 'FKClassName' => 'CRM_Activity_DAO_Activity',
a9d0587b 128 'add' => '4.4',
c3fc2621
CW
129 ],
130 'contact_id' => [
e501603b
TO
131 'name' => 'contact_id',
132 'type' => CRM_Utils_Type::T_INT,
c3fc2621 133 'title' => ts('Contact ID (match to contact)'),
215b423e 134 'description' => ts('Foreign key to the contact for this record.'),
c3fc2621
CW
135 'required' => TRUE,
136 'import' => TRUE,
e501603b 137 'where' => 'civicrm_activity_contact.contact_id',
c3fc2621 138 'export' => TRUE,
522a26c9 139 'table_name' => 'civicrm_activity_contact',
140 'entity' => 'ActivityContact',
141 'bao' => 'CRM_Activity_BAO_ActivityContact',
6a7e5e5d 142 'localizable' => 0,
e501603b 143 'FKClassName' => 'CRM_Contact_DAO_Contact',
a9d0587b 144 'add' => '4.4',
c3fc2621
CW
145 ],
146 'record_type_id' => [
e501603b
TO
147 'name' => 'record_type_id',
148 'type' => CRM_Utils_Type::T_INT,
c3fc2621 149 'title' => ts('Record Type ID'),
215b423e 150 'description' => ts('Nature of this contact\'s role in the activity: 1 assignee, 2 creator, 3 focus or target.'),
a36434b9 151 'where' => 'civicrm_activity_contact.record_type_id',
522a26c9 152 'table_name' => 'civicrm_activity_contact',
153 'entity' => 'ActivityContact',
154 'bao' => 'CRM_Activity_BAO_ActivityContact',
6a7e5e5d 155 'localizable' => 0,
c3fc2621 156 'html' => [
e501603b 157 'type' => 'Select',
c3fc2621
CW
158 ],
159 'pseudoconstant' => [
e501603b
TO
160 'optionGroupName' => 'activity_contacts',
161 'optionEditPath' => 'civicrm/admin/options/activity_contacts',
e6ca0a57 162 ],
a9d0587b 163 'add' => '4.4',
c3fc2621
CW
164 ],
165 ];
346aaaba 166 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 167 }
346aaaba 168 return Civi::$statics[__CLASS__]['fields'];
e501603b 169 }
c3fc2621 170
e501603b 171 /**
bd8e0b14 172 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
173 *
174 * @return array
bd8e0b14 175 * Array(string $name => string $uniqueName).
e501603b 176 */
c3fc2621 177 public static function &fieldKeys() {
bd8e0b14
TO
178 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
179 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 180 }
bd8e0b14 181 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 182 }
c3fc2621 183
e501603b
TO
184 /**
185 * Returns the names of this table
186 *
187 * @return string
188 */
c3fc2621 189 public static function getTableName() {
e501603b
TO
190 return self::$_tableName;
191 }
c3fc2621 192
e501603b
TO
193 /**
194 * Returns if this table needs to be logged
195 *
c3fc2621 196 * @return bool
e501603b 197 */
c3fc2621 198 public function getLog() {
e501603b
TO
199 return self::$_log;
200 }
c3fc2621 201
e501603b
TO
202 /**
203 * Returns the list of fields that can be imported
204 *
205 * @param bool $prefix
206 *
207 * @return array
208 */
c3fc2621
CW
209 public static function &import($prefix = FALSE) {
210 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'activity_contact', $prefix, []);
60808919 211 return $r;
e501603b 212 }
c3fc2621 213
e501603b
TO
214 /**
215 * Returns the list of fields that can be exported
216 *
217 * @param bool $prefix
218 *
219 * @return array
220 */
c3fc2621
CW
221 public static function &export($prefix = FALSE) {
222 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'activity_contact', $prefix, []);
60808919 223 return $r;
e501603b 224 }
c3fc2621 225
e7a6b91a
AS
226 /**
227 * Returns the list of indices
c3fc2621
CW
228 *
229 * @param bool $localize
230 *
231 * @return array
e7a6b91a
AS
232 */
233 public static function indices($localize = TRUE) {
c3fc2621
CW
234 $indices = [
235 'UI_activity_contact' => [
e7a6b91a 236 'name' => 'UI_activity_contact',
c3fc2621 237 'field' => [
e7a6b91a
AS
238 0 => 'contact_id',
239 1 => 'activity_id',
240 2 => 'record_type_id',
c3fc2621
CW
241 ],
242 'localizable' => FALSE,
243 'unique' => TRUE,
e7a6b91a 244 'sig' => 'civicrm_activity_contact::1::contact_id::activity_id::record_type_id',
c3fc2621
CW
245 ],
246 'index_record_type' => [
e7a6b91a 247 'name' => 'index_record_type',
c3fc2621 248 'field' => [
e7a6b91a
AS
249 0 => 'activity_id',
250 1 => 'record_type_id',
c3fc2621
CW
251 ],
252 'localizable' => FALSE,
e7a6b91a 253 'sig' => 'civicrm_activity_contact::0::activity_id::record_type_id',
c3fc2621
CW
254 ],
255 ];
e7a6b91a
AS
256 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
257 }
c3fc2621 258
e501603b 259}