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