Delete entities in the reverse order that they were created
[civicrm-core.git] / CRM / Core / DAO / Phone.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC (c) 2004-2018
6 *
7 * Generated from xml/schema/CRM/Core/Phone.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:661faad4886dd1a40784d465b906f447)
10 */
11
12 /**
13 * Database access object for the Phone entity.
14 */
15 class CRM_Core_DAO_Phone extends CRM_Core_DAO {
16
17 /**
18 * Static instance to hold the table name.
19 *
20 * @var string
21 */
22 static $_tableName = 'civicrm_phone';
23
24 /**
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
26 *
27 * @var bool
28 */
29 static $_log = TRUE;
30
31 /**
32 * Unique Phone ID
33 *
34 * @var int unsigned
35 */
36 public $id;
37
38 /**
39 * FK to Contact ID
40 *
41 * @var int unsigned
42 */
43 public $contact_id;
44
45 /**
46 * Which Location does this phone belong to.
47 *
48 * @var int unsigned
49 */
50 public $location_type_id;
51
52 /**
53 * Is this the primary phone for this contact and location.
54 *
55 * @var boolean
56 */
57 public $is_primary;
58
59 /**
60 * Is this the billing?
61 *
62 * @var boolean
63 */
64 public $is_billing;
65
66 /**
67 * Which Mobile Provider does this phone belong to.
68 *
69 * @var int unsigned
70 */
71 public $mobile_provider_id;
72
73 /**
74 * Complete phone number.
75 *
76 * @var string
77 */
78 public $phone;
79
80 /**
81 * Optional extension for a phone number.
82 *
83 * @var string
84 */
85 public $phone_ext;
86
87 /**
88 * Phone number stripped of all whitespace, letters, and punctuation.
89 *
90 * @var string
91 */
92 public $phone_numeric;
93
94 /**
95 * Which type of phone does this number belongs.
96 *
97 * @var int unsigned
98 */
99 public $phone_type_id;
100
101 /**
102 * Class constructor.
103 */
104 public function __construct() {
105 $this->__table = 'civicrm_phone';
106 parent::__construct();
107 }
108
109 /**
110 * Returns foreign keys and entity references.
111 *
112 * @return array
113 * [CRM_Core_Reference_Interface]
114 */
115 public static function getReferenceColumns() {
116 if (!isset(Civi::$statics[__CLASS__]['links'])) {
117 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
118 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
119 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
120 }
121 return Civi::$statics[__CLASS__]['links'];
122 }
123
124 /**
125 * Returns all the column names of this table
126 *
127 * @return array
128 */
129 public static function &fields() {
130 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
131 Civi::$statics[__CLASS__]['fields'] = [
132 'id' => [
133 'name' => 'id',
134 'type' => CRM_Utils_Type::T_INT,
135 'title' => ts('Phone ID'),
136 'description' => 'Unique Phone ID',
137 'required' => TRUE,
138 'table_name' => 'civicrm_phone',
139 'entity' => 'Phone',
140 'bao' => 'CRM_Core_BAO_Phone',
141 'localizable' => 0,
142 ],
143 'contact_id' => [
144 'name' => 'contact_id',
145 'type' => CRM_Utils_Type::T_INT,
146 'title' => ts('Phone Contact'),
147 'description' => 'FK to Contact ID',
148 'table_name' => 'civicrm_phone',
149 'entity' => 'Phone',
150 'bao' => 'CRM_Core_BAO_Phone',
151 'localizable' => 0,
152 'FKClassName' => 'CRM_Contact_DAO_Contact',
153 ],
154 'location_type_id' => [
155 'name' => 'location_type_id',
156 'type' => CRM_Utils_Type::T_INT,
157 'title' => ts('Phone Location Type'),
158 'description' => 'Which Location does this phone belong to.',
159 'table_name' => 'civicrm_phone',
160 'entity' => 'Phone',
161 'bao' => 'CRM_Core_BAO_Phone',
162 'localizable' => 0,
163 'html' => [
164 'type' => 'Select',
165 ],
166 'pseudoconstant' => [
167 'table' => 'civicrm_location_type',
168 'keyColumn' => 'id',
169 'labelColumn' => 'display_name',
170 ]
171 ],
172 'is_primary' => [
173 'name' => 'is_primary',
174 'type' => CRM_Utils_Type::T_BOOLEAN,
175 'title' => ts('Is Phone Primary?'),
176 'description' => 'Is this the primary phone for this contact and location.',
177 'table_name' => 'civicrm_phone',
178 'entity' => 'Phone',
179 'bao' => 'CRM_Core_BAO_Phone',
180 'localizable' => 0,
181 ],
182 'is_billing' => [
183 'name' => 'is_billing',
184 'type' => CRM_Utils_Type::T_BOOLEAN,
185 'title' => ts('Is Billing Phone'),
186 'description' => 'Is this the billing?',
187 'table_name' => 'civicrm_phone',
188 'entity' => 'Phone',
189 'bao' => 'CRM_Core_BAO_Phone',
190 'localizable' => 0,
191 ],
192 'mobile_provider_id' => [
193 'name' => 'mobile_provider_id',
194 'type' => CRM_Utils_Type::T_INT,
195 'title' => ts('Mobile Provider'),
196 'description' => 'Which Mobile Provider does this phone belong to.',
197 'table_name' => 'civicrm_phone',
198 'entity' => 'Phone',
199 'bao' => 'CRM_Core_BAO_Phone',
200 'localizable' => 0,
201 ],
202 'phone' => [
203 'name' => 'phone',
204 'type' => CRM_Utils_Type::T_STRING,
205 'title' => ts('Phone'),
206 'description' => 'Complete phone number.',
207 'maxlength' => 32,
208 'size' => CRM_Utils_Type::MEDIUM,
209 'import' => TRUE,
210 'where' => 'civicrm_phone.phone',
211 'headerPattern' => '/phone/i',
212 'dataPattern' => '/^[\d\(\)\-\.\s]+$/',
213 'export' => TRUE,
214 'table_name' => 'civicrm_phone',
215 'entity' => 'Phone',
216 'bao' => 'CRM_Core_BAO_Phone',
217 'localizable' => 0,
218 'html' => [
219 'type' => 'Text',
220 ],
221 ],
222 'phone_ext' => [
223 'name' => 'phone_ext',
224 'type' => CRM_Utils_Type::T_STRING,
225 'title' => ts('Phone Extension'),
226 'description' => 'Optional extension for a phone number.',
227 'maxlength' => 16,
228 'size' => 4,
229 'import' => TRUE,
230 'where' => 'civicrm_phone.phone_ext',
231 'headerPattern' => '/extension/i',
232 'dataPattern' => '/^\d+$/',
233 'export' => TRUE,
234 'table_name' => 'civicrm_phone',
235 'entity' => 'Phone',
236 'bao' => 'CRM_Core_BAO_Phone',
237 'localizable' => 0,
238 'html' => [
239 'type' => 'Text',
240 ],
241 ],
242 'phone_numeric' => [
243 'name' => 'phone_numeric',
244 'type' => CRM_Utils_Type::T_STRING,
245 'title' => ts('Phone Numeric'),
246 'description' => 'Phone number stripped of all whitespace, letters, and punctuation.',
247 'maxlength' => 32,
248 'size' => CRM_Utils_Type::MEDIUM,
249 'table_name' => 'civicrm_phone',
250 'entity' => 'Phone',
251 'bao' => 'CRM_Core_BAO_Phone',
252 'localizable' => 0,
253 ],
254 'phone_type_id' => [
255 'name' => 'phone_type_id',
256 'type' => CRM_Utils_Type::T_INT,
257 'title' => ts('Phone Type'),
258 'description' => 'Which type of phone does this number belongs.',
259 'table_name' => 'civicrm_phone',
260 'entity' => 'Phone',
261 'bao' => 'CRM_Core_BAO_Phone',
262 'localizable' => 0,
263 'html' => [
264 'type' => 'Select',
265 ],
266 'pseudoconstant' => [
267 'optionGroupName' => 'phone_type',
268 'optionEditPath' => 'civicrm/admin/options/phone_type',
269 ]
270 ],
271 ];
272 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
273 }
274 return Civi::$statics[__CLASS__]['fields'];
275 }
276
277 /**
278 * Return a mapping from field-name to the corresponding key (as used in fields()).
279 *
280 * @return array
281 * Array(string $name => string $uniqueName).
282 */
283 public static function &fieldKeys() {
284 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
285 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
286 }
287 return Civi::$statics[__CLASS__]['fieldKeys'];
288 }
289
290 /**
291 * Returns the names of this table
292 *
293 * @return string
294 */
295 public static function getTableName() {
296 return self::$_tableName;
297 }
298
299 /**
300 * Returns if this table needs to be logged
301 *
302 * @return bool
303 */
304 public function getLog() {
305 return self::$_log;
306 }
307
308 /**
309 * Returns the list of fields that can be imported
310 *
311 * @param bool $prefix
312 *
313 * @return array
314 */
315 public static function &import($prefix = FALSE) {
316 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'phone', $prefix, []);
317 return $r;
318 }
319
320 /**
321 * Returns the list of fields that can be exported
322 *
323 * @param bool $prefix
324 *
325 * @return array
326 */
327 public static function &export($prefix = FALSE) {
328 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'phone', $prefix, []);
329 return $r;
330 }
331
332 /**
333 * Returns the list of indices
334 *
335 * @param bool $localize
336 *
337 * @return array
338 */
339 public static function indices($localize = TRUE) {
340 $indices = [
341 'index_location_type' => [
342 'name' => 'index_location_type',
343 'field' => [
344 0 => 'location_type_id',
345 ],
346 'localizable' => FALSE,
347 'sig' => 'civicrm_phone::0::location_type_id',
348 ],
349 'index_is_primary' => [
350 'name' => 'index_is_primary',
351 'field' => [
352 0 => 'is_primary',
353 ],
354 'localizable' => FALSE,
355 'sig' => 'civicrm_phone::0::is_primary',
356 ],
357 'index_is_billing' => [
358 'name' => 'index_is_billing',
359 'field' => [
360 0 => 'is_billing',
361 ],
362 'localizable' => FALSE,
363 'sig' => 'civicrm_phone::0::is_billing',
364 ],
365 'UI_mobile_provider_id' => [
366 'name' => 'UI_mobile_provider_id',
367 'field' => [
368 0 => 'mobile_provider_id',
369 ],
370 'localizable' => FALSE,
371 'sig' => 'civicrm_phone::0::mobile_provider_id',
372 ],
373 'index_phone_numeric' => [
374 'name' => 'index_phone_numeric',
375 'field' => [
376 0 => 'phone_numeric',
377 ],
378 'localizable' => FALSE,
379 'sig' => 'civicrm_phone::0::phone_numeric',
380 ],
381 ];
382 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
383 }
384
385 }