Merge pull request #11017 from seamuslee001/CRM-21212
[civicrm-core.git] / CRM / Core / DAO / Country.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2017 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
26 */
27 /**
28 * @package CRM
29 * @copyright CiviCRM LLC (c) 2004-2017
30 *
31 * Generated from xml/schema/CRM/Core/Country.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
33 * (GenCodeChecksum:e01f7b6fdc1c22bcf6fbc125ea2d894a)
34 */
35 require_once 'CRM/Core/DAO.php';
36 require_once 'CRM/Utils/Type.php';
37 /**
38 * CRM_Core_DAO_Country constructor.
39 */
40 class CRM_Core_DAO_Country extends CRM_Core_DAO {
41 /**
42 * Static instance to hold the table name.
43 *
44 * @var string
45 */
46 static $_tableName = 'civicrm_country';
47 /**
48 * Should CiviCRM log any modifications to this table in the civicrm_log table.
49 *
50 * @var boolean
51 */
52 static $_log = false;
53 /**
54 * Country Id
55 *
56 * @var int unsigned
57 */
58 public $id;
59 /**
60 * Country Name
61 *
62 * @var string
63 */
64 public $name;
65 /**
66 * ISO Code
67 *
68 * @var string
69 */
70 public $iso_code;
71 /**
72 * National prefix to be used when dialing TO this country.
73 *
74 * @var string
75 */
76 public $country_code;
77 /**
78 * Foreign key to civicrm_address_format.id.
79 *
80 * @var int unsigned
81 */
82 public $address_format_id;
83 /**
84 * International direct dialing prefix from within the country TO another country
85 *
86 * @var string
87 */
88 public $idd_prefix;
89 /**
90 * Access prefix to call within a country to a different area
91 *
92 * @var string
93 */
94 public $ndd_prefix;
95 /**
96 * Foreign key to civicrm_worldregion.id.
97 *
98 * @var int unsigned
99 */
100 public $region_id;
101 /**
102 * Should state/province be displayed as abbreviation for contacts from this country?
103 *
104 * @var boolean
105 */
106 public $is_province_abbreviated;
107 /**
108 * Class constructor.
109 */
110 function __construct() {
111 $this->__table = 'civicrm_country';
112 parent::__construct();
113 }
114 /**
115 * Returns foreign keys and entity references.
116 *
117 * @return array
118 * [CRM_Core_Reference_Interface]
119 */
120 static function getReferenceColumns() {
121 if (!isset(Civi::$statics[__CLASS__]['links'])) {
122 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
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');
125 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
126 }
127 return Civi::$statics[__CLASS__]['links'];
128 }
129 /**
130 * Returns all the column names of this table
131 *
132 * @return array
133 */
134 static function &fields() {
135 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
136 Civi::$statics[__CLASS__]['fields'] = array(
137 'id' => array(
138 'name' => 'id',
139 'type' => CRM_Utils_Type::T_INT,
140 'title' => ts('Country ID') ,
141 'description' => 'Country Id',
142 'required' => true,
143 'table_name' => 'civicrm_country',
144 'entity' => 'Country',
145 'bao' => 'CRM_Core_BAO_Country',
146 'localizable' => 0,
147 ) ,
148 'name' => array(
149 'name' => 'name',
150 'type' => CRM_Utils_Type::T_STRING,
151 'title' => ts('Country') ,
152 'description' => 'Country Name',
153 'maxlength' => 64,
154 'size' => CRM_Utils_Type::BIG,
155 'import' => true,
156 'where' => 'civicrm_country.name',
157 'headerPattern' => '/country/i',
158 'dataPattern' => '/^[A-Z][a-z]+\.?(\s+[A-Z][a-z]+){0,3}$/',
159 'export' => true,
160 'table_name' => 'civicrm_country',
161 'entity' => 'Country',
162 'bao' => 'CRM_Core_BAO_Country',
163 'localizable' => 0,
164 ) ,
165 'iso_code' => array(
166 'name' => 'iso_code',
167 'type' => CRM_Utils_Type::T_STRING,
168 'title' => ts('Country ISO Code') ,
169 'description' => 'ISO Code',
170 'maxlength' => 2,
171 'size' => CRM_Utils_Type::TWO,
172 'table_name' => 'civicrm_country',
173 'entity' => 'Country',
174 'bao' => 'CRM_Core_BAO_Country',
175 'localizable' => 0,
176 ) ,
177 'country_code' => array(
178 'name' => 'country_code',
179 'type' => CRM_Utils_Type::T_STRING,
180 'title' => ts('Country Phone Prefix') ,
181 'description' => 'National prefix to be used when dialing TO this country.',
182 'maxlength' => 4,
183 'size' => CRM_Utils_Type::FOUR,
184 'table_name' => 'civicrm_country',
185 'entity' => 'Country',
186 'bao' => 'CRM_Core_BAO_Country',
187 'localizable' => 0,
188 ) ,
189 'address_format_id' => array(
190 'name' => 'address_format_id',
191 'type' => CRM_Utils_Type::T_INT,
192 'title' => ts('Address Format') ,
193 'description' => 'Foreign key to civicrm_address_format.id.',
194 'table_name' => 'civicrm_country',
195 'entity' => 'Country',
196 'bao' => 'CRM_Core_BAO_Country',
197 'localizable' => 0,
198 'FKClassName' => 'CRM_Core_DAO_AddressFormat',
199 ) ,
200 'idd_prefix' => array(
201 'name' => 'idd_prefix',
202 'type' => CRM_Utils_Type::T_STRING,
203 'title' => ts('Outgoing Phone Prefix') ,
204 'description' => 'International direct dialing prefix from within the country TO another country',
205 'maxlength' => 4,
206 'size' => CRM_Utils_Type::FOUR,
207 'table_name' => 'civicrm_country',
208 'entity' => 'Country',
209 'bao' => 'CRM_Core_BAO_Country',
210 'localizable' => 0,
211 ) ,
212 'ndd_prefix' => array(
213 'name' => 'ndd_prefix',
214 'type' => CRM_Utils_Type::T_STRING,
215 'title' => ts('Area Code') ,
216 'description' => 'Access prefix to call within a country to a different area',
217 'maxlength' => 4,
218 'size' => CRM_Utils_Type::FOUR,
219 'table_name' => 'civicrm_country',
220 'entity' => 'Country',
221 'bao' => 'CRM_Core_BAO_Country',
222 'localizable' => 0,
223 ) ,
224 'region_id' => array(
225 'name' => 'region_id',
226 'type' => CRM_Utils_Type::T_INT,
227 'title' => ts('Region') ,
228 'description' => 'Foreign key to civicrm_worldregion.id.',
229 'required' => true,
230 'table_name' => 'civicrm_country',
231 'entity' => 'Country',
232 'bao' => 'CRM_Core_BAO_Country',
233 'localizable' => 0,
234 'FKClassName' => 'CRM_Core_DAO_Worldregion',
235 ) ,
236 'is_province_abbreviated' => array(
237 'name' => 'is_province_abbreviated',
238 'type' => CRM_Utils_Type::T_BOOLEAN,
239 'title' => ts('Abbreviate Province?') ,
240 'description' => 'Should state/province be displayed as abbreviation for contacts from this country?',
241 'table_name' => 'civicrm_country',
242 'entity' => 'Country',
243 'bao' => 'CRM_Core_BAO_Country',
244 'localizable' => 0,
245 ) ,
246 );
247 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
248 }
249 return Civi::$statics[__CLASS__]['fields'];
250 }
251 /**
252 * Return a mapping from field-name to the corresponding key (as used in fields()).
253 *
254 * @return array
255 * Array(string $name => string $uniqueName).
256 */
257 static function &fieldKeys() {
258 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
259 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
260 }
261 return Civi::$statics[__CLASS__]['fieldKeys'];
262 }
263 /**
264 * Returns the names of this table
265 *
266 * @return string
267 */
268 static function getTableName() {
269 return self::$_tableName;
270 }
271 /**
272 * Returns if this table needs to be logged
273 *
274 * @return boolean
275 */
276 function getLog() {
277 return self::$_log;
278 }
279 /**
280 * Returns the list of fields that can be imported
281 *
282 * @param bool $prefix
283 *
284 * @return array
285 */
286 static function &import($prefix = false) {
287 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'country', $prefix, array());
288 return $r;
289 }
290 /**
291 * Returns the list of fields that can be exported
292 *
293 * @param bool $prefix
294 *
295 * @return array
296 */
297 static function &export($prefix = false) {
298 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'country', $prefix, array());
299 return $r;
300 }
301 /**
302 * Returns the list of indices
303 */
304 public static function indices($localize = TRUE) {
305 $indices = array(
306 'UI_name_iso_code' => array(
307 'name' => 'UI_name_iso_code',
308 'field' => array(
309 0 => 'name',
310 1 => 'iso_code',
311 ) ,
312 'localizable' => false,
313 'unique' => true,
314 'sig' => 'civicrm_country::1::name::iso_code',
315 ) ,
316 );
317 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
318 }
319 }