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