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