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