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