Merge pull request #23942 from tschuettler/3717-sort-mapping-page
[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:aa43f28e70d1de3571aa1775f71d7990)
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|string|null
51 * (SQL type: int unsigned)
52 * Note that values will be retrieved from the database as a string.
53 */
54 public $id;
55
56 /**
57 * FK to Contact ID
58 *
59 * @var int|string|null
60 * (SQL type: int unsigned)
61 * Note that values will be retrieved from the database as a string.
62 */
63 public $contact_id;
64
65 /**
66 * Which Location does this email belong to.
67 *
68 * @var int|string|null
69 * (SQL type: int unsigned)
70 * Note that values will be retrieved from the database as a string.
71 */
72 public $location_type_id;
73
74 /**
75 * IM screen name
76 *
77 * @var string|null
78 * (SQL type: varchar(64))
79 * Note that values will be retrieved from the database as a string.
80 */
81 public $name;
82
83 /**
84 * Which IM Provider does this screen name belong to.
85 *
86 * @var int|string|null
87 * (SQL type: int unsigned)
88 * Note that values will be retrieved from the database as a string.
89 */
90 public $provider_id;
91
92 /**
93 * Is this the primary IM for this contact and location.
94 *
95 * @var bool|string
96 * (SQL type: tinyint)
97 * Note that values will be retrieved from the database as a string.
98 */
99 public $is_primary;
100
101 /**
102 * Is this the billing?
103 *
104 * @var bool|string
105 * (SQL type: tinyint)
106 * Note that values will be retrieved from the database as a string.
107 */
108 public $is_billing;
109
110 /**
111 * Class constructor.
112 */
113 public function __construct() {
114 $this->__table = 'civicrm_im';
115 parent::__construct();
116 }
117
118 /**
119 * Returns localized title of this entity.
120 *
121 * @param bool $plural
122 * Whether to return the plural version of the title.
123 */
124 public static function getEntityTitle($plural = FALSE) {
125 return $plural ? ts('Instant Messaging') : ts('Instant Messaging');
126 }
127
128 /**
129 * Returns foreign keys and entity references.
130 *
131 * @return array
132 * [CRM_Core_Reference_Interface]
133 */
134 public static function getReferenceColumns() {
135 if (!isset(Civi::$statics[__CLASS__]['links'])) {
136 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
137 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
138 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
139 }
140 return Civi::$statics[__CLASS__]['links'];
141 }
142
143 /**
144 * Returns all the column names of this table
145 *
146 * @return array
147 */
148 public static function &fields() {
149 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
150 Civi::$statics[__CLASS__]['fields'] = [
151 'id' => [
152 'name' => 'id',
153 'type' => CRM_Utils_Type::T_INT,
154 'title' => ts('Instant Messenger ID'),
155 'description' => ts('Unique IM ID'),
156 'required' => TRUE,
157 'where' => 'civicrm_im.id',
158 'table_name' => 'civicrm_im',
159 'entity' => 'IM',
160 'bao' => 'CRM_Core_BAO_IM',
161 'localizable' => 0,
162 'html' => [
163 'type' => 'Number',
164 ],
165 'readonly' => TRUE,
166 'add' => '1.1',
167 ],
168 'contact_id' => [
169 'name' => 'contact_id',
170 'type' => CRM_Utils_Type::T_INT,
171 'title' => ts('Contact ID'),
172 'description' => ts('FK to Contact ID'),
173 'where' => 'civicrm_im.contact_id',
174 'table_name' => 'civicrm_im',
175 'entity' => 'IM',
176 'bao' => 'CRM_Core_BAO_IM',
177 'localizable' => 0,
178 'FKClassName' => 'CRM_Contact_DAO_Contact',
179 'html' => [
180 'label' => ts("Contact"),
181 ],
182 'add' => '2.0',
183 ],
184 'location_type_id' => [
185 'name' => 'location_type_id',
186 'type' => CRM_Utils_Type::T_INT,
187 'title' => ts('IM Location Type'),
188 'description' => ts('Which Location does this email belong to.'),
189 'where' => 'civicrm_im.location_type_id',
190 'table_name' => 'civicrm_im',
191 'entity' => 'IM',
192 'bao' => 'CRM_Core_BAO_IM',
193 'localizable' => 0,
194 'html' => [
195 'type' => 'Select',
196 ],
197 'pseudoconstant' => [
198 'table' => 'civicrm_location_type',
199 'keyColumn' => 'id',
200 'labelColumn' => 'display_name',
201 ],
202 'add' => '2.0',
203 ],
204 'name' => [
205 'name' => 'name',
206 'type' => CRM_Utils_Type::T_STRING,
207 'title' => ts('IM Screen Name'),
208 'description' => ts('IM screen name'),
209 'maxlength' => 64,
210 'size' => CRM_Utils_Type::BIG,
211 'import' => TRUE,
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,}$/',
215 'export' => TRUE,
216 'table_name' => 'civicrm_im',
217 'entity' => 'IM',
218 'bao' => 'CRM_Core_BAO_IM',
219 'localizable' => 0,
220 'html' => [
221 'type' => 'Text',
222 ],
223 'add' => '1.1',
224 ],
225 'provider_id' => [
226 'name' => 'provider_id',
227 'type' => CRM_Utils_Type::T_INT,
228 'title' => ts('IM Provider'),
229 'description' => ts('Which IM Provider does this screen name belong to.'),
230 'where' => 'civicrm_im.provider_id',
231 'table_name' => 'civicrm_im',
232 'entity' => 'IM',
233 'bao' => 'CRM_Core_BAO_IM',
234 'localizable' => 0,
235 'html' => [
236 'type' => 'Select',
237 ],
238 'pseudoconstant' => [
239 'optionGroupName' => 'instant_messenger_service',
240 'optionEditPath' => 'civicrm/admin/options/instant_messenger_service',
241 ],
242 'add' => '1.1',
243 ],
244 'is_primary' => [
245 'name' => 'is_primary',
246 'type' => CRM_Utils_Type::T_BOOLEAN,
247 'title' => ts('Primary IM'),
248 'description' => ts('Is this the primary IM for this contact and location.'),
249 'required' => TRUE,
250 'where' => 'civicrm_im.is_primary',
251 'default' => '0',
252 'table_name' => 'civicrm_im',
253 'entity' => 'IM',
254 'bao' => 'CRM_Core_BAO_IM',
255 'localizable' => 0,
256 'html' => [
257 'type' => 'Radio',
258 ],
259 'add' => '1.1',
260 ],
261 'is_billing' => [
262 'name' => 'is_billing',
263 'type' => CRM_Utils_Type::T_BOOLEAN,
264 'title' => ts('Is IM Billing?'),
265 'description' => ts('Is this the billing?'),
266 'required' => TRUE,
267 'where' => 'civicrm_im.is_billing',
268 'default' => '0',
269 'table_name' => 'civicrm_im',
270 'entity' => 'IM',
271 'bao' => 'CRM_Core_BAO_IM',
272 'localizable' => 0,
273 'add' => '2.0',
274 ],
275 ];
276 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
277 }
278 return Civi::$statics[__CLASS__]['fields'];
279 }
280
281 /**
282 * Return a mapping from field-name to the corresponding key (as used in fields()).
283 *
284 * @return array
285 * Array(string $name => string $uniqueName).
286 */
287 public static function &fieldKeys() {
288 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
289 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
290 }
291 return Civi::$statics[__CLASS__]['fieldKeys'];
292 }
293
294 /**
295 * Returns the names of this table
296 *
297 * @return string
298 */
299 public static function getTableName() {
300 return self::$_tableName;
301 }
302
303 /**
304 * Returns if this table needs to be logged
305 *
306 * @return bool
307 */
308 public function getLog() {
309 return self::$_log;
310 }
311
312 /**
313 * Returns the list of fields that can be imported
314 *
315 * @param bool $prefix
316 *
317 * @return array
318 */
319 public static function &import($prefix = FALSE) {
320 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'im', $prefix, []);
321 return $r;
322 }
323
324 /**
325 * Returns the list of fields that can be exported
326 *
327 * @param bool $prefix
328 *
329 * @return array
330 */
331 public static function &export($prefix = FALSE) {
332 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'im', $prefix, []);
333 return $r;
334 }
335
336 /**
337 * Returns the list of indices
338 *
339 * @param bool $localize
340 *
341 * @return array
342 */
343 public static function indices($localize = TRUE) {
344 $indices = [
345 'index_location_type' => [
346 'name' => 'index_location_type',
347 'field' => [
348 0 => 'location_type_id',
349 ],
350 'localizable' => FALSE,
351 'sig' => 'civicrm_im::0::location_type_id',
352 ],
353 'UI_provider_id' => [
354 'name' => 'UI_provider_id',
355 'field' => [
356 0 => 'provider_id',
357 ],
358 'localizable' => FALSE,
359 'sig' => 'civicrm_im::0::provider_id',
360 ],
361 'index_is_primary' => [
362 'name' => 'index_is_primary',
363 'field' => [
364 0 => 'is_primary',
365 ],
366 'localizable' => FALSE,
367 'sig' => 'civicrm_im::0::is_primary',
368 ],
369 'index_is_billing' => [
370 'name' => 'index_is_billing',
371 'field' => [
372 0 => 'is_billing',
373 ],
374 'localizable' => FALSE,
375 'sig' => 'civicrm_im::0::is_billing',
376 ],
377 ];
378 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
379 }
380
381 }