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