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