Commit | Line | Data |
---|---|---|
e501603b | 1 | <?php |
c3fc2621 | 2 | |
e501603b TO |
3 | /** |
4 | * @package CRM | |
8c9251b3 | 5 | * @copyright CiviCRM LLC (c) 2004-2018 |
e501603b TO |
6 | * |
7 | * Generated from xml/schema/CRM/Core/IM.xml | |
8 | * DO NOT EDIT. Generated by CRM_Core_CodeGen | |
e7a6b91a | 9 | * (GenCodeChecksum:fe754a68bdda23ca881ac6425750eeba) |
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 | */ | |
22 | 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 | */ |
c3fc2621 CW |
29 | static $_log = TRUE; |
30 | ||
e501603b TO |
31 | /** |
32 | * Unique IM ID | |
33 | * | |
34 | * @var int unsigned | |
35 | */ | |
36 | public $id; | |
c3fc2621 | 37 | |
e501603b TO |
38 | /** |
39 | * FK to Contact ID | |
40 | * | |
41 | * @var int unsigned | |
42 | */ | |
43 | public $contact_id; | |
c3fc2621 | 44 | |
e501603b TO |
45 | /** |
46 | * Which Location does this email belong to. | |
47 | * | |
48 | * @var int unsigned | |
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 | * | |
62 | * @var int unsigned | |
63 | */ | |
64 | public $provider_id; | |
c3fc2621 | 65 | |
e501603b TO |
66 | /** |
67 | * Is this the primary IM for this contact and location. | |
68 | * | |
69 | * @var boolean | |
70 | */ | |
71 | public $is_primary; | |
c3fc2621 | 72 | |
e501603b TO |
73 | /** |
74 | * Is this the billing? | |
75 | * | |
76 | * @var boolean | |
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 TO |
95 | if (!isset(Civi::$statics[__CLASS__]['links'])) { |
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'), |
e501603b | 115 | 'description' => 'Unique IM ID', |
c3fc2621 | 116 | 'required' => TRUE, |
522a26c9 | 117 | 'table_name' => 'civicrm_im', |
118 | 'entity' => 'IM', | |
119 | 'bao' => 'CRM_Core_BAO_IM', | |
6a7e5e5d | 120 | 'localizable' => 0, |
c3fc2621 CW |
121 | ], |
122 | 'contact_id' => [ | |
e501603b TO |
123 | 'name' => 'contact_id', |
124 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 125 | 'title' => ts('IM Contact'), |
e501603b | 126 | 'description' => 'FK to Contact ID', |
522a26c9 | 127 | 'table_name' => 'civicrm_im', |
128 | 'entity' => 'IM', | |
129 | 'bao' => 'CRM_Core_BAO_IM', | |
6a7e5e5d | 130 | 'localizable' => 0, |
e501603b | 131 | 'FKClassName' => 'CRM_Contact_DAO_Contact', |
c3fc2621 CW |
132 | ], |
133 | 'location_type_id' => [ | |
e501603b TO |
134 | 'name' => 'location_type_id', |
135 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 136 | 'title' => ts('IM Location Type'), |
e501603b | 137 | 'description' => 'Which Location does this email belong to.', |
522a26c9 | 138 | 'table_name' => 'civicrm_im', |
139 | 'entity' => 'IM', | |
140 | 'bao' => 'CRM_Core_BAO_IM', | |
6a7e5e5d | 141 | 'localizable' => 0, |
c3fc2621 | 142 | 'html' => [ |
e501603b | 143 | 'type' => 'Select', |
c3fc2621 CW |
144 | ], |
145 | 'pseudoconstant' => [ | |
e501603b TO |
146 | 'table' => 'civicrm_location_type', |
147 | 'keyColumn' => 'id', | |
148 | 'labelColumn' => 'display_name', | |
c3fc2621 CW |
149 | ] |
150 | ], | |
151 | 'name' => [ | |
e501603b TO |
152 | 'name' => 'name', |
153 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 154 | 'title' => ts('IM Screen Name'), |
e501603b TO |
155 | 'description' => 'IM screen name', |
156 | 'maxlength' => 64, | |
157 | 'size' => CRM_Utils_Type::BIG, | |
c3fc2621 | 158 | 'import' => TRUE, |
e501603b TO |
159 | 'where' => 'civicrm_im.name', |
160 | 'headerPattern' => '/I(nstant )?M(ess.*)?|screen(\s+)?name/i', | |
161 | 'dataPattern' => '/^[A-Za-z][0-9A-Za-z]{20,}$/', | |
c3fc2621 | 162 | 'export' => TRUE, |
522a26c9 | 163 | 'table_name' => 'civicrm_im', |
164 | 'entity' => 'IM', | |
165 | 'bao' => 'CRM_Core_BAO_IM', | |
6a7e5e5d | 166 | 'localizable' => 0, |
c3fc2621 | 167 | 'html' => [ |
e501603b | 168 | 'type' => 'Text', |
c3fc2621 CW |
169 | ], |
170 | ], | |
171 | 'provider_id' => [ | |
e501603b TO |
172 | 'name' => 'provider_id', |
173 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 174 | 'title' => ts('IM Provider'), |
e501603b | 175 | 'description' => 'Which IM Provider does this screen name belong to.', |
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 | 'optionGroupName' => 'instant_messenger_service', |
185 | 'optionEditPath' => 'civicrm/admin/options/instant_messenger_service', | |
c3fc2621 CW |
186 | ] |
187 | ], | |
188 | 'is_primary' => [ | |
e501603b TO |
189 | 'name' => 'is_primary', |
190 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
c3fc2621 | 191 | 'title' => ts('Is IM Primary?'), |
e501603b | 192 | 'description' => 'Is this the primary IM for this contact and location.', |
522a26c9 | 193 | 'table_name' => 'civicrm_im', |
194 | 'entity' => 'IM', | |
195 | 'bao' => 'CRM_Core_BAO_IM', | |
6a7e5e5d | 196 | 'localizable' => 0, |
c3fc2621 CW |
197 | ], |
198 | 'is_billing' => [ | |
e501603b TO |
199 | 'name' => 'is_billing', |
200 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
c3fc2621 | 201 | 'title' => ts('Is IM Billing?'), |
e501603b | 202 | 'description' => 'Is this the billing?', |
522a26c9 | 203 | 'table_name' => 'civicrm_im', |
204 | 'entity' => 'IM', | |
205 | 'bao' => 'CRM_Core_BAO_IM', | |
6a7e5e5d | 206 | 'localizable' => 0, |
c3fc2621 CW |
207 | ], |
208 | ]; | |
346aaaba | 209 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); |
e501603b | 210 | } |
346aaaba | 211 | return Civi::$statics[__CLASS__]['fields']; |
e501603b | 212 | } |
c3fc2621 | 213 | |
e501603b | 214 | /** |
bd8e0b14 | 215 | * Return a mapping from field-name to the corresponding key (as used in fields()). |
e501603b TO |
216 | * |
217 | * @return array | |
bd8e0b14 | 218 | * Array(string $name => string $uniqueName). |
e501603b | 219 | */ |
c3fc2621 | 220 | public static function &fieldKeys() { |
bd8e0b14 TO |
221 | if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { |
222 | Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); | |
e501603b | 223 | } |
bd8e0b14 | 224 | return Civi::$statics[__CLASS__]['fieldKeys']; |
e501603b | 225 | } |
c3fc2621 | 226 | |
e501603b TO |
227 | /** |
228 | * Returns the names of this table | |
229 | * | |
230 | * @return string | |
231 | */ | |
c3fc2621 | 232 | public static function getTableName() { |
e501603b TO |
233 | return self::$_tableName; |
234 | } | |
c3fc2621 | 235 | |
e501603b TO |
236 | /** |
237 | * Returns if this table needs to be logged | |
238 | * | |
c3fc2621 | 239 | * @return bool |
e501603b | 240 | */ |
c3fc2621 | 241 | public function getLog() { |
e501603b TO |
242 | return self::$_log; |
243 | } | |
c3fc2621 | 244 | |
e501603b TO |
245 | /** |
246 | * Returns the list of fields that can be imported | |
247 | * | |
248 | * @param bool $prefix | |
249 | * | |
250 | * @return array | |
251 | */ | |
c3fc2621 CW |
252 | public static function &import($prefix = FALSE) { |
253 | $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'im', $prefix, []); | |
60808919 | 254 | return $r; |
e501603b | 255 | } |
c3fc2621 | 256 | |
e501603b TO |
257 | /** |
258 | * Returns the list of fields that can be exported | |
259 | * | |
260 | * @param bool $prefix | |
261 | * | |
262 | * @return array | |
263 | */ | |
c3fc2621 CW |
264 | public static function &export($prefix = FALSE) { |
265 | $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'im', $prefix, []); | |
60808919 | 266 | return $r; |
e501603b | 267 | } |
c3fc2621 | 268 | |
e7a6b91a AS |
269 | /** |
270 | * Returns the list of indices | |
c3fc2621 CW |
271 | * |
272 | * @param bool $localize | |
273 | * | |
274 | * @return array | |
e7a6b91a AS |
275 | */ |
276 | public static function indices($localize = TRUE) { | |
c3fc2621 CW |
277 | $indices = [ |
278 | 'index_location_type' => [ | |
e7a6b91a | 279 | 'name' => 'index_location_type', |
c3fc2621 | 280 | 'field' => [ |
e7a6b91a | 281 | 0 => 'location_type_id', |
c3fc2621 CW |
282 | ], |
283 | 'localizable' => FALSE, | |
e7a6b91a | 284 | 'sig' => 'civicrm_im::0::location_type_id', |
c3fc2621 CW |
285 | ], |
286 | 'UI_provider_id' => [ | |
e7a6b91a | 287 | 'name' => 'UI_provider_id', |
c3fc2621 | 288 | 'field' => [ |
e7a6b91a | 289 | 0 => 'provider_id', |
c3fc2621 CW |
290 | ], |
291 | 'localizable' => FALSE, | |
e7a6b91a | 292 | 'sig' => 'civicrm_im::0::provider_id', |
c3fc2621 CW |
293 | ], |
294 | 'index_is_primary' => [ | |
e7a6b91a | 295 | 'name' => 'index_is_primary', |
c3fc2621 | 296 | 'field' => [ |
e7a6b91a | 297 | 0 => 'is_primary', |
c3fc2621 CW |
298 | ], |
299 | 'localizable' => FALSE, | |
e7a6b91a | 300 | 'sig' => 'civicrm_im::0::is_primary', |
c3fc2621 CW |
301 | ], |
302 | 'index_is_billing' => [ | |
e7a6b91a | 303 | 'name' => 'index_is_billing', |
c3fc2621 | 304 | 'field' => [ |
e7a6b91a | 305 | 0 => 'is_billing', |
c3fc2621 CW |
306 | ], |
307 | 'localizable' => FALSE, | |
e7a6b91a | 308 | 'sig' => 'civicrm_im::0::is_billing', |
c3fc2621 CW |
309 | ], |
310 | ]; | |
e7a6b91a AS |
311 | return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; |
312 | } | |
c3fc2621 | 313 | |
e501603b | 314 | } |