Merge pull request #18215 from civicrm/5.29
[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
929a1c14 9 * (GenCodeChecksum:777598f3625dfeaf37a81de282808c60)
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.
71 */
72 public static function getEntityTitle() {
73 return ts('Activity Contacts');
74 }
75
e501603b 76 /**
f41f0342 77 * Returns foreign keys and entity references.
e501603b
TO
78 *
79 * @return array
80 * [CRM_Core_Reference_Interface]
81 */
c3fc2621 82 public static function getReferenceColumns() {
346aaaba 83 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 84 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621
CW
85 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'activity_id', 'civicrm_activity', 'id');
86 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
346aaaba 87 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 88 }
346aaaba 89 return Civi::$statics[__CLASS__]['links'];
e501603b 90 }
c3fc2621 91
e501603b
TO
92 /**
93 * Returns all the column names of this table
94 *
95 * @return array
96 */
c3fc2621 97 public static function &fields() {
346aaaba 98 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
99 Civi::$statics[__CLASS__]['fields'] = [
100 'id' => [
e501603b
TO
101 'name' => 'id',
102 'type' => CRM_Utils_Type::T_INT,
c3fc2621 103 'title' => ts('Activity Contact ID'),
215b423e 104 'description' => ts('Activity contact id'),
c3fc2621 105 'required' => TRUE,
a36434b9 106 'where' => 'civicrm_activity_contact.id',
522a26c9 107 'table_name' => 'civicrm_activity_contact',
108 'entity' => 'ActivityContact',
109 'bao' => 'CRM_Activity_BAO_ActivityContact',
6a7e5e5d 110 'localizable' => 0,
a9d0587b 111 'add' => '4.4',
c3fc2621
CW
112 ],
113 'activity_id' => [
e501603b
TO
114 'name' => 'activity_id',
115 'type' => CRM_Utils_Type::T_INT,
c3fc2621 116 'title' => ts('Activity ID'),
215b423e 117 'description' => ts('Foreign key to the activity for this record.'),
c3fc2621 118 'required' => TRUE,
a36434b9 119 'where' => 'civicrm_activity_contact.activity_id',
522a26c9 120 'table_name' => 'civicrm_activity_contact',
121 'entity' => 'ActivityContact',
122 'bao' => 'CRM_Activity_BAO_ActivityContact',
6a7e5e5d 123 'localizable' => 0,
e501603b 124 'FKClassName' => 'CRM_Activity_DAO_Activity',
a9d0587b 125 'add' => '4.4',
c3fc2621
CW
126 ],
127 'contact_id' => [
e501603b
TO
128 'name' => 'contact_id',
129 'type' => CRM_Utils_Type::T_INT,
c3fc2621 130 'title' => ts('Contact ID (match to contact)'),
215b423e 131 'description' => ts('Foreign key to the contact for this record.'),
c3fc2621
CW
132 'required' => TRUE,
133 'import' => TRUE,
e501603b 134 'where' => 'civicrm_activity_contact.contact_id',
c3fc2621 135 'export' => TRUE,
522a26c9 136 'table_name' => 'civicrm_activity_contact',
137 'entity' => 'ActivityContact',
138 'bao' => 'CRM_Activity_BAO_ActivityContact',
6a7e5e5d 139 'localizable' => 0,
e501603b 140 'FKClassName' => 'CRM_Contact_DAO_Contact',
a9d0587b 141 'add' => '4.4',
c3fc2621
CW
142 ],
143 'record_type_id' => [
e501603b
TO
144 'name' => 'record_type_id',
145 'type' => CRM_Utils_Type::T_INT,
c3fc2621 146 'title' => ts('Record Type ID'),
215b423e 147 'description' => ts('Nature of this contact\'s role in the activity: 1 assignee, 2 creator, 3 focus or target.'),
a36434b9 148 'where' => 'civicrm_activity_contact.record_type_id',
522a26c9 149 'table_name' => 'civicrm_activity_contact',
150 'entity' => 'ActivityContact',
151 'bao' => 'CRM_Activity_BAO_ActivityContact',
6a7e5e5d 152 'localizable' => 0,
c3fc2621 153 'html' => [
e501603b 154 'type' => 'Select',
c3fc2621
CW
155 ],
156 'pseudoconstant' => [
e501603b
TO
157 'optionGroupName' => 'activity_contacts',
158 'optionEditPath' => 'civicrm/admin/options/activity_contacts',
e6ca0a57 159 ],
a9d0587b 160 'add' => '4.4',
c3fc2621
CW
161 ],
162 ];
346aaaba 163 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 164 }
346aaaba 165 return Civi::$statics[__CLASS__]['fields'];
e501603b 166 }
c3fc2621 167
e501603b 168 /**
bd8e0b14 169 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
170 *
171 * @return array
bd8e0b14 172 * Array(string $name => string $uniqueName).
e501603b 173 */
c3fc2621 174 public static function &fieldKeys() {
bd8e0b14
TO
175 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
176 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 177 }
bd8e0b14 178 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 179 }
c3fc2621 180
e501603b
TO
181 /**
182 * Returns the names of this table
183 *
184 * @return string
185 */
c3fc2621 186 public static function getTableName() {
e501603b
TO
187 return self::$_tableName;
188 }
c3fc2621 189
e501603b
TO
190 /**
191 * Returns if this table needs to be logged
192 *
c3fc2621 193 * @return bool
e501603b 194 */
c3fc2621 195 public function getLog() {
e501603b
TO
196 return self::$_log;
197 }
c3fc2621 198
e501603b
TO
199 /**
200 * Returns the list of fields that can be imported
201 *
202 * @param bool $prefix
203 *
204 * @return array
205 */
c3fc2621
CW
206 public static function &import($prefix = FALSE) {
207 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'activity_contact', $prefix, []);
60808919 208 return $r;
e501603b 209 }
c3fc2621 210
e501603b
TO
211 /**
212 * Returns the list of fields that can be exported
213 *
214 * @param bool $prefix
215 *
216 * @return array
217 */
c3fc2621
CW
218 public static function &export($prefix = FALSE) {
219 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'activity_contact', $prefix, []);
60808919 220 return $r;
e501603b 221 }
c3fc2621 222
e7a6b91a
AS
223 /**
224 * Returns the list of indices
c3fc2621
CW
225 *
226 * @param bool $localize
227 *
228 * @return array
e7a6b91a
AS
229 */
230 public static function indices($localize = TRUE) {
c3fc2621
CW
231 $indices = [
232 'UI_activity_contact' => [
e7a6b91a 233 'name' => 'UI_activity_contact',
c3fc2621 234 'field' => [
e7a6b91a
AS
235 0 => 'contact_id',
236 1 => 'activity_id',
237 2 => 'record_type_id',
c3fc2621
CW
238 ],
239 'localizable' => FALSE,
240 'unique' => TRUE,
e7a6b91a 241 'sig' => 'civicrm_activity_contact::1::contact_id::activity_id::record_type_id',
c3fc2621
CW
242 ],
243 'index_record_type' => [
e7a6b91a 244 'name' => 'index_record_type',
c3fc2621 245 'field' => [
e7a6b91a
AS
246 0 => 'activity_id',
247 1 => 'record_type_id',
c3fc2621
CW
248 ],
249 'localizable' => FALSE,
e7a6b91a 250 'sig' => 'civicrm_activity_contact::0::activity_id::record_type_id',
c3fc2621
CW
251 ],
252 ];
e7a6b91a
AS
253 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
254 }
c3fc2621 255
e501603b 256}