Merge pull request #8525 from twomice/CRM-18251b
[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:aed6082497eb601fdc249c7a361204a8)
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 ) ,
152 'contact_id' => array(
153 'name' => 'contact_id',
154 'type' => CRM_Utils_Type::T_INT,
155 'title' => ts('Phone Contact') ,
156 'description' => 'FK to Contact ID',
157 'table_name' => 'civicrm_phone',
158 'entity' => 'Phone',
159 'bao' => 'CRM_Core_BAO_Phone',
160 'FKClassName' => 'CRM_Contact_DAO_Contact',
161 ) ,
162 'location_type_id' => array(
163 'name' => 'location_type_id',
164 'type' => CRM_Utils_Type::T_INT,
165 'title' => ts('Phone Location Type') ,
166 'description' => 'Which Location does this phone belong to.',
167 'table_name' => 'civicrm_phone',
168 'entity' => 'Phone',
169 'bao' => 'CRM_Core_BAO_Phone',
170 'html' => array(
171 'type' => 'Select',
172 ) ,
173 'pseudoconstant' => array(
174 'table' => 'civicrm_location_type',
175 'keyColumn' => 'id',
176 'labelColumn' => 'display_name',
177 )
178 ) ,
179 'is_primary' => array(
180 'name' => 'is_primary',
181 'type' => CRM_Utils_Type::T_BOOLEAN,
182 'title' => ts('Is Phone Primary?') ,
183 'description' => 'Is this the primary phone for this contact and location.',
184 'table_name' => 'civicrm_phone',
185 'entity' => 'Phone',
186 'bao' => 'CRM_Core_BAO_Phone',
187 ) ,
188 'is_billing' => array(
189 'name' => 'is_billing',
190 'type' => CRM_Utils_Type::T_BOOLEAN,
191 'title' => ts('Is Billing Phone') ,
192 'description' => 'Is this the billing?',
193 'table_name' => 'civicrm_phone',
194 'entity' => 'Phone',
195 'bao' => 'CRM_Core_BAO_Phone',
196 ) ,
197 'mobile_provider_id' => array(
198 'name' => 'mobile_provider_id',
199 'type' => CRM_Utils_Type::T_INT,
200 'title' => ts('Mobile Provider') ,
201 'description' => 'Which Mobile Provider does this phone belong to.',
202 'table_name' => 'civicrm_phone',
203 'entity' => 'Phone',
204 'bao' => 'CRM_Core_BAO_Phone',
205 ) ,
206 'phone' => array(
207 'name' => 'phone',
208 'type' => CRM_Utils_Type::T_STRING,
209 'title' => ts('Phone') ,
210 'description' => 'Complete phone number.',
211 'maxlength' => 32,
212 'size' => CRM_Utils_Type::MEDIUM,
213 'import' => true,
214 'where' => 'civicrm_phone.phone',
215 'headerPattern' => '/phone/i',
216 'dataPattern' => '/^[\d\(\)\-\.\s]+$/',
217 'export' => true,
218 'table_name' => 'civicrm_phone',
219 'entity' => 'Phone',
220 'bao' => 'CRM_Core_BAO_Phone',
221 'html' => array(
222 'type' => 'Text',
223 ) ,
224 ) ,
225 'phone_ext' => array(
226 'name' => 'phone_ext',
227 'type' => CRM_Utils_Type::T_STRING,
228 'title' => ts('Phone Extension') ,
229 'description' => 'Optional extension for a phone number.',
230 'maxlength' => 16,
231 'size' => 4,
232 'import' => true,
233 'where' => 'civicrm_phone.phone_ext',
234 'headerPattern' => '/extension/i',
235 'dataPattern' => '/^\d+$/',
236 'export' => true,
237 'table_name' => 'civicrm_phone',
238 'entity' => 'Phone',
239 'bao' => 'CRM_Core_BAO_Phone',
240 'html' => array(
241 'type' => 'Text',
242 ) ,
243 ) ,
244 'phone_numeric' => array(
245 'name' => 'phone_numeric',
246 'type' => CRM_Utils_Type::T_STRING,
247 'title' => ts('Phone Numeric') ,
248 'description' => 'Phone number stripped of all whitespace, letters, and punctuation.',
249 'maxlength' => 32,
250 'size' => CRM_Utils_Type::MEDIUM,
251 'table_name' => 'civicrm_phone',
252 'entity' => 'Phone',
253 'bao' => 'CRM_Core_BAO_Phone',
254 ) ,
255 'phone_type_id' => array(
256 'name' => 'phone_type_id',
257 'type' => CRM_Utils_Type::T_INT,
258 'title' => ts('Phone Type') ,
259 'description' => 'Which type of phone does this number belongs.',
260 'table_name' => 'civicrm_phone',
261 'entity' => 'Phone',
262 'bao' => 'CRM_Core_BAO_Phone',
263 'html' => array(
264 'type' => 'Select',
265 ) ,
266 'pseudoconstant' => array(
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 * Return a mapping from field-name to the corresponding key (as used in fields()).
278 *
279 * @return array
280 * Array(string $name => string $uniqueName).
281 */
282 static function &fieldKeys() {
283 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
284 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
285 }
286 return Civi::$statics[__CLASS__]['fieldKeys'];
287 }
288 /**
289 * Returns the names of this table
290 *
291 * @return string
292 */
293 static function getTableName() {
294 return self::$_tableName;
295 }
296 /**
297 * Returns if this table needs to be logged
298 *
299 * @return boolean
300 */
301 function getLog() {
302 return self::$_log;
303 }
304 /**
305 * Returns the list of fields that can be imported
306 *
307 * @param bool $prefix
308 *
309 * @return array
310 */
311 static function &import($prefix = false) {
312 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'phone', $prefix, array());
313 return $r;
314 }
315 /**
316 * Returns the list of fields that can be exported
317 *
318 * @param bool $prefix
319 *
320 * @return array
321 */
322 static function &export($prefix = false) {
323 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'phone', $prefix, array());
324 return $r;
325 }
326 }