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