CRM-20312 Add indices to DAO classes
[civicrm-core.git] / CRM / Core / DAO / Phone.php
CommitLineData
e501603b
TO
1<?php
2/*
3+--------------------------------------------------------------------+
4| CiviCRM version 4.7 |
5+--------------------------------------------------------------------+
0f03f337 6| Copyright CiviCRM LLC (c) 2004-2017 |
e501603b
TO
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
0f03f337 29 * @copyright CiviCRM LLC (c) 2004-2017
e501603b
TO
30 *
31 * Generated from xml/schema/CRM/Core/Phone.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
022785d8 33 * (GenCodeChecksum:aed6082497eb601fdc249c7a361204a8)
e501603b
TO
34 */
35require_once 'CRM/Core/DAO.php';
36require_once 'CRM/Utils/Type.php';
f41f0342 37/**
38 * CRM_Core_DAO_Phone constructor.
39 */
e501603b
TO
40class CRM_Core_DAO_Phone extends CRM_Core_DAO {
41 /**
f41f0342 42 * Static instance to hold the table name.
e501603b
TO
43 *
44 * @var string
45 */
46 static $_tableName = 'civicrm_phone';
e501603b 47 /**
f41f0342 48 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b
TO
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 /**
f41f0342 114 * Class constructor.
e501603b
TO
115 */
116 function __construct() {
117 $this->__table = 'civicrm_phone';
118 parent::__construct();
119 }
120 /**
f41f0342 121 * Returns foreign keys and entity references.
e501603b
TO
122 *
123 * @return array
124 * [CRM_Core_Reference_Interface]
125 */
126 static function getReferenceColumns() {
346aaaba
TO
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']);
e501603b 131 }
346aaaba 132 return Civi::$statics[__CLASS__]['links'];
e501603b
TO
133 }
134 /**
135 * Returns all the column names of this table
136 *
137 * @return array
138 */
139 static function &fields() {
346aaaba
TO
140 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
141 Civi::$statics[__CLASS__]['fields'] = array(
e501603b
TO
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,
522a26c9 148 'table_name' => 'civicrm_phone',
149 'entity' => 'Phone',
150 'bao' => 'CRM_Core_BAO_Phone',
6a7e5e5d 151 'localizable' => 0,
e501603b
TO
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',
522a26c9 158 'table_name' => 'civicrm_phone',
159 'entity' => 'Phone',
160 'bao' => 'CRM_Core_BAO_Phone',
6a7e5e5d 161 'localizable' => 0,
e501603b
TO
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.',
522a26c9 169 'table_name' => 'civicrm_phone',
170 'entity' => 'Phone',
171 'bao' => 'CRM_Core_BAO_Phone',
6a7e5e5d 172 'localizable' => 0,
e501603b
TO
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.',
522a26c9 187 'table_name' => 'civicrm_phone',
188 'entity' => 'Phone',
189 'bao' => 'CRM_Core_BAO_Phone',
6a7e5e5d 190 'localizable' => 0,
e501603b
TO
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?',
522a26c9 197 'table_name' => 'civicrm_phone',
198 'entity' => 'Phone',
199 'bao' => 'CRM_Core_BAO_Phone',
6a7e5e5d 200 'localizable' => 0,
e501603b
TO
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.',
522a26c9 207 'table_name' => 'civicrm_phone',
208 'entity' => 'Phone',
209 'bao' => 'CRM_Core_BAO_Phone',
6a7e5e5d 210 'localizable' => 0,
e501603b
TO
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,
522a26c9 224 'table_name' => 'civicrm_phone',
225 'entity' => 'Phone',
226 'bao' => 'CRM_Core_BAO_Phone',
6a7e5e5d 227 'localizable' => 0,
e501603b
TO
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,
522a26c9 244 'table_name' => 'civicrm_phone',
245 'entity' => 'Phone',
246 'bao' => 'CRM_Core_BAO_Phone',
6a7e5e5d 247 'localizable' => 0,
e501603b
TO
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,
522a26c9 259 'table_name' => 'civicrm_phone',
260 'entity' => 'Phone',
261 'bao' => 'CRM_Core_BAO_Phone',
6a7e5e5d 262 'localizable' => 0,
e501603b
TO
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.',
522a26c9 269 'table_name' => 'civicrm_phone',
270 'entity' => 'Phone',
271 'bao' => 'CRM_Core_BAO_Phone',
6a7e5e5d 272 'localizable' => 0,
e501603b
TO
273 'html' => array(
274 'type' => 'Select',
275 ) ,
276 'pseudoconstant' => array(
277 'optionGroupName' => 'phone_type',
278 'optionEditPath' => 'civicrm/admin/options/phone_type',
279 )
280 ) ,
281 );
346aaaba 282 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 283 }
346aaaba 284 return Civi::$statics[__CLASS__]['fields'];
e501603b
TO
285 }
286 /**
bd8e0b14 287 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
288 *
289 * @return array
bd8e0b14 290 * Array(string $name => string $uniqueName).
e501603b
TO
291 */
292 static function &fieldKeys() {
bd8e0b14
TO
293 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
294 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 295 }
bd8e0b14 296 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b
TO
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) {
60808919
TO
322 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'phone', $prefix, array());
323 return $r;
e501603b
TO
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) {
60808919
TO
333 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'phone', $prefix, array());
334 return $r;
e501603b
TO
335 }
336}