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/Country.xml | |
8 | * DO NOT EDIT. Generated by CRM_Core_CodeGen | |
c1e814c7 | 9 | * (GenCodeChecksum:27aa4dca6a02c9e3827feff015f759fe) |
e501603b | 10 | */ |
c3fc2621 | 11 | |
f41f0342 | 12 | /** |
c3fc2621 | 13 | * Database access object for the Country entity. |
f41f0342 | 14 | */ |
e501603b | 15 | class CRM_Core_DAO_Country 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_country'; |
c3fc2621 | 25 | |
8ab43c93 CW |
26 | /** |
27 | * Field to show when displaying a record. | |
28 | * | |
29 | * @var string | |
30 | */ | |
31 | public static $_labelField = 'name'; | |
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 = FALSE; |
c3fc2621 | 39 | |
e501603b | 40 | /** |
2cbbebe8 | 41 | * Country ID |
e501603b | 42 | * |
28979d65 CW |
43 | * @var int|string|null |
44 | * (SQL type: int unsigned) | |
45 | * Note that values will be retrieved from the database as a string. | |
e501603b TO |
46 | */ |
47 | public $id; | |
c3fc2621 | 48 | |
e501603b TO |
49 | /** |
50 | * Country Name | |
51 | * | |
28979d65 CW |
52 | * @var string|null |
53 | * (SQL type: varchar(64)) | |
54 | * Note that values will be retrieved from the database as a string. | |
e501603b TO |
55 | */ |
56 | public $name; | |
c3fc2621 | 57 | |
e501603b TO |
58 | /** |
59 | * ISO Code | |
60 | * | |
28979d65 CW |
61 | * @var string|null |
62 | * (SQL type: char(2)) | |
63 | * Note that values will be retrieved from the database as a string. | |
e501603b TO |
64 | */ |
65 | public $iso_code; | |
c3fc2621 | 66 | |
e501603b TO |
67 | /** |
68 | * National prefix to be used when dialing TO this country. | |
69 | * | |
28979d65 CW |
70 | * @var string|null |
71 | * (SQL type: varchar(4)) | |
72 | * Note that values will be retrieved from the database as a string. | |
e501603b TO |
73 | */ |
74 | public $country_code; | |
c3fc2621 | 75 | |
e501603b TO |
76 | /** |
77 | * Foreign key to civicrm_address_format.id. | |
78 | * | |
28979d65 CW |
79 | * @var int|string|null |
80 | * (SQL type: int unsigned) | |
81 | * Note that values will be retrieved from the database as a string. | |
e501603b TO |
82 | */ |
83 | public $address_format_id; | |
c3fc2621 | 84 | |
e501603b TO |
85 | /** |
86 | * International direct dialing prefix from within the country TO another country | |
87 | * | |
28979d65 CW |
88 | * @var string|null |
89 | * (SQL type: varchar(4)) | |
90 | * Note that values will be retrieved from the database as a string. | |
e501603b TO |
91 | */ |
92 | public $idd_prefix; | |
c3fc2621 | 93 | |
e501603b TO |
94 | /** |
95 | * Access prefix to call within a country to a different area | |
96 | * | |
28979d65 CW |
97 | * @var string|null |
98 | * (SQL type: varchar(4)) | |
99 | * Note that values will be retrieved from the database as a string. | |
e501603b TO |
100 | */ |
101 | public $ndd_prefix; | |
c3fc2621 | 102 | |
e501603b TO |
103 | /** |
104 | * Foreign key to civicrm_worldregion.id. | |
105 | * | |
28979d65 CW |
106 | * @var int|string |
107 | * (SQL type: int unsigned) | |
108 | * Note that values will be retrieved from the database as a string. | |
e501603b TO |
109 | */ |
110 | public $region_id; | |
c3fc2621 | 111 | |
e501603b TO |
112 | /** |
113 | * Should state/province be displayed as abbreviation for contacts from this country? | |
114 | * | |
c1e814c7 | 115 | * @var bool|string |
28979d65 CW |
116 | * (SQL type: tinyint) |
117 | * Note that values will be retrieved from the database as a string. | |
e501603b TO |
118 | */ |
119 | public $is_province_abbreviated; | |
c3fc2621 | 120 | |
005f02ec MW |
121 | /** |
122 | * Is this Country active? | |
123 | * | |
c1e814c7 | 124 | * @var bool|string |
28979d65 CW |
125 | * (SQL type: tinyint) |
126 | * Note that values will be retrieved from the database as a string. | |
005f02ec MW |
127 | */ |
128 | public $is_active; | |
129 | ||
e501603b | 130 | /** |
f41f0342 | 131 | * Class constructor. |
e501603b | 132 | */ |
c3fc2621 | 133 | public function __construct() { |
e501603b TO |
134 | $this->__table = 'civicrm_country'; |
135 | parent::__construct(); | |
136 | } | |
c3fc2621 | 137 | |
449c4e6b CW |
138 | /** |
139 | * Returns localized title of this entity. | |
7b66c3b5 AH |
140 | * |
141 | * @param bool $plural | |
142 | * Whether to return the plural version of the title. | |
449c4e6b | 143 | */ |
7b66c3b5 AH |
144 | public static function getEntityTitle($plural = FALSE) { |
145 | return $plural ? ts('Countries') : ts('Country'); | |
449c4e6b CW |
146 | } |
147 | ||
e501603b | 148 | /** |
f41f0342 | 149 | * Returns foreign keys and entity references. |
e501603b TO |
150 | * |
151 | * @return array | |
152 | * [CRM_Core_Reference_Interface] | |
153 | */ | |
c3fc2621 | 154 | public static function getReferenceColumns() { |
346aaaba | 155 | if (!isset(Civi::$statics[__CLASS__]['links'])) { |
fa45b5b9 | 156 | Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); |
c3fc2621 CW |
157 | Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'address_format_id', 'civicrm_address_format', 'id'); |
158 | Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'region_id', 'civicrm_worldregion', 'id'); | |
346aaaba | 159 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); |
e501603b | 160 | } |
346aaaba | 161 | return Civi::$statics[__CLASS__]['links']; |
e501603b | 162 | } |
c3fc2621 | 163 | |
e501603b TO |
164 | /** |
165 | * Returns all the column names of this table | |
166 | * | |
167 | * @return array | |
168 | */ | |
c3fc2621 | 169 | public static function &fields() { |
346aaaba | 170 | if (!isset(Civi::$statics[__CLASS__]['fields'])) { |
c3fc2621 CW |
171 | Civi::$statics[__CLASS__]['fields'] = [ |
172 | 'id' => [ | |
e501603b TO |
173 | 'name' => 'id', |
174 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 175 | 'title' => ts('Country ID'), |
2cbbebe8 | 176 | 'description' => ts('Country ID'), |
c3fc2621 | 177 | 'required' => TRUE, |
a36434b9 | 178 | 'where' => 'civicrm_country.id', |
522a26c9 | 179 | 'table_name' => 'civicrm_country', |
180 | 'entity' => 'Country', | |
181 | 'bao' => 'CRM_Core_BAO_Country', | |
6a7e5e5d | 182 | 'localizable' => 0, |
2cbbebe8 A |
183 | 'html' => [ |
184 | 'type' => 'Number', | |
185 | ], | |
1fe423d6 | 186 | 'readonly' => TRUE, |
a9d0587b | 187 | 'add' => '1.1', |
c3fc2621 CW |
188 | ], |
189 | 'name' => [ | |
e501603b TO |
190 | 'name' => 'name', |
191 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 192 | 'title' => ts('Country'), |
215b423e | 193 | 'description' => ts('Country Name'), |
e501603b TO |
194 | 'maxlength' => 64, |
195 | 'size' => CRM_Utils_Type::BIG, | |
c3fc2621 | 196 | 'import' => TRUE, |
e501603b TO |
197 | 'where' => 'civicrm_country.name', |
198 | 'headerPattern' => '/country/i', | |
199 | 'dataPattern' => '/^[A-Z][a-z]+\.?(\s+[A-Z][a-z]+){0,3}$/', | |
c3fc2621 | 200 | 'export' => TRUE, |
522a26c9 | 201 | 'table_name' => 'civicrm_country', |
202 | 'entity' => 'Country', | |
203 | 'bao' => 'CRM_Core_BAO_Country', | |
6a7e5e5d | 204 | 'localizable' => 0, |
a9d0587b | 205 | 'add' => '1.1', |
c3fc2621 CW |
206 | ], |
207 | 'iso_code' => [ | |
e501603b TO |
208 | 'name' => 'iso_code', |
209 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 210 | 'title' => ts('Country ISO Code'), |
215b423e | 211 | 'description' => ts('ISO Code'), |
e501603b TO |
212 | 'maxlength' => 2, |
213 | 'size' => CRM_Utils_Type::TWO, | |
a36434b9 | 214 | 'where' => 'civicrm_country.iso_code', |
522a26c9 | 215 | 'table_name' => 'civicrm_country', |
216 | 'entity' => 'Country', | |
217 | 'bao' => 'CRM_Core_BAO_Country', | |
6a7e5e5d | 218 | 'localizable' => 0, |
a9d0587b | 219 | 'add' => '1.1', |
c3fc2621 CW |
220 | ], |
221 | 'country_code' => [ | |
e501603b TO |
222 | 'name' => 'country_code', |
223 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 224 | 'title' => ts('Country Phone Prefix'), |
215b423e | 225 | 'description' => ts('National prefix to be used when dialing TO this country.'), |
e501603b TO |
226 | 'maxlength' => 4, |
227 | 'size' => CRM_Utils_Type::FOUR, | |
a36434b9 | 228 | 'where' => 'civicrm_country.country_code', |
522a26c9 | 229 | 'table_name' => 'civicrm_country', |
230 | 'entity' => 'Country', | |
231 | 'bao' => 'CRM_Core_BAO_Country', | |
6a7e5e5d | 232 | 'localizable' => 0, |
a9d0587b | 233 | 'add' => '1.1', |
c3fc2621 CW |
234 | ], |
235 | 'address_format_id' => [ | |
e501603b TO |
236 | 'name' => 'address_format_id', |
237 | 'type' => CRM_Utils_Type::T_INT, | |
2cbbebe8 | 238 | 'title' => ts('Address Format ID'), |
215b423e | 239 | 'description' => ts('Foreign key to civicrm_address_format.id.'), |
a36434b9 | 240 | 'where' => 'civicrm_country.address_format_id', |
522a26c9 | 241 | 'table_name' => 'civicrm_country', |
242 | 'entity' => 'Country', | |
243 | 'bao' => 'CRM_Core_BAO_Country', | |
6a7e5e5d | 244 | 'localizable' => 0, |
e501603b | 245 | 'FKClassName' => 'CRM_Core_DAO_AddressFormat', |
2cbbebe8 A |
246 | 'html' => [ |
247 | 'label' => ts("Address Format"), | |
248 | ], | |
a9d0587b | 249 | 'add' => '3.2', |
c3fc2621 CW |
250 | ], |
251 | 'idd_prefix' => [ | |
e501603b TO |
252 | 'name' => 'idd_prefix', |
253 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 254 | 'title' => ts('Outgoing Phone Prefix'), |
215b423e | 255 | 'description' => ts('International direct dialing prefix from within the country TO another country'), |
e501603b TO |
256 | 'maxlength' => 4, |
257 | 'size' => CRM_Utils_Type::FOUR, | |
a36434b9 | 258 | 'where' => 'civicrm_country.idd_prefix', |
522a26c9 | 259 | 'table_name' => 'civicrm_country', |
260 | 'entity' => 'Country', | |
261 | 'bao' => 'CRM_Core_BAO_Country', | |
6a7e5e5d | 262 | 'localizable' => 0, |
a9d0587b | 263 | 'add' => '1.1', |
c3fc2621 CW |
264 | ], |
265 | 'ndd_prefix' => [ | |
e501603b TO |
266 | 'name' => 'ndd_prefix', |
267 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 268 | 'title' => ts('Area Code'), |
215b423e | 269 | 'description' => ts('Access prefix to call within a country to a different area'), |
e501603b TO |
270 | 'maxlength' => 4, |
271 | 'size' => CRM_Utils_Type::FOUR, | |
a36434b9 | 272 | 'where' => 'civicrm_country.ndd_prefix', |
522a26c9 | 273 | 'table_name' => 'civicrm_country', |
274 | 'entity' => 'Country', | |
275 | 'bao' => 'CRM_Core_BAO_Country', | |
6a7e5e5d | 276 | 'localizable' => 0, |
a9d0587b | 277 | 'add' => '1.1', |
c3fc2621 CW |
278 | ], |
279 | 'region_id' => [ | |
e501603b TO |
280 | 'name' => 'region_id', |
281 | 'type' => CRM_Utils_Type::T_INT, | |
b06ca616 | 282 | 'title' => ts('World Region ID'), |
215b423e | 283 | 'description' => ts('Foreign key to civicrm_worldregion.id.'), |
c3fc2621 | 284 | 'required' => TRUE, |
a36434b9 | 285 | 'where' => 'civicrm_country.region_id', |
522a26c9 | 286 | 'table_name' => 'civicrm_country', |
287 | 'entity' => 'Country', | |
288 | 'bao' => 'CRM_Core_BAO_Country', | |
6a7e5e5d | 289 | 'localizable' => 0, |
65c86f7d | 290 | 'localize_context' => 'country', |
e501603b | 291 | 'FKClassName' => 'CRM_Core_DAO_Worldregion', |
2cbbebe8 A |
292 | 'html' => [ |
293 | 'label' => ts("World Region"), | |
294 | ], | |
65c86f7d | 295 | 'pseudoconstant' => [ |
296 | 'table' => 'civicrm_worldregion', | |
297 | 'keyColumn' => 'id', | |
298 | 'labelColumn' => 'name', | |
e6ca0a57 | 299 | ], |
a9d0587b | 300 | 'add' => '1.8', |
c3fc2621 CW |
301 | ], |
302 | 'is_province_abbreviated' => [ | |
e501603b TO |
303 | 'name' => 'is_province_abbreviated', |
304 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
c3fc2621 | 305 | 'title' => ts('Abbreviate Province?'), |
215b423e | 306 | 'description' => ts('Should state/province be displayed as abbreviation for contacts from this country?'), |
c1e814c7 | 307 | 'required' => TRUE, |
a36434b9 | 308 | 'where' => 'civicrm_country.is_province_abbreviated', |
45a83e42 | 309 | 'default' => '0', |
522a26c9 | 310 | 'table_name' => 'civicrm_country', |
311 | 'entity' => 'Country', | |
312 | 'bao' => 'CRM_Core_BAO_Country', | |
6a7e5e5d | 313 | 'localizable' => 0, |
a9d0587b | 314 | 'add' => '3.1', |
c3fc2621 | 315 | ], |
005f02ec MW |
316 | 'is_active' => [ |
317 | 'name' => 'is_active', | |
318 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
319 | 'title' => ts('Country Is Active'), | |
320 | 'description' => ts('Is this Country active?'), | |
c1e814c7 | 321 | 'required' => TRUE, |
005f02ec MW |
322 | 'where' => 'civicrm_country.is_active', |
323 | 'default' => '1', | |
324 | 'table_name' => 'civicrm_country', | |
325 | 'entity' => 'Country', | |
326 | 'bao' => 'CRM_Core_BAO_Country', | |
327 | 'localizable' => 0, | |
328 | 'add' => '5.35', | |
329 | ], | |
c3fc2621 | 330 | ]; |
346aaaba | 331 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); |
e501603b | 332 | } |
346aaaba | 333 | return Civi::$statics[__CLASS__]['fields']; |
e501603b | 334 | } |
c3fc2621 | 335 | |
e501603b | 336 | /** |
bd8e0b14 | 337 | * Return a mapping from field-name to the corresponding key (as used in fields()). |
e501603b TO |
338 | * |
339 | * @return array | |
bd8e0b14 | 340 | * Array(string $name => string $uniqueName). |
e501603b | 341 | */ |
c3fc2621 | 342 | public static function &fieldKeys() { |
bd8e0b14 TO |
343 | if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { |
344 | Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); | |
e501603b | 345 | } |
bd8e0b14 | 346 | return Civi::$statics[__CLASS__]['fieldKeys']; |
e501603b | 347 | } |
c3fc2621 | 348 | |
e501603b TO |
349 | /** |
350 | * Returns the names of this table | |
351 | * | |
352 | * @return string | |
353 | */ | |
c3fc2621 | 354 | public static function getTableName() { |
e501603b TO |
355 | return self::$_tableName; |
356 | } | |
c3fc2621 | 357 | |
e501603b TO |
358 | /** |
359 | * Returns if this table needs to be logged | |
360 | * | |
c3fc2621 | 361 | * @return bool |
e501603b | 362 | */ |
c3fc2621 | 363 | public function getLog() { |
e501603b TO |
364 | return self::$_log; |
365 | } | |
c3fc2621 | 366 | |
e501603b TO |
367 | /** |
368 | * Returns the list of fields that can be imported | |
369 | * | |
370 | * @param bool $prefix | |
371 | * | |
372 | * @return array | |
373 | */ | |
c3fc2621 CW |
374 | public static function &import($prefix = FALSE) { |
375 | $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'country', $prefix, []); | |
60808919 | 376 | return $r; |
e501603b | 377 | } |
c3fc2621 | 378 | |
e501603b TO |
379 | /** |
380 | * Returns the list of fields that can be exported | |
381 | * | |
382 | * @param bool $prefix | |
383 | * | |
384 | * @return array | |
385 | */ | |
c3fc2621 CW |
386 | public static function &export($prefix = FALSE) { |
387 | $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'country', $prefix, []); | |
60808919 | 388 | return $r; |
e501603b | 389 | } |
c3fc2621 | 390 | |
e7a6b91a AS |
391 | /** |
392 | * Returns the list of indices | |
c3fc2621 CW |
393 | * |
394 | * @param bool $localize | |
395 | * | |
396 | * @return array | |
e7a6b91a AS |
397 | */ |
398 | public static function indices($localize = TRUE) { | |
c3fc2621 CW |
399 | $indices = [ |
400 | 'UI_name_iso_code' => [ | |
e7a6b91a | 401 | 'name' => 'UI_name_iso_code', |
c3fc2621 | 402 | 'field' => [ |
e7a6b91a AS |
403 | 0 => 'name', |
404 | 1 => 'iso_code', | |
c3fc2621 CW |
405 | ], |
406 | 'localizable' => FALSE, | |
407 | 'unique' => TRUE, | |
e7a6b91a | 408 | 'sig' => 'civicrm_country::1::name::iso_code', |
c3fc2621 CW |
409 | ], |
410 | ]; | |
e7a6b91a AS |
411 | return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; |
412 | } | |
c3fc2621 | 413 | |
e501603b | 414 | } |