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