fixup CRM-14885 - Import DAOs
[civicrm-core.git] / CRM / Core / DAO / Email.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/Email.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
33 * (GenCodeChecksum:988b68b07a90ff903001c8f68b2e2545)
34 */
35 require_once 'CRM/Core/DAO.php';
36 require_once 'CRM/Utils/Type.php';
37 class CRM_Core_DAO_Email extends CRM_Core_DAO {
38 /**
39 * static instance to hold the table name
40 *
41 * @var string
42 */
43 static $_tableName = 'civicrm_email';
44 /**
45 * static instance to hold the field values
46 *
47 * @var array
48 */
49 static $_fields = null;
50 /**
51 * static instance to hold the keys used in $_fields for each field.
52 *
53 * @var array
54 */
55 static $_fieldKeys = null;
56 /**
57 * static instance to hold the FK relationships
58 *
59 * @var string
60 */
61 static $_links = null;
62 /**
63 * static instance to hold the values that can
64 * be imported
65 *
66 * @var array
67 */
68 static $_import = null;
69 /**
70 * static instance to hold the values that can
71 * be exported
72 *
73 * @var array
74 */
75 static $_export = null;
76 /**
77 * static value to see if we should log any modifications to
78 * this table in the civicrm_log table
79 *
80 * @var boolean
81 */
82 static $_log = true;
83 /**
84 * Unique Email ID
85 *
86 * @var int unsigned
87 */
88 public $id;
89 /**
90 * FK to Contact ID
91 *
92 * @var int unsigned
93 */
94 public $contact_id;
95 /**
96 * Which Location does this email belong to.
97 *
98 * @var int unsigned
99 */
100 public $location_type_id;
101 /**
102 * Email address
103 *
104 * @var string
105 */
106 public $email;
107 /**
108 * Is this the primary?
109 *
110 * @var boolean
111 */
112 public $is_primary;
113 /**
114 * Is this the billing?
115 *
116 * @var boolean
117 */
118 public $is_billing;
119 /**
120 * Is this address on bounce hold?
121 *
122 * @var boolean
123 */
124 public $on_hold;
125 /**
126 * Is this address for bulk mail ?
127 *
128 * @var boolean
129 */
130 public $is_bulkmail;
131 /**
132 * When the address went on bounce hold
133 *
134 * @var datetime
135 */
136 public $hold_date;
137 /**
138 * When the address bounce status was last reset
139 *
140 * @var datetime
141 */
142 public $reset_date;
143 /**
144 * Text formatted signature for the email.
145 *
146 * @var text
147 */
148 public $signature_text;
149 /**
150 * HTML formatted signature for the email.
151 *
152 * @var text
153 */
154 public $signature_html;
155 /**
156 * class constructor
157 *
158 * @return civicrm_email
159 */
160 function __construct() {
161 $this->__table = 'civicrm_email';
162 parent::__construct();
163 }
164 /**
165 * Returns foreign keys and entity references
166 *
167 * @return array
168 * [CRM_Core_Reference_Interface]
169 */
170 static function getReferenceColumns() {
171 if (!self::$_links) {
172 self::$_links = static ::createReferenceColumns(__CLASS__);
173 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'contact_id', 'civicrm_contact', 'id');
174 }
175 return self::$_links;
176 }
177 /**
178 * Returns all the column names of this table
179 *
180 * @return array
181 */
182 static function &fields() {
183 if (!(self::$_fields)) {
184 self::$_fields = array(
185 'id' => array(
186 'name' => 'id',
187 'type' => CRM_Utils_Type::T_INT,
188 'title' => ts('Email ID') ,
189 'description' => 'Unique Email ID',
190 'required' => true,
191 ) ,
192 'contact_id' => array(
193 'name' => 'contact_id',
194 'type' => CRM_Utils_Type::T_INT,
195 'title' => ts('Email Contact') ,
196 'description' => 'FK to Contact ID',
197 'FKClassName' => 'CRM_Contact_DAO_Contact',
198 ) ,
199 'location_type_id' => array(
200 'name' => 'location_type_id',
201 'type' => CRM_Utils_Type::T_INT,
202 'title' => ts('Email Location Type') ,
203 'description' => 'Which Location does this email belong to.',
204 'html' => array(
205 'type' => 'Select',
206 ) ,
207 'pseudoconstant' => array(
208 'table' => 'civicrm_location_type',
209 'keyColumn' => 'id',
210 'labelColumn' => 'display_name',
211 )
212 ) ,
213 'email' => array(
214 'name' => 'email',
215 'type' => CRM_Utils_Type::T_STRING,
216 'title' => ts('Email') ,
217 'description' => 'Email address',
218 'maxlength' => 254,
219 'size' => 30,
220 'import' => true,
221 'where' => 'civicrm_email.email',
222 'headerPattern' => '/e.?mail/i',
223 'dataPattern' => '/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/',
224 'export' => true,
225 'rule' => 'email',
226 'html' => array(
227 'type' => 'Text',
228 ) ,
229 ) ,
230 'is_primary' => array(
231 'name' => 'is_primary',
232 'type' => CRM_Utils_Type::T_BOOLEAN,
233 'title' => ts('Is Primary email') ,
234 'description' => 'Is this the primary?',
235 ) ,
236 'is_billing' => array(
237 'name' => 'is_billing',
238 'type' => CRM_Utils_Type::T_BOOLEAN,
239 'title' => ts('Is Billing Email?') ,
240 'description' => 'Is this the billing?',
241 ) ,
242 'on_hold' => array(
243 'name' => 'on_hold',
244 'type' => CRM_Utils_Type::T_BOOLEAN,
245 'title' => ts('On Hold') ,
246 'description' => 'Is this address on bounce hold?',
247 'required' => true,
248 'export' => true,
249 'where' => 'civicrm_email.on_hold',
250 'headerPattern' => '',
251 'dataPattern' => '',
252 'html' => array(
253 'type' => 'CheckBox',
254 ) ,
255 ) ,
256 'is_bulkmail' => array(
257 'name' => 'is_bulkmail',
258 'type' => CRM_Utils_Type::T_BOOLEAN,
259 'title' => ts('Use for Bulk Mail') ,
260 'description' => 'Is this address for bulk mail ?',
261 'required' => true,
262 'export' => true,
263 'where' => 'civicrm_email.is_bulkmail',
264 'headerPattern' => '',
265 'dataPattern' => '',
266 ) ,
267 'hold_date' => array(
268 'name' => 'hold_date',
269 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
270 'title' => ts('Hold Date') ,
271 'description' => 'When the address went on bounce hold',
272 ) ,
273 'reset_date' => array(
274 'name' => 'reset_date',
275 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
276 'title' => ts('Reset Date') ,
277 'description' => 'When the address bounce status was last reset',
278 ) ,
279 'signature_text' => array(
280 'name' => 'signature_text',
281 'type' => CRM_Utils_Type::T_TEXT,
282 'title' => ts('Signature Text') ,
283 'description' => 'Text formatted signature for the email.',
284 'import' => true,
285 'where' => 'civicrm_email.signature_text',
286 'headerPattern' => '',
287 'dataPattern' => '',
288 'export' => true,
289 'default' => 'NULL',
290 ) ,
291 'signature_html' => array(
292 'name' => 'signature_html',
293 'type' => CRM_Utils_Type::T_TEXT,
294 'title' => ts('Signature Html') ,
295 'description' => 'HTML formatted signature for the email.',
296 'import' => true,
297 'where' => 'civicrm_email.signature_html',
298 'headerPattern' => '',
299 'dataPattern' => '',
300 'export' => true,
301 'default' => 'NULL',
302 ) ,
303 );
304 }
305 return self::$_fields;
306 }
307 /**
308 * Returns an array containing, for each field, the arary key used for that
309 * field in self::$_fields.
310 *
311 * @return array
312 */
313 static function &fieldKeys() {
314 if (!(self::$_fieldKeys)) {
315 self::$_fieldKeys = array(
316 'id' => 'id',
317 'contact_id' => 'contact_id',
318 'location_type_id' => 'location_type_id',
319 'email' => 'email',
320 'is_primary' => 'is_primary',
321 'is_billing' => 'is_billing',
322 'on_hold' => 'on_hold',
323 'is_bulkmail' => 'is_bulkmail',
324 'hold_date' => 'hold_date',
325 'reset_date' => 'reset_date',
326 'signature_text' => 'signature_text',
327 'signature_html' => 'signature_html',
328 );
329 }
330 return self::$_fieldKeys;
331 }
332 /**
333 * Returns the names of this table
334 *
335 * @return string
336 */
337 static function getTableName() {
338 return self::$_tableName;
339 }
340 /**
341 * Returns if this table needs to be logged
342 *
343 * @return boolean
344 */
345 function getLog() {
346 return self::$_log;
347 }
348 /**
349 * Returns the list of fields that can be imported
350 *
351 * @param bool $prefix
352 *
353 * @return array
354 */
355 static function &import($prefix = false) {
356 if (!(self::$_import)) {
357 self::$_import = array();
358 $fields = self::fields();
359 foreach($fields as $name => $field) {
360 if (CRM_Utils_Array::value('import', $field)) {
361 if ($prefix) {
362 self::$_import['email'] = & $fields[$name];
363 } else {
364 self::$_import[$name] = & $fields[$name];
365 }
366 }
367 }
368 }
369 return self::$_import;
370 }
371 /**
372 * Returns the list of fields that can be exported
373 *
374 * @param bool $prefix
375 *
376 * @return array
377 */
378 static function &export($prefix = false) {
379 if (!(self::$_export)) {
380 self::$_export = array();
381 $fields = self::fields();
382 foreach($fields as $name => $field) {
383 if (CRM_Utils_Array::value('export', $field)) {
384 if ($prefix) {
385 self::$_export['email'] = & $fields[$name];
386 } else {
387 self::$_export[$name] = & $fields[$name];
388 }
389 }
390 }
391 }
392 return self::$_export;
393 }
394 }