Regenerate DAOs with readonly attribute for id fields
[civicrm-core.git] / CRM / Core / DAO / IM.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Core/IM.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:5607b27ff96ad39ec97877d089b4a9e3)
10 */
11
12 /**
13 * Database access object for the IM entity.
14 */
15 class CRM_Core_DAO_IM extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.1';
18
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
24 public static $_tableName = 'civicrm_im';
25
26 /**
27 * Icon associated with this entity.
28 *
29 * @var string
30 */
31 public static $_icon = 'fa-comments-o';
32
33 /**
34 * Field to show when displaying a record.
35 *
36 * @var string
37 */
38 public static $_labelField = 'name';
39
40 /**
41 * Should CiviCRM log any modifications to this table in the civicrm_log table.
42 *
43 * @var bool
44 */
45 public static $_log = TRUE;
46
47 /**
48 * Unique IM ID
49 *
50 * @var int
51 */
52 public $id;
53
54 /**
55 * FK to Contact ID
56 *
57 * @var int
58 */
59 public $contact_id;
60
61 /**
62 * Which Location does this email belong to.
63 *
64 * @var int
65 */
66 public $location_type_id;
67
68 /**
69 * IM screen name
70 *
71 * @var string
72 */
73 public $name;
74
75 /**
76 * Which IM Provider does this screen name belong to.
77 *
78 * @var int
79 */
80 public $provider_id;
81
82 /**
83 * Is this the primary IM for this contact and location.
84 *
85 * @var bool
86 */
87 public $is_primary;
88
89 /**
90 * Is this the billing?
91 *
92 * @var bool
93 */
94 public $is_billing;
95
96 /**
97 * Class constructor.
98 */
99 public function __construct() {
100 $this->__table = 'civicrm_im';
101 parent::__construct();
102 }
103
104 /**
105 * Returns localized title of this entity.
106 *
107 * @param bool $plural
108 * Whether to return the plural version of the title.
109 */
110 public static function getEntityTitle($plural = FALSE) {
111 return $plural ? ts('Instant Messaging') : ts('Instant Messaging');
112 }
113
114 /**
115 * Returns foreign keys and entity references.
116 *
117 * @return array
118 * [CRM_Core_Reference_Interface]
119 */
120 public static function getReferenceColumns() {
121 if (!isset(Civi::$statics[__CLASS__]['links'])) {
122 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
123 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
124 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
125 }
126 return Civi::$statics[__CLASS__]['links'];
127 }
128
129 /**
130 * Returns all the column names of this table
131 *
132 * @return array
133 */
134 public static function &fields() {
135 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
136 Civi::$statics[__CLASS__]['fields'] = [
137 'id' => [
138 'name' => 'id',
139 'type' => CRM_Utils_Type::T_INT,
140 'title' => ts('Instant Messenger ID'),
141 'description' => ts('Unique IM ID'),
142 'required' => TRUE,
143 'where' => 'civicrm_im.id',
144 'table_name' => 'civicrm_im',
145 'entity' => 'IM',
146 'bao' => 'CRM_Core_BAO_IM',
147 'localizable' => 0,
148 'html' => [
149 'type' => 'Number',
150 ],
151 'readonly' => TRUE,
152 'add' => '1.1',
153 ],
154 'contact_id' => [
155 'name' => 'contact_id',
156 'type' => CRM_Utils_Type::T_INT,
157 'title' => ts('Contact ID'),
158 'description' => ts('FK to Contact ID'),
159 'where' => 'civicrm_im.contact_id',
160 'table_name' => 'civicrm_im',
161 'entity' => 'IM',
162 'bao' => 'CRM_Core_BAO_IM',
163 'localizable' => 0,
164 'FKClassName' => 'CRM_Contact_DAO_Contact',
165 'html' => [
166 'label' => ts("Contact"),
167 ],
168 'add' => '2.0',
169 ],
170 'location_type_id' => [
171 'name' => 'location_type_id',
172 'type' => CRM_Utils_Type::T_INT,
173 'title' => ts('IM Location Type'),
174 'description' => ts('Which Location does this email belong to.'),
175 'where' => 'civicrm_im.location_type_id',
176 'table_name' => 'civicrm_im',
177 'entity' => 'IM',
178 'bao' => 'CRM_Core_BAO_IM',
179 'localizable' => 0,
180 'html' => [
181 'type' => 'Select',
182 ],
183 'pseudoconstant' => [
184 'table' => 'civicrm_location_type',
185 'keyColumn' => 'id',
186 'labelColumn' => 'display_name',
187 ],
188 'add' => '2.0',
189 ],
190 'name' => [
191 'name' => 'name',
192 'type' => CRM_Utils_Type::T_STRING,
193 'title' => ts('IM Screen Name'),
194 'description' => ts('IM screen name'),
195 'maxlength' => 64,
196 'size' => CRM_Utils_Type::BIG,
197 'import' => TRUE,
198 'where' => 'civicrm_im.name',
199 'headerPattern' => '/I(nstant )?M(ess.*)?|screen(\s+)?name/i',
200 'dataPattern' => '/^[A-Za-z][0-9A-Za-z]{20,}$/',
201 'export' => TRUE,
202 'table_name' => 'civicrm_im',
203 'entity' => 'IM',
204 'bao' => 'CRM_Core_BAO_IM',
205 'localizable' => 0,
206 'html' => [
207 'type' => 'Text',
208 ],
209 'add' => '1.1',
210 ],
211 'provider_id' => [
212 'name' => 'provider_id',
213 'type' => CRM_Utils_Type::T_INT,
214 'title' => ts('IM Provider'),
215 'description' => ts('Which IM Provider does this screen name belong to.'),
216 'where' => 'civicrm_im.provider_id',
217 'table_name' => 'civicrm_im',
218 'entity' => 'IM',
219 'bao' => 'CRM_Core_BAO_IM',
220 'localizable' => 0,
221 'html' => [
222 'type' => 'Select',
223 ],
224 'pseudoconstant' => [
225 'optionGroupName' => 'instant_messenger_service',
226 'optionEditPath' => 'civicrm/admin/options/instant_messenger_service',
227 ],
228 'add' => '1.1',
229 ],
230 'is_primary' => [
231 'name' => 'is_primary',
232 'type' => CRM_Utils_Type::T_BOOLEAN,
233 'title' => ts('Primary IM'),
234 'description' => ts('Is this the primary IM for this contact and location.'),
235 'where' => 'civicrm_im.is_primary',
236 'default' => '0',
237 'table_name' => 'civicrm_im',
238 'entity' => 'IM',
239 'bao' => 'CRM_Core_BAO_IM',
240 'localizable' => 0,
241 'html' => [
242 'type' => 'Radio',
243 ],
244 'add' => '1.1',
245 ],
246 'is_billing' => [
247 'name' => 'is_billing',
248 'type' => CRM_Utils_Type::T_BOOLEAN,
249 'title' => ts('Is IM Billing?'),
250 'description' => ts('Is this the billing?'),
251 'where' => 'civicrm_im.is_billing',
252 'default' => '0',
253 'table_name' => 'civicrm_im',
254 'entity' => 'IM',
255 'bao' => 'CRM_Core_BAO_IM',
256 'localizable' => 0,
257 'add' => '2.0',
258 ],
259 ];
260 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
261 }
262 return Civi::$statics[__CLASS__]['fields'];
263 }
264
265 /**
266 * Return a mapping from field-name to the corresponding key (as used in fields()).
267 *
268 * @return array
269 * Array(string $name => string $uniqueName).
270 */
271 public static function &fieldKeys() {
272 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
273 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
274 }
275 return Civi::$statics[__CLASS__]['fieldKeys'];
276 }
277
278 /**
279 * Returns the names of this table
280 *
281 * @return string
282 */
283 public static function getTableName() {
284 return self::$_tableName;
285 }
286
287 /**
288 * Returns if this table needs to be logged
289 *
290 * @return bool
291 */
292 public function getLog() {
293 return self::$_log;
294 }
295
296 /**
297 * Returns the list of fields that can be imported
298 *
299 * @param bool $prefix
300 *
301 * @return array
302 */
303 public static function &import($prefix = FALSE) {
304 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'im', $prefix, []);
305 return $r;
306 }
307
308 /**
309 * Returns the list of fields that can be exported
310 *
311 * @param bool $prefix
312 *
313 * @return array
314 */
315 public static function &export($prefix = FALSE) {
316 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'im', $prefix, []);
317 return $r;
318 }
319
320 /**
321 * Returns the list of indices
322 *
323 * @param bool $localize
324 *
325 * @return array
326 */
327 public static function indices($localize = TRUE) {
328 $indices = [
329 'index_location_type' => [
330 'name' => 'index_location_type',
331 'field' => [
332 0 => 'location_type_id',
333 ],
334 'localizable' => FALSE,
335 'sig' => 'civicrm_im::0::location_type_id',
336 ],
337 'UI_provider_id' => [
338 'name' => 'UI_provider_id',
339 'field' => [
340 0 => 'provider_id',
341 ],
342 'localizable' => FALSE,
343 'sig' => 'civicrm_im::0::provider_id',
344 ],
345 'index_is_primary' => [
346 'name' => 'index_is_primary',
347 'field' => [
348 0 => 'is_primary',
349 ],
350 'localizable' => FALSE,
351 'sig' => 'civicrm_im::0::is_primary',
352 ],
353 'index_is_billing' => [
354 'name' => 'index_is_billing',
355 'field' => [
356 0 => 'is_billing',
357 ],
358 'localizable' => FALSE,
359 'sig' => 'civicrm_im::0::is_billing',
360 ],
361 ];
362 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
363 }
364
365 }