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/Address.xml | |
8 | * DO NOT EDIT. Generated by CRM_Core_CodeGen | |
207f62c6 | 9 | * (GenCodeChecksum:472057d193d1e875a14e7719a2d6a2ee) |
e501603b | 10 | */ |
c3fc2621 | 11 | |
f41f0342 | 12 | /** |
c3fc2621 | 13 | * Database access object for the Address entity. |
f41f0342 | 14 | */ |
e501603b | 15 | class CRM_Core_DAO_Address 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_address'; | |
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 Address 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 address belong to. | |
47 | * | |
48 | * @var int unsigned | |
49 | */ | |
50 | public $location_type_id; | |
c3fc2621 | 51 | |
e501603b TO |
52 | /** |
53 | * Is this the primary address. | |
54 | * | |
55 | * @var boolean | |
56 | */ | |
57 | public $is_primary; | |
c3fc2621 | 58 | |
e501603b TO |
59 | /** |
60 | * Is this the billing address. | |
61 | * | |
62 | * @var boolean | |
63 | */ | |
64 | public $is_billing; | |
c3fc2621 | 65 | |
e501603b TO |
66 | /** |
67 | * Concatenation of all routable street address components (prefix, street number, street name, suffix, unit | |
68 | number OR P.O. Box). Apps should be able to determine physical location with this data (for mapping, mail | |
69 | delivery, etc.). | |
70 | * | |
71 | * @var string | |
72 | */ | |
73 | public $street_address; | |
c3fc2621 | 74 | |
e501603b TO |
75 | /** |
76 | * Numeric portion of address number on the street, e.g. For 112A Main St, the street_number = 112. | |
77 | * | |
78 | * @var int | |
79 | */ | |
80 | public $street_number; | |
c3fc2621 | 81 | |
e501603b TO |
82 | /** |
83 | * Non-numeric portion of address number on the street, e.g. For 112A Main St, the street_number_suffix = A | |
84 | * | |
85 | * @var string | |
86 | */ | |
87 | public $street_number_suffix; | |
c3fc2621 | 88 | |
e501603b TO |
89 | /** |
90 | * Directional prefix, e.g. SE Main St, SE is the prefix. | |
91 | * | |
92 | * @var string | |
93 | */ | |
94 | public $street_number_predirectional; | |
c3fc2621 | 95 | |
e501603b TO |
96 | /** |
97 | * Actual street name, excluding St, Dr, Rd, Ave, e.g. For 112 Main St, the street_name = Main. | |
98 | * | |
99 | * @var string | |
100 | */ | |
101 | public $street_name; | |
c3fc2621 | 102 | |
e501603b TO |
103 | /** |
104 | * St, Rd, Dr, etc. | |
105 | * | |
106 | * @var string | |
107 | */ | |
108 | public $street_type; | |
c3fc2621 | 109 | |
e501603b TO |
110 | /** |
111 | * Directional prefix, e.g. Main St S, S is the suffix. | |
112 | * | |
113 | * @var string | |
114 | */ | |
115 | public $street_number_postdirectional; | |
c3fc2621 | 116 | |
e501603b TO |
117 | /** |
118 | * Secondary unit designator, e.g. Apt 3 or Unit # 14, or Bldg 1200 | |
119 | * | |
120 | * @var string | |
121 | */ | |
122 | public $street_unit; | |
c3fc2621 | 123 | |
e501603b TO |
124 | /** |
125 | * Supplemental Address Information, Line 1 | |
126 | * | |
127 | * @var string | |
128 | */ | |
129 | public $supplemental_address_1; | |
c3fc2621 | 130 | |
e501603b TO |
131 | /** |
132 | * Supplemental Address Information, Line 2 | |
133 | * | |
134 | * @var string | |
135 | */ | |
136 | public $supplemental_address_2; | |
c3fc2621 | 137 | |
e501603b TO |
138 | /** |
139 | * Supplemental Address Information, Line 3 | |
140 | * | |
141 | * @var string | |
142 | */ | |
143 | public $supplemental_address_3; | |
c3fc2621 | 144 | |
e501603b TO |
145 | /** |
146 | * City, Town or Village Name. | |
147 | * | |
148 | * @var string | |
149 | */ | |
150 | public $city; | |
c3fc2621 | 151 | |
e501603b TO |
152 | /** |
153 | * Which County does this address belong to. | |
154 | * | |
155 | * @var int unsigned | |
156 | */ | |
157 | public $county_id; | |
c3fc2621 | 158 | |
e501603b TO |
159 | /** |
160 | * Which State_Province does this address belong to. | |
161 | * | |
162 | * @var int unsigned | |
163 | */ | |
164 | public $state_province_id; | |
c3fc2621 | 165 | |
e501603b TO |
166 | /** |
167 | * Store the suffix, like the +4 part in the USPS system. | |
168 | * | |
169 | * @var string | |
170 | */ | |
171 | public $postal_code_suffix; | |
c3fc2621 | 172 | |
e501603b TO |
173 | /** |
174 | * Store both US (zip5) AND international postal codes. App is responsible for country/region appropriate validation. | |
175 | * | |
176 | * @var string | |
177 | */ | |
178 | public $postal_code; | |
c3fc2621 | 179 | |
e501603b TO |
180 | /** |
181 | * USPS Bulk mailing code. | |
182 | * | |
183 | * @var string | |
184 | */ | |
185 | public $usps_adc; | |
c3fc2621 | 186 | |
e501603b TO |
187 | /** |
188 | * Which Country does this address belong to. | |
189 | * | |
190 | * @var int unsigned | |
191 | */ | |
192 | public $country_id; | |
c3fc2621 | 193 | |
e501603b TO |
194 | /** |
195 | * Latitude | |
196 | * | |
197 | * @var float | |
198 | */ | |
199 | public $geo_code_1; | |
c3fc2621 | 200 | |
e501603b TO |
201 | /** |
202 | * Longitude | |
203 | * | |
204 | * @var float | |
205 | */ | |
206 | public $geo_code_2; | |
c3fc2621 | 207 | |
e501603b TO |
208 | /** |
209 | * Is this a manually entered geo code | |
210 | * | |
211 | * @var boolean | |
212 | */ | |
213 | public $manual_geo_code; | |
c3fc2621 | 214 | |
e501603b TO |
215 | /** |
216 | * Timezone expressed as a UTC offset - e.g. United States CST would be written as "UTC-6". | |
217 | * | |
218 | * @var string | |
219 | */ | |
220 | public $timezone; | |
c3fc2621 | 221 | |
e501603b | 222 | /** |
e501603b TO |
223 | * @var string |
224 | */ | |
225 | public $name; | |
c3fc2621 | 226 | |
e501603b TO |
227 | /** |
228 | * FK to Address ID | |
229 | * | |
230 | * @var int unsigned | |
231 | */ | |
232 | public $master_id; | |
c3fc2621 | 233 | |
e501603b | 234 | /** |
f41f0342 | 235 | * Class constructor. |
e501603b | 236 | */ |
c3fc2621 | 237 | public function __construct() { |
e501603b TO |
238 | $this->__table = 'civicrm_address'; |
239 | parent::__construct(); | |
240 | } | |
c3fc2621 | 241 | |
e501603b | 242 | /** |
f41f0342 | 243 | * Returns foreign keys and entity references. |
e501603b TO |
244 | * |
245 | * @return array | |
246 | * [CRM_Core_Reference_Interface] | |
247 | */ | |
c3fc2621 | 248 | public static function getReferenceColumns() { |
346aaaba TO |
249 | if (!isset(Civi::$statics[__CLASS__]['links'])) { |
250 | Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); | |
c3fc2621 CW |
251 | Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); |
252 | Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'county_id', 'civicrm_county', 'id'); | |
253 | Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'state_province_id', 'civicrm_state_province', 'id'); | |
254 | Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'country_id', 'civicrm_country', 'id'); | |
255 | Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'master_id', 'civicrm_address', 'id'); | |
346aaaba | 256 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); |
e501603b | 257 | } |
346aaaba | 258 | return Civi::$statics[__CLASS__]['links']; |
e501603b | 259 | } |
c3fc2621 | 260 | |
e501603b TO |
261 | /** |
262 | * Returns all the column names of this table | |
263 | * | |
264 | * @return array | |
265 | */ | |
c3fc2621 | 266 | public static function &fields() { |
346aaaba | 267 | if (!isset(Civi::$statics[__CLASS__]['fields'])) { |
c3fc2621 CW |
268 | Civi::$statics[__CLASS__]['fields'] = [ |
269 | 'id' => [ | |
e501603b TO |
270 | 'name' => 'id', |
271 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 272 | 'title' => ts('Address ID'), |
e501603b | 273 | 'description' => 'Unique Address ID', |
c3fc2621 | 274 | 'required' => TRUE, |
522a26c9 | 275 | 'table_name' => 'civicrm_address', |
276 | 'entity' => 'Address', | |
277 | 'bao' => 'CRM_Core_BAO_Address', | |
6a7e5e5d | 278 | 'localizable' => 0, |
c3fc2621 CW |
279 | ], |
280 | 'contact_id' => [ | |
e501603b TO |
281 | 'name' => 'contact_id', |
282 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 283 | 'title' => ts('Contact ID'), |
e501603b | 284 | 'description' => 'FK to Contact ID', |
522a26c9 | 285 | 'table_name' => 'civicrm_address', |
286 | 'entity' => 'Address', | |
287 | 'bao' => 'CRM_Core_BAO_Address', | |
6a7e5e5d | 288 | 'localizable' => 0, |
e501603b | 289 | 'FKClassName' => 'CRM_Contact_DAO_Contact', |
c3fc2621 CW |
290 | ], |
291 | 'location_type_id' => [ | |
e501603b TO |
292 | 'name' => 'location_type_id', |
293 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 294 | 'title' => ts('Address Location Type'), |
e501603b | 295 | 'description' => 'Which Location does this address belong to.', |
522a26c9 | 296 | 'table_name' => 'civicrm_address', |
297 | 'entity' => 'Address', | |
298 | 'bao' => 'CRM_Core_BAO_Address', | |
6a7e5e5d | 299 | 'localizable' => 0, |
c3fc2621 | 300 | 'html' => [ |
e501603b | 301 | 'type' => 'Select', |
c3fc2621 CW |
302 | ], |
303 | 'pseudoconstant' => [ | |
e501603b TO |
304 | 'table' => 'civicrm_location_type', |
305 | 'keyColumn' => 'id', | |
306 | 'labelColumn' => 'display_name', | |
c3fc2621 CW |
307 | ] |
308 | ], | |
309 | 'is_primary' => [ | |
e501603b TO |
310 | 'name' => 'is_primary', |
311 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
c3fc2621 | 312 | 'title' => ts('Is Address Primary?'), |
e501603b | 313 | 'description' => 'Is this the primary address.', |
522a26c9 | 314 | 'table_name' => 'civicrm_address', |
315 | 'entity' => 'Address', | |
316 | 'bao' => 'CRM_Core_BAO_Address', | |
6a7e5e5d | 317 | 'localizable' => 0, |
c3fc2621 | 318 | 'html' => [ |
e501603b | 319 | 'type' => 'CheckBox', |
c3fc2621 CW |
320 | ], |
321 | ], | |
322 | 'is_billing' => [ | |
e501603b TO |
323 | 'name' => 'is_billing', |
324 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
c3fc2621 | 325 | 'title' => ts('Is Billing Address'), |
e501603b | 326 | 'description' => 'Is this the billing address.', |
522a26c9 | 327 | 'table_name' => 'civicrm_address', |
328 | 'entity' => 'Address', | |
329 | 'bao' => 'CRM_Core_BAO_Address', | |
6a7e5e5d | 330 | 'localizable' => 0, |
c3fc2621 | 331 | 'html' => [ |
e501603b | 332 | 'type' => 'CheckBox', |
c3fc2621 CW |
333 | ], |
334 | ], | |
335 | 'street_address' => [ | |
e501603b TO |
336 | 'name' => 'street_address', |
337 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 338 | 'title' => ts('Street Address'), |
e501603b TO |
339 | 'description' => 'Concatenation of all routable street address components (prefix, street number, street name, suffix, unit |
340 | number OR P.O. Box). Apps should be able to determine physical location with this data (for mapping, mail | |
341 | delivery, etc.). | |
342 | ', | |
343 | 'maxlength' => 96, | |
344 | 'size' => CRM_Utils_Type::HUGE, | |
c3fc2621 | 345 | 'import' => TRUE, |
e501603b TO |
346 | 'where' => 'civicrm_address.street_address', |
347 | 'headerPattern' => '/(street|address)/i', | |
348 | 'dataPattern' => '/^(\d{1,5}( [0-9A-Za-z]+)+)$|^(P\.?O\.\? Box \d{1,5})$/i', | |
c3fc2621 | 349 | 'export' => TRUE, |
522a26c9 | 350 | 'table_name' => 'civicrm_address', |
351 | 'entity' => 'Address', | |
352 | 'bao' => 'CRM_Core_BAO_Address', | |
6a7e5e5d | 353 | 'localizable' => 0, |
c3fc2621 | 354 | 'html' => [ |
e501603b | 355 | 'type' => 'Text', |
c3fc2621 CW |
356 | ], |
357 | ], | |
358 | 'street_number' => [ | |
e501603b TO |
359 | 'name' => 'street_number', |
360 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 361 | 'title' => ts('Street Number'), |
e501603b | 362 | 'description' => 'Numeric portion of address number on the street, e.g. For 112A Main St, the street_number = 112.', |
c3fc2621 | 363 | 'export' => TRUE, |
e501603b TO |
364 | 'where' => 'civicrm_address.street_number', |
365 | 'headerPattern' => '', | |
366 | 'dataPattern' => '', | |
522a26c9 | 367 | 'table_name' => 'civicrm_address', |
368 | 'entity' => 'Address', | |
369 | 'bao' => 'CRM_Core_BAO_Address', | |
6a7e5e5d | 370 | 'localizable' => 0, |
c3fc2621 | 371 | 'html' => [ |
e501603b | 372 | 'type' => 'Text', |
c3fc2621 CW |
373 | ], |
374 | ], | |
375 | 'street_number_suffix' => [ | |
e501603b TO |
376 | 'name' => 'street_number_suffix', |
377 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 378 | 'title' => ts('Street Number Suffix'), |
e501603b TO |
379 | 'description' => 'Non-numeric portion of address number on the street, e.g. For 112A Main St, the street_number_suffix = A |
380 | ', | |
381 | 'maxlength' => 8, | |
382 | 'size' => CRM_Utils_Type::EIGHT, | |
c3fc2621 | 383 | 'export' => TRUE, |
e501603b TO |
384 | 'where' => 'civicrm_address.street_number_suffix', |
385 | 'headerPattern' => '', | |
386 | 'dataPattern' => '', | |
522a26c9 | 387 | 'table_name' => 'civicrm_address', |
388 | 'entity' => 'Address', | |
389 | 'bao' => 'CRM_Core_BAO_Address', | |
6a7e5e5d | 390 | 'localizable' => 0, |
c3fc2621 | 391 | 'html' => [ |
e501603b | 392 | 'type' => 'Text', |
c3fc2621 CW |
393 | ], |
394 | ], | |
395 | 'street_number_predirectional' => [ | |
e501603b TO |
396 | 'name' => 'street_number_predirectional', |
397 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 398 | 'title' => ts('Street Direction Prefix'), |
e501603b TO |
399 | 'description' => 'Directional prefix, e.g. SE Main St, SE is the prefix.', |
400 | 'maxlength' => 8, | |
401 | 'size' => CRM_Utils_Type::EIGHT, | |
522a26c9 | 402 | 'table_name' => 'civicrm_address', |
403 | 'entity' => 'Address', | |
404 | 'bao' => 'CRM_Core_BAO_Address', | |
6a7e5e5d | 405 | 'localizable' => 0, |
c3fc2621 | 406 | 'html' => [ |
e501603b | 407 | 'type' => 'Text', |
c3fc2621 CW |
408 | ], |
409 | ], | |
410 | 'street_name' => [ | |
e501603b TO |
411 | 'name' => 'street_name', |
412 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 413 | 'title' => ts('Street Name'), |
e501603b TO |
414 | 'description' => 'Actual street name, excluding St, Dr, Rd, Ave, e.g. For 112 Main St, the street_name = Main.', |
415 | 'maxlength' => 64, | |
416 | 'size' => CRM_Utils_Type::BIG, | |
c3fc2621 | 417 | 'export' => TRUE, |
e501603b TO |
418 | 'where' => 'civicrm_address.street_name', |
419 | 'headerPattern' => '', | |
420 | 'dataPattern' => '', | |
522a26c9 | 421 | 'table_name' => 'civicrm_address', |
422 | 'entity' => 'Address', | |
423 | 'bao' => 'CRM_Core_BAO_Address', | |
6a7e5e5d | 424 | 'localizable' => 0, |
c3fc2621 | 425 | 'html' => [ |
e501603b | 426 | 'type' => 'Text', |
c3fc2621 CW |
427 | ], |
428 | ], | |
429 | 'street_type' => [ | |
e501603b TO |
430 | 'name' => 'street_type', |
431 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 432 | 'title' => ts('Street Type'), |
e501603b TO |
433 | 'description' => 'St, Rd, Dr, etc.', |
434 | 'maxlength' => 8, | |
435 | 'size' => CRM_Utils_Type::EIGHT, | |
522a26c9 | 436 | 'table_name' => 'civicrm_address', |
437 | 'entity' => 'Address', | |
438 | 'bao' => 'CRM_Core_BAO_Address', | |
6a7e5e5d | 439 | 'localizable' => 0, |
c3fc2621 | 440 | 'html' => [ |
e501603b | 441 | 'type' => 'Text', |
c3fc2621 CW |
442 | ], |
443 | ], | |
444 | 'street_number_postdirectional' => [ | |
e501603b TO |
445 | 'name' => 'street_number_postdirectional', |
446 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 447 | 'title' => ts('Street Direction Suffix'), |
e501603b TO |
448 | 'description' => 'Directional prefix, e.g. Main St S, S is the suffix.', |
449 | 'maxlength' => 8, | |
450 | 'size' => CRM_Utils_Type::EIGHT, | |
522a26c9 | 451 | 'table_name' => 'civicrm_address', |
452 | 'entity' => 'Address', | |
453 | 'bao' => 'CRM_Core_BAO_Address', | |
6a7e5e5d | 454 | 'localizable' => 0, |
c3fc2621 | 455 | 'html' => [ |
e501603b | 456 | 'type' => 'Text', |
c3fc2621 CW |
457 | ], |
458 | ], | |
459 | 'street_unit' => [ | |
e501603b TO |
460 | 'name' => 'street_unit', |
461 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 462 | 'title' => ts('Street Unit'), |
e501603b TO |
463 | 'description' => 'Secondary unit designator, e.g. Apt 3 or Unit # 14, or Bldg 1200', |
464 | 'maxlength' => 16, | |
465 | 'size' => CRM_Utils_Type::TWELVE, | |
c3fc2621 | 466 | 'export' => TRUE, |
e501603b TO |
467 | 'where' => 'civicrm_address.street_unit', |
468 | 'headerPattern' => '', | |
469 | 'dataPattern' => '', | |
522a26c9 | 470 | 'table_name' => 'civicrm_address', |
471 | 'entity' => 'Address', | |
472 | 'bao' => 'CRM_Core_BAO_Address', | |
6a7e5e5d | 473 | 'localizable' => 0, |
c3fc2621 | 474 | 'html' => [ |
e501603b | 475 | 'type' => 'Text', |
c3fc2621 CW |
476 | ], |
477 | ], | |
478 | 'supplemental_address_1' => [ | |
e501603b TO |
479 | 'name' => 'supplemental_address_1', |
480 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 481 | 'title' => ts('Supplemental Address 1'), |
e501603b TO |
482 | 'description' => 'Supplemental Address Information, Line 1', |
483 | 'maxlength' => 96, | |
484 | 'size' => CRM_Utils_Type::HUGE, | |
c3fc2621 | 485 | 'import' => TRUE, |
e501603b TO |
486 | 'where' => 'civicrm_address.supplemental_address_1', |
487 | 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i', | |
488 | 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i', | |
c3fc2621 | 489 | 'export' => TRUE, |
522a26c9 | 490 | 'table_name' => 'civicrm_address', |
491 | 'entity' => 'Address', | |
492 | 'bao' => 'CRM_Core_BAO_Address', | |
6a7e5e5d | 493 | 'localizable' => 0, |
c3fc2621 | 494 | 'html' => [ |
e501603b | 495 | 'type' => 'Text', |
c3fc2621 CW |
496 | ], |
497 | ], | |
498 | 'supplemental_address_2' => [ | |
e501603b TO |
499 | 'name' => 'supplemental_address_2', |
500 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 501 | 'title' => ts('Supplemental Address 2'), |
e501603b TO |
502 | 'description' => 'Supplemental Address Information, Line 2', |
503 | 'maxlength' => 96, | |
504 | 'size' => CRM_Utils_Type::HUGE, | |
c3fc2621 | 505 | 'import' => TRUE, |
e501603b TO |
506 | 'where' => 'civicrm_address.supplemental_address_2', |
507 | 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i', | |
508 | 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i', | |
c3fc2621 | 509 | 'export' => TRUE, |
522a26c9 | 510 | 'table_name' => 'civicrm_address', |
511 | 'entity' => 'Address', | |
512 | 'bao' => 'CRM_Core_BAO_Address', | |
6a7e5e5d | 513 | 'localizable' => 0, |
c3fc2621 | 514 | 'html' => [ |
e501603b | 515 | 'type' => 'Text', |
c3fc2621 CW |
516 | ], |
517 | ], | |
518 | 'supplemental_address_3' => [ | |
e501603b TO |
519 | 'name' => 'supplemental_address_3', |
520 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 521 | 'title' => ts('Supplemental Address 3'), |
e501603b TO |
522 | 'description' => 'Supplemental Address Information, Line 3', |
523 | 'maxlength' => 96, | |
524 | 'size' => CRM_Utils_Type::HUGE, | |
c3fc2621 | 525 | 'import' => TRUE, |
207f62c6 AS |
526 | 'where' => 'civicrm_address.supplemental_address_3', |
527 | 'headerPattern' => '/(supplemental(\s)?)?address(\s\d+)?/i', | |
528 | 'dataPattern' => '/unit|ap(ar)?t(ment)?\s(\d|\w)+/i', | |
c3fc2621 | 529 | 'export' => TRUE, |
522a26c9 | 530 | 'table_name' => 'civicrm_address', |
531 | 'entity' => 'Address', | |
532 | 'bao' => 'CRM_Core_BAO_Address', | |
6a7e5e5d | 533 | 'localizable' => 0, |
c3fc2621 | 534 | 'html' => [ |
e501603b | 535 | 'type' => 'Text', |
c3fc2621 CW |
536 | ], |
537 | ], | |
538 | 'city' => [ | |
e501603b TO |
539 | 'name' => 'city', |
540 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 541 | 'title' => ts('City'), |
e501603b TO |
542 | 'description' => 'City, Town or Village Name.', |
543 | 'maxlength' => 64, | |
544 | 'size' => CRM_Utils_Type::BIG, | |
c3fc2621 | 545 | 'import' => TRUE, |
e501603b TO |
546 | 'where' => 'civicrm_address.city', |
547 | 'headerPattern' => '/city/i', | |
548 | 'dataPattern' => '/^[A-Za-z]+(\.?)(\s?[A-Za-z]+){0,2}$/', | |
c3fc2621 | 549 | 'export' => TRUE, |
522a26c9 | 550 | 'table_name' => 'civicrm_address', |
551 | 'entity' => 'Address', | |
552 | 'bao' => 'CRM_Core_BAO_Address', | |
6a7e5e5d | 553 | 'localizable' => 0, |
c3fc2621 | 554 | 'html' => [ |
e501603b | 555 | 'type' => 'Text', |
c3fc2621 CW |
556 | ], |
557 | ], | |
558 | 'county_id' => [ | |
e501603b TO |
559 | 'name' => 'county_id', |
560 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 561 | 'title' => ts('County'), |
e501603b | 562 | 'description' => 'Which County does this address belong to.', |
522a26c9 | 563 | 'table_name' => 'civicrm_address', |
564 | 'entity' => 'Address', | |
565 | 'bao' => 'CRM_Core_BAO_Address', | |
6a7e5e5d | 566 | 'localizable' => 0, |
e501603b | 567 | 'FKClassName' => 'CRM_Core_DAO_County', |
c3fc2621 | 568 | 'html' => [ |
e501603b | 569 | 'type' => 'ChainSelect', |
c3fc2621 CW |
570 | ], |
571 | 'pseudoconstant' => [ | |
e501603b TO |
572 | 'table' => 'civicrm_county', |
573 | 'keyColumn' => 'id', | |
574 | 'labelColumn' => 'name', | |
c3fc2621 CW |
575 | ] |
576 | ], | |
577 | 'state_province_id' => [ | |
e501603b TO |
578 | 'name' => 'state_province_id', |
579 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 580 | 'title' => ts('State/Province'), |
e501603b | 581 | 'description' => 'Which State_Province does this address belong to.', |
522a26c9 | 582 | 'table_name' => 'civicrm_address', |
583 | 'entity' => 'Address', | |
584 | 'bao' => 'CRM_Core_BAO_Address', | |
6a7e5e5d | 585 | 'localizable' => 0, |
e501603b | 586 | 'FKClassName' => 'CRM_Core_DAO_StateProvince', |
c3fc2621 | 587 | 'html' => [ |
e501603b | 588 | 'type' => 'ChainSelect', |
c3fc2621 CW |
589 | ], |
590 | 'pseudoconstant' => [ | |
e501603b TO |
591 | 'table' => 'civicrm_state_province', |
592 | 'keyColumn' => 'id', | |
593 | 'labelColumn' => 'name', | |
c3fc2621 CW |
594 | ] |
595 | ], | |
596 | 'postal_code_suffix' => [ | |
e501603b TO |
597 | 'name' => 'postal_code_suffix', |
598 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 599 | 'title' => ts('Postal Code Suffix'), |
e501603b TO |
600 | 'description' => 'Store the suffix, like the +4 part in the USPS system.', |
601 | 'maxlength' => 12, | |
602 | 'size' => 3, | |
c3fc2621 | 603 | 'import' => TRUE, |
e501603b TO |
604 | 'where' => 'civicrm_address.postal_code_suffix', |
605 | 'headerPattern' => '/p(ostal)\sc(ode)\ss(uffix)/i', | |
606 | 'dataPattern' => '/\d?\d{4}(-\d{4})?/', | |
c3fc2621 | 607 | 'export' => TRUE, |
522a26c9 | 608 | 'table_name' => 'civicrm_address', |
609 | 'entity' => 'Address', | |
610 | 'bao' => 'CRM_Core_BAO_Address', | |
6a7e5e5d | 611 | 'localizable' => 0, |
c3fc2621 | 612 | 'html' => [ |
e501603b | 613 | 'type' => 'Text', |
c3fc2621 CW |
614 | ], |
615 | ], | |
616 | 'postal_code' => [ | |
e501603b TO |
617 | 'name' => 'postal_code', |
618 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 619 | 'title' => ts('Postal Code'), |
e501603b TO |
620 | 'description' => 'Store both US (zip5) AND international postal codes. App is responsible for country/region appropriate validation.', |
621 | 'maxlength' => 64, | |
622 | 'size' => 6, | |
c3fc2621 | 623 | 'import' => TRUE, |
e501603b TO |
624 | 'where' => 'civicrm_address.postal_code', |
625 | 'headerPattern' => '/postal|zip/i', | |
626 | 'dataPattern' => '/\d?\d{4}(-\d{4})?/', | |
c3fc2621 | 627 | 'export' => TRUE, |
522a26c9 | 628 | 'table_name' => 'civicrm_address', |
629 | 'entity' => 'Address', | |
630 | 'bao' => 'CRM_Core_BAO_Address', | |
6a7e5e5d | 631 | 'localizable' => 0, |
c3fc2621 | 632 | 'html' => [ |
e501603b | 633 | 'type' => 'Text', |
c3fc2621 CW |
634 | ], |
635 | ], | |
636 | 'usps_adc' => [ | |
e501603b TO |
637 | 'name' => 'usps_adc', |
638 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 639 | 'title' => ts('USPS Code'), |
e501603b TO |
640 | 'description' => 'USPS Bulk mailing code.', |
641 | 'maxlength' => 32, | |
642 | 'size' => CRM_Utils_Type::MEDIUM, | |
522a26c9 | 643 | 'table_name' => 'civicrm_address', |
644 | 'entity' => 'Address', | |
645 | 'bao' => 'CRM_Core_BAO_Address', | |
6a7e5e5d | 646 | 'localizable' => 0, |
c3fc2621 CW |
647 | ], |
648 | 'country_id' => [ | |
e501603b TO |
649 | 'name' => 'country_id', |
650 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 651 | 'title' => ts('Country'), |
e501603b | 652 | 'description' => 'Which Country does this address belong to.', |
522a26c9 | 653 | 'table_name' => 'civicrm_address', |
654 | 'entity' => 'Address', | |
655 | 'bao' => 'CRM_Core_BAO_Address', | |
6a7e5e5d | 656 | 'localizable' => 0, |
e501603b | 657 | 'FKClassName' => 'CRM_Core_DAO_Country', |
c3fc2621 | 658 | 'html' => [ |
e501603b | 659 | 'type' => 'Select', |
c3fc2621 CW |
660 | ], |
661 | 'pseudoconstant' => [ | |
e501603b TO |
662 | 'table' => 'civicrm_country', |
663 | 'keyColumn' => 'id', | |
664 | 'labelColumn' => 'name', | |
665 | 'nameColumn' => 'iso_code', | |
c3fc2621 CW |
666 | ] |
667 | ], | |
668 | 'geo_code_1' => [ | |
e501603b TO |
669 | 'name' => 'geo_code_1', |
670 | 'type' => CRM_Utils_Type::T_FLOAT, | |
c3fc2621 | 671 | 'title' => ts('Latitude'), |
e501603b | 672 | 'description' => 'Latitude', |
c3fc2621 | 673 | 'import' => TRUE, |
e501603b TO |
674 | 'where' => 'civicrm_address.geo_code_1', |
675 | 'headerPattern' => '/geo/i', | |
676 | 'dataPattern' => '', | |
c3fc2621 | 677 | 'export' => TRUE, |
522a26c9 | 678 | 'table_name' => 'civicrm_address', |
679 | 'entity' => 'Address', | |
680 | 'bao' => 'CRM_Core_BAO_Address', | |
6a7e5e5d | 681 | 'localizable' => 0, |
c3fc2621 | 682 | 'html' => [ |
e501603b | 683 | 'type' => 'Text', |
c3fc2621 CW |
684 | ], |
685 | ], | |
686 | 'geo_code_2' => [ | |
e501603b TO |
687 | 'name' => 'geo_code_2', |
688 | 'type' => CRM_Utils_Type::T_FLOAT, | |
c3fc2621 | 689 | 'title' => ts('Longitude'), |
e501603b | 690 | 'description' => 'Longitude', |
c3fc2621 | 691 | 'import' => TRUE, |
e501603b TO |
692 | 'where' => 'civicrm_address.geo_code_2', |
693 | 'headerPattern' => '/geo/i', | |
694 | 'dataPattern' => '', | |
c3fc2621 | 695 | 'export' => TRUE, |
522a26c9 | 696 | 'table_name' => 'civicrm_address', |
697 | 'entity' => 'Address', | |
698 | 'bao' => 'CRM_Core_BAO_Address', | |
6a7e5e5d | 699 | 'localizable' => 0, |
c3fc2621 | 700 | 'html' => [ |
e501603b | 701 | 'type' => 'Text', |
c3fc2621 CW |
702 | ], |
703 | ], | |
704 | 'manual_geo_code' => [ | |
e501603b TO |
705 | 'name' => 'manual_geo_code', |
706 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
c3fc2621 | 707 | 'title' => ts('Is manually geocoded'), |
e501603b | 708 | 'description' => 'Is this a manually entered geo code', |
522a26c9 | 709 | 'table_name' => 'civicrm_address', |
710 | 'entity' => 'Address', | |
711 | 'bao' => 'CRM_Core_BAO_Address', | |
6a7e5e5d | 712 | 'localizable' => 0, |
c3fc2621 | 713 | 'html' => [ |
e501603b | 714 | 'type' => 'CheckBox', |
c3fc2621 CW |
715 | ], |
716 | ], | |
717 | 'timezone' => [ | |
e501603b TO |
718 | 'name' => 'timezone', |
719 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 720 | 'title' => ts('Timezone'), |
e501603b TO |
721 | 'description' => 'Timezone expressed as a UTC offset - e.g. United States CST would be written as "UTC-6".', |
722 | 'maxlength' => 8, | |
723 | 'size' => CRM_Utils_Type::EIGHT, | |
522a26c9 | 724 | 'table_name' => 'civicrm_address', |
725 | 'entity' => 'Address', | |
726 | 'bao' => 'CRM_Core_BAO_Address', | |
6a7e5e5d | 727 | 'localizable' => 0, |
c3fc2621 | 728 | 'html' => [ |
e501603b | 729 | 'type' => 'Text', |
c3fc2621 CW |
730 | ], |
731 | ], | |
732 | 'address_name' => [ | |
e501603b TO |
733 | 'name' => 'name', |
734 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 735 | 'title' => ts('Address Name'), |
e501603b TO |
736 | 'maxlength' => 255, |
737 | 'size' => CRM_Utils_Type::HUGE, | |
c3fc2621 | 738 | 'import' => TRUE, |
e501603b TO |
739 | 'where' => 'civicrm_address.name', |
740 | 'headerPattern' => '/^location|(l(ocation\s)?name)$/i', | |
741 | 'dataPattern' => '/^\w+$/', | |
c3fc2621 | 742 | 'export' => TRUE, |
522a26c9 | 743 | 'table_name' => 'civicrm_address', |
744 | 'entity' => 'Address', | |
745 | 'bao' => 'CRM_Core_BAO_Address', | |
6a7e5e5d | 746 | 'localizable' => 0, |
c3fc2621 | 747 | 'html' => [ |
e501603b | 748 | 'type' => 'Text', |
c3fc2621 CW |
749 | ], |
750 | ], | |
751 | 'master_id' => [ | |
e501603b TO |
752 | 'name' => 'master_id', |
753 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 754 | 'title' => ts('Master Address Belongs To'), |
e501603b | 755 | 'description' => 'FK to Address ID', |
c3fc2621 | 756 | 'import' => TRUE, |
e501603b TO |
757 | 'where' => 'civicrm_address.master_id', |
758 | 'headerPattern' => '', | |
759 | 'dataPattern' => '', | |
c3fc2621 | 760 | 'export' => TRUE, |
522a26c9 | 761 | 'table_name' => 'civicrm_address', |
762 | 'entity' => 'Address', | |
763 | 'bao' => 'CRM_Core_BAO_Address', | |
6a7e5e5d | 764 | 'localizable' => 0, |
e501603b | 765 | 'FKClassName' => 'CRM_Core_DAO_Address', |
c3fc2621 CW |
766 | ], |
767 | ]; | |
346aaaba | 768 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); |
e501603b | 769 | } |
346aaaba | 770 | return Civi::$statics[__CLASS__]['fields']; |
e501603b | 771 | } |
c3fc2621 | 772 | |
e501603b | 773 | /** |
bd8e0b14 | 774 | * Return a mapping from field-name to the corresponding key (as used in fields()). |
e501603b TO |
775 | * |
776 | * @return array | |
bd8e0b14 | 777 | * Array(string $name => string $uniqueName). |
e501603b | 778 | */ |
c3fc2621 | 779 | public static function &fieldKeys() { |
bd8e0b14 TO |
780 | if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { |
781 | Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); | |
e501603b | 782 | } |
bd8e0b14 | 783 | return Civi::$statics[__CLASS__]['fieldKeys']; |
e501603b | 784 | } |
c3fc2621 | 785 | |
e501603b TO |
786 | /** |
787 | * Returns the names of this table | |
788 | * | |
789 | * @return string | |
790 | */ | |
c3fc2621 | 791 | public static function getTableName() { |
e501603b TO |
792 | return self::$_tableName; |
793 | } | |
c3fc2621 | 794 | |
e501603b TO |
795 | /** |
796 | * Returns if this table needs to be logged | |
797 | * | |
c3fc2621 | 798 | * @return bool |
e501603b | 799 | */ |
c3fc2621 | 800 | public function getLog() { |
e501603b TO |
801 | return self::$_log; |
802 | } | |
c3fc2621 | 803 | |
e501603b TO |
804 | /** |
805 | * Returns the list of fields that can be imported | |
806 | * | |
807 | * @param bool $prefix | |
808 | * | |
809 | * @return array | |
810 | */ | |
c3fc2621 CW |
811 | public static function &import($prefix = FALSE) { |
812 | $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'address', $prefix, [ | |
60808919 TO |
813 | 'CRM_Core_DAO_County', |
814 | 'CRM_Core_DAO_StateProvince', | |
815 | 'CRM_Core_DAO_Country', | |
c3fc2621 | 816 | ]); |
60808919 | 817 | return $r; |
e501603b | 818 | } |
c3fc2621 | 819 | |
e501603b TO |
820 | /** |
821 | * Returns the list of fields that can be exported | |
822 | * | |
823 | * @param bool $prefix | |
824 | * | |
825 | * @return array | |
826 | */ | |
c3fc2621 CW |
827 | public static function &export($prefix = FALSE) { |
828 | $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'address', $prefix, [ | |
60808919 TO |
829 | 'CRM_Core_DAO_County', |
830 | 'CRM_Core_DAO_StateProvince', | |
831 | 'CRM_Core_DAO_Country', | |
c3fc2621 | 832 | ]); |
60808919 | 833 | return $r; |
e501603b | 834 | } |
c3fc2621 | 835 | |
e7a6b91a AS |
836 | /** |
837 | * Returns the list of indices | |
c3fc2621 CW |
838 | * |
839 | * @param bool $localize | |
840 | * | |
841 | * @return array | |
e7a6b91a AS |
842 | */ |
843 | public static function indices($localize = TRUE) { | |
c3fc2621 CW |
844 | $indices = [ |
845 | 'index_location_type' => [ | |
e7a6b91a | 846 | 'name' => 'index_location_type', |
c3fc2621 | 847 | 'field' => [ |
e7a6b91a | 848 | 0 => 'location_type_id', |
c3fc2621 CW |
849 | ], |
850 | 'localizable' => FALSE, | |
e7a6b91a | 851 | 'sig' => 'civicrm_address::0::location_type_id', |
c3fc2621 CW |
852 | ], |
853 | 'index_is_primary' => [ | |
e7a6b91a | 854 | 'name' => 'index_is_primary', |
c3fc2621 | 855 | 'field' => [ |
e7a6b91a | 856 | 0 => 'is_primary', |
c3fc2621 CW |
857 | ], |
858 | 'localizable' => FALSE, | |
e7a6b91a | 859 | 'sig' => 'civicrm_address::0::is_primary', |
c3fc2621 CW |
860 | ], |
861 | 'index_is_billing' => [ | |
e7a6b91a | 862 | 'name' => 'index_is_billing', |
c3fc2621 | 863 | 'field' => [ |
e7a6b91a | 864 | 0 => 'is_billing', |
c3fc2621 CW |
865 | ], |
866 | 'localizable' => FALSE, | |
e7a6b91a | 867 | 'sig' => 'civicrm_address::0::is_billing', |
c3fc2621 CW |
868 | ], |
869 | 'index_street_name' => [ | |
e7a6b91a | 870 | 'name' => 'index_street_name', |
c3fc2621 | 871 | 'field' => [ |
e7a6b91a | 872 | 0 => 'street_name', |
c3fc2621 CW |
873 | ], |
874 | 'localizable' => FALSE, | |
e7a6b91a | 875 | 'sig' => 'civicrm_address::0::street_name', |
c3fc2621 CW |
876 | ], |
877 | 'index_city' => [ | |
e7a6b91a | 878 | 'name' => 'index_city', |
c3fc2621 | 879 | 'field' => [ |
e7a6b91a | 880 | 0 => 'city', |
c3fc2621 CW |
881 | ], |
882 | 'localizable' => FALSE, | |
e7a6b91a | 883 | 'sig' => 'civicrm_address::0::city', |
c3fc2621 CW |
884 | ], |
885 | ]; | |
e7a6b91a AS |
886 | return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; |
887 | } | |
c3fc2621 | 888 | |
e501603b | 889 | } |