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