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