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