Merge pull request #8344 from darrick/CRM-18515
[civicrm-core.git] / CRM / Core / DAO / Phone.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2016 |
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-2016
30 *
31 * Generated from xml/schema/CRM/Core/Phone.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
33 * (GenCodeChecksum:97437ba9054b6175f63fe45e1756081f)
34 */
35 require_once 'CRM/Core/DAO.php';
36 require_once 'CRM/Utils/Type.php';
37 class CRM_Core_DAO_Phone extends CRM_Core_DAO {
38 /**
39 * static instance to hold the table name
40 *
41 * @var string
42 */
43 static $_tableName = 'civicrm_phone';
44 /**
45 * static value to see if we should log any modifications to
46 * this table in the civicrm_log table
47 *
48 * @var boolean
49 */
50 static $_log = true;
51 /**
52 * Unique Phone ID
53 *
54 * @var int unsigned
55 */
56 public $id;
57 /**
58 * FK to Contact ID
59 *
60 * @var int unsigned
61 */
62 public $contact_id;
63 /**
64 * Which Location does this phone belong to.
65 *
66 * @var int unsigned
67 */
68 public $location_type_id;
69 /**
70 * Is this the primary phone for this contact and location.
71 *
72 * @var boolean
73 */
74 public $is_primary;
75 /**
76 * Is this the billing?
77 *
78 * @var boolean
79 */
80 public $is_billing;
81 /**
82 * Which Mobile Provider does this phone belong to.
83 *
84 * @var int unsigned
85 */
86 public $mobile_provider_id;
87 /**
88 * Complete phone number.
89 *
90 * @var string
91 */
92 public $phone;
93 /**
94 * Optional extension for a phone number.
95 *
96 * @var string
97 */
98 public $phone_ext;
99 /**
100 * Phone number stripped of all whitespace, letters, and punctuation.
101 *
102 * @var string
103 */
104 public $phone_numeric;
105 /**
106 * Which type of phone does this number belongs.
107 *
108 * @var int unsigned
109 */
110 public $phone_type_id;
111 /**
112 * class constructor
113 *
114 * @return civicrm_phone
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 ) ,
149 'contact_id' => array(
150 'name' => 'contact_id',
151 'type' => CRM_Utils_Type::T_INT,
152 'title' => ts('Phone Contact') ,
153 'description' => 'FK to Contact ID',
154 'FKClassName' => 'CRM_Contact_DAO_Contact',
155 ) ,
156 'location_type_id' => array(
157 'name' => 'location_type_id',
158 'type' => CRM_Utils_Type::T_INT,
159 'title' => ts('Phone Location Type') ,
160 'description' => 'Which Location does this phone belong to.',
161 'html' => array(
162 'type' => 'Select',
163 ) ,
164 'pseudoconstant' => array(
165 'table' => 'civicrm_location_type',
166 'keyColumn' => 'id',
167 'labelColumn' => 'display_name',
168 )
169 ) ,
170 'is_primary' => array(
171 'name' => 'is_primary',
172 'type' => CRM_Utils_Type::T_BOOLEAN,
173 'title' => ts('Is Phone Primary?') ,
174 'description' => 'Is this the primary phone for this contact and location.',
175 ) ,
176 'is_billing' => array(
177 'name' => 'is_billing',
178 'type' => CRM_Utils_Type::T_BOOLEAN,
179 'title' => ts('Is Billing Phone') ,
180 'description' => 'Is this the billing?',
181 ) ,
182 'mobile_provider_id' => array(
183 'name' => 'mobile_provider_id',
184 'type' => CRM_Utils_Type::T_INT,
185 'title' => ts('Mobile Provider') ,
186 'description' => 'Which Mobile Provider does this phone belong to.',
187 ) ,
188 'phone' => array(
189 'name' => 'phone',
190 'type' => CRM_Utils_Type::T_STRING,
191 'title' => ts('Phone') ,
192 'description' => 'Complete phone number.',
193 'maxlength' => 32,
194 'size' => CRM_Utils_Type::MEDIUM,
195 'import' => true,
196 'where' => 'civicrm_phone.phone',
197 'headerPattern' => '/phone/i',
198 'dataPattern' => '/^[\d\(\)\-\.\s]+$/',
199 'export' => true,
200 'html' => array(
201 'type' => 'Text',
202 ) ,
203 ) ,
204 'phone_ext' => array(
205 'name' => 'phone_ext',
206 'type' => CRM_Utils_Type::T_STRING,
207 'title' => ts('Phone Extension') ,
208 'description' => 'Optional extension for a phone number.',
209 'maxlength' => 16,
210 'size' => 4,
211 'import' => true,
212 'where' => 'civicrm_phone.phone_ext',
213 'headerPattern' => '/extension/i',
214 'dataPattern' => '/^\d+$/',
215 'export' => true,
216 'html' => array(
217 'type' => 'Text',
218 ) ,
219 ) ,
220 'phone_numeric' => array(
221 'name' => 'phone_numeric',
222 'type' => CRM_Utils_Type::T_STRING,
223 'title' => ts('Phone Numeric') ,
224 'description' => 'Phone number stripped of all whitespace, letters, and punctuation.',
225 'maxlength' => 32,
226 'size' => CRM_Utils_Type::MEDIUM,
227 ) ,
228 'phone_type_id' => array(
229 'name' => 'phone_type_id',
230 'type' => CRM_Utils_Type::T_INT,
231 'title' => ts('Phone Type') ,
232 'description' => 'Which type of phone does this number belongs.',
233 'html' => array(
234 'type' => 'Select',
235 ) ,
236 'pseudoconstant' => array(
237 'optionGroupName' => 'phone_type',
238 'optionEditPath' => 'civicrm/admin/options/phone_type',
239 )
240 ) ,
241 );
242 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
243 }
244 return Civi::$statics[__CLASS__]['fields'];
245 }
246 /**
247 * Return a mapping from field-name to the corresponding key (as used in fields()).
248 *
249 * @return array
250 * Array(string $name => string $uniqueName).
251 */
252 static function &fieldKeys() {
253 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
254 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
255 }
256 return Civi::$statics[__CLASS__]['fieldKeys'];
257 }
258 /**
259 * Returns the names of this table
260 *
261 * @return string
262 */
263 static function getTableName() {
264 return self::$_tableName;
265 }
266 /**
267 * Returns if this table needs to be logged
268 *
269 * @return boolean
270 */
271 function getLog() {
272 return self::$_log;
273 }
274 /**
275 * Returns the list of fields that can be imported
276 *
277 * @param bool $prefix
278 *
279 * @return array
280 */
281 static function &import($prefix = false) {
282 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'phone', $prefix, array());
283 return $r;
284 }
285 /**
286 * Returns the list of fields that can be exported
287 *
288 * @param bool $prefix
289 *
290 * @return array
291 */
292 static function &export($prefix = false) {
293 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'phone', $prefix, array());
294 return $r;
295 }
296 }