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