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