Merge pull request #12056 from eileenmcnaughton/pcp
[civicrm-core.git] / CRM / Core / DAO / Email.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC (c) 2004-2018
6 *
7 * Generated from xml/schema/CRM/Core/Email.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:08f53d44527d7d174b4aa1bd545b028c)
10 */
11
12 /**
13 * Database access object for the Email entity.
14 */
15 class CRM_Core_DAO_Email extends CRM_Core_DAO {
16
17 /**
18 * Static instance to hold the table name.
19 *
20 * @var string
21 */
22 static $_tableName = 'civicrm_email';
23
24 /**
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
26 *
27 * @var bool
28 */
29 static $_log = TRUE;
30
31 /**
32 * Unique Email ID
33 *
34 * @var int unsigned
35 */
36 public $id;
37
38 /**
39 * FK to Contact ID
40 *
41 * @var int unsigned
42 */
43 public $contact_id;
44
45 /**
46 * Which Location does this email belong to.
47 *
48 * @var int unsigned
49 */
50 public $location_type_id;
51
52 /**
53 * Email address
54 *
55 * @var string
56 */
57 public $email;
58
59 /**
60 * Is this the primary?
61 *
62 * @var boolean
63 */
64 public $is_primary;
65
66 /**
67 * Is this the billing?
68 *
69 * @var boolean
70 */
71 public $is_billing;
72
73 /**
74 * Is this address on bounce hold?
75 *
76 * @var boolean
77 */
78 public $on_hold;
79
80 /**
81 * Is this address for bulk mail ?
82 *
83 * @var boolean
84 */
85 public $is_bulkmail;
86
87 /**
88 * When the address went on bounce hold
89 *
90 * @var datetime
91 */
92 public $hold_date;
93
94 /**
95 * When the address bounce status was last reset
96 *
97 * @var datetime
98 */
99 public $reset_date;
100
101 /**
102 * Text formatted signature for the email.
103 *
104 * @var text
105 */
106 public $signature_text;
107
108 /**
109 * HTML formatted signature for the email.
110 *
111 * @var text
112 */
113 public $signature_html;
114
115 /**
116 * Class constructor.
117 */
118 public function __construct() {
119 $this->__table = 'civicrm_email';
120 parent::__construct();
121 }
122
123 /**
124 * Returns foreign keys and entity references.
125 *
126 * @return array
127 * [CRM_Core_Reference_Interface]
128 */
129 public static function getReferenceColumns() {
130 if (!isset(Civi::$statics[__CLASS__]['links'])) {
131 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
132 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
133 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
134 }
135 return Civi::$statics[__CLASS__]['links'];
136 }
137
138 /**
139 * Returns all the column names of this table
140 *
141 * @return array
142 */
143 public static function &fields() {
144 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
145 Civi::$statics[__CLASS__]['fields'] = [
146 'id' => [
147 'name' => 'id',
148 'type' => CRM_Utils_Type::T_INT,
149 'title' => ts('Email ID'),
150 'description' => 'Unique Email ID',
151 'required' => TRUE,
152 'table_name' => 'civicrm_email',
153 'entity' => 'Email',
154 'bao' => 'CRM_Core_BAO_Email',
155 'localizable' => 0,
156 ],
157 'contact_id' => [
158 'name' => 'contact_id',
159 'type' => CRM_Utils_Type::T_INT,
160 'title' => ts('Email Contact'),
161 'description' => 'FK to Contact ID',
162 'table_name' => 'civicrm_email',
163 'entity' => 'Email',
164 'bao' => 'CRM_Core_BAO_Email',
165 'localizable' => 0,
166 'FKClassName' => 'CRM_Contact_DAO_Contact',
167 ],
168 'location_type_id' => [
169 'name' => 'location_type_id',
170 'type' => CRM_Utils_Type::T_INT,
171 'title' => ts('Email Location Type'),
172 'description' => 'Which Location does this email belong to.',
173 'table_name' => 'civicrm_email',
174 'entity' => 'Email',
175 'bao' => 'CRM_Core_BAO_Email',
176 'localizable' => 0,
177 'html' => [
178 'type' => 'Select',
179 ],
180 'pseudoconstant' => [
181 'table' => 'civicrm_location_type',
182 'keyColumn' => 'id',
183 'labelColumn' => 'display_name',
184 ]
185 ],
186 'email' => [
187 'name' => 'email',
188 'type' => CRM_Utils_Type::T_STRING,
189 'title' => ts('Email'),
190 'description' => 'Email address',
191 'maxlength' => 254,
192 'size' => 30,
193 'import' => TRUE,
194 'where' => 'civicrm_email.email',
195 'headerPattern' => '/e.?mail/i',
196 '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]$/',
197 'export' => TRUE,
198 'rule' => 'email',
199 'table_name' => 'civicrm_email',
200 'entity' => 'Email',
201 'bao' => 'CRM_Core_BAO_Email',
202 'localizable' => 0,
203 'html' => [
204 'type' => 'Text',
205 ],
206 ],
207 'is_primary' => [
208 'name' => 'is_primary',
209 'type' => CRM_Utils_Type::T_BOOLEAN,
210 'title' => ts('Is Primary email'),
211 'description' => 'Is this the primary?',
212 'table_name' => 'civicrm_email',
213 'entity' => 'Email',
214 'bao' => 'CRM_Core_BAO_Email',
215 'localizable' => 0,
216 ],
217 'is_billing' => [
218 'name' => 'is_billing',
219 'type' => CRM_Utils_Type::T_BOOLEAN,
220 'title' => ts('Is Billing Email?'),
221 'description' => 'Is this the billing?',
222 'table_name' => 'civicrm_email',
223 'entity' => 'Email',
224 'bao' => 'CRM_Core_BAO_Email',
225 'localizable' => 0,
226 ],
227 'on_hold' => [
228 'name' => 'on_hold',
229 'type' => CRM_Utils_Type::T_BOOLEAN,
230 'title' => ts('On Hold'),
231 'description' => 'Is this address on bounce hold?',
232 'required' => TRUE,
233 'export' => TRUE,
234 'where' => 'civicrm_email.on_hold',
235 'headerPattern' => '',
236 'dataPattern' => '',
237 'table_name' => 'civicrm_email',
238 'entity' => 'Email',
239 'bao' => 'CRM_Core_BAO_Email',
240 'localizable' => 0,
241 'html' => [
242 'type' => 'CheckBox',
243 ],
244 ],
245 'is_bulkmail' => [
246 'name' => 'is_bulkmail',
247 'type' => CRM_Utils_Type::T_BOOLEAN,
248 'title' => ts('Use for Bulk Mail'),
249 'description' => 'Is this address for bulk mail ?',
250 'required' => TRUE,
251 'export' => TRUE,
252 'where' => 'civicrm_email.is_bulkmail',
253 'headerPattern' => '',
254 'dataPattern' => '',
255 'table_name' => 'civicrm_email',
256 'entity' => 'Email',
257 'bao' => 'CRM_Core_BAO_Email',
258 'localizable' => 0,
259 ],
260 'hold_date' => [
261 'name' => 'hold_date',
262 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
263 'title' => ts('Hold Date'),
264 'description' => 'When the address went on bounce hold',
265 'table_name' => 'civicrm_email',
266 'entity' => 'Email',
267 'bao' => 'CRM_Core_BAO_Email',
268 'localizable' => 0,
269 ],
270 'reset_date' => [
271 'name' => 'reset_date',
272 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
273 'title' => ts('Reset Date'),
274 'description' => 'When the address bounce status was last reset',
275 'table_name' => 'civicrm_email',
276 'entity' => 'Email',
277 'bao' => 'CRM_Core_BAO_Email',
278 'localizable' => 0,
279 ],
280 'signature_text' => [
281 'name' => 'signature_text',
282 'type' => CRM_Utils_Type::T_TEXT,
283 'title' => ts('Signature Text'),
284 'description' => 'Text formatted signature for the email.',
285 'import' => TRUE,
286 'where' => 'civicrm_email.signature_text',
287 'headerPattern' => '',
288 'dataPattern' => '',
289 'export' => TRUE,
290 'default' => 'NULL',
291 'table_name' => 'civicrm_email',
292 'entity' => 'Email',
293 'bao' => 'CRM_Core_BAO_Email',
294 'localizable' => 0,
295 ],
296 'signature_html' => [
297 'name' => 'signature_html',
298 'type' => CRM_Utils_Type::T_TEXT,
299 'title' => ts('Signature Html'),
300 'description' => 'HTML formatted signature for the email.',
301 'import' => TRUE,
302 'where' => 'civicrm_email.signature_html',
303 'headerPattern' => '',
304 'dataPattern' => '',
305 'export' => TRUE,
306 'default' => 'NULL',
307 'table_name' => 'civicrm_email',
308 'entity' => 'Email',
309 'bao' => 'CRM_Core_BAO_Email',
310 'localizable' => 0,
311 ],
312 ];
313 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
314 }
315 return Civi::$statics[__CLASS__]['fields'];
316 }
317
318 /**
319 * Return a mapping from field-name to the corresponding key (as used in fields()).
320 *
321 * @return array
322 * Array(string $name => string $uniqueName).
323 */
324 public static function &fieldKeys() {
325 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
326 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
327 }
328 return Civi::$statics[__CLASS__]['fieldKeys'];
329 }
330
331 /**
332 * Returns the names of this table
333 *
334 * @return string
335 */
336 public static function getTableName() {
337 return self::$_tableName;
338 }
339
340 /**
341 * Returns if this table needs to be logged
342 *
343 * @return bool
344 */
345 public function getLog() {
346 return self::$_log;
347 }
348
349 /**
350 * Returns the list of fields that can be imported
351 *
352 * @param bool $prefix
353 *
354 * @return array
355 */
356 public static function &import($prefix = FALSE) {
357 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'email', $prefix, []);
358 return $r;
359 }
360
361 /**
362 * Returns the list of fields that can be exported
363 *
364 * @param bool $prefix
365 *
366 * @return array
367 */
368 public static function &export($prefix = FALSE) {
369 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'email', $prefix, []);
370 return $r;
371 }
372
373 /**
374 * Returns the list of indices
375 *
376 * @param bool $localize
377 *
378 * @return array
379 */
380 public static function indices($localize = TRUE) {
381 $indices = [
382 'index_location_type' => [
383 'name' => 'index_location_type',
384 'field' => [
385 0 => 'location_type_id',
386 ],
387 'localizable' => FALSE,
388 'sig' => 'civicrm_email::0::location_type_id',
389 ],
390 'UI_email' => [
391 'name' => 'UI_email',
392 'field' => [
393 0 => 'email',
394 ],
395 'localizable' => FALSE,
396 'sig' => 'civicrm_email::0::email',
397 ],
398 'index_is_primary' => [
399 'name' => 'index_is_primary',
400 'field' => [
401 0 => 'is_primary',
402 ],
403 'localizable' => FALSE,
404 'sig' => 'civicrm_email::0::is_primary',
405 ],
406 'index_is_billing' => [
407 'name' => 'index_is_billing',
408 'field' => [
409 0 => 'is_billing',
410 ],
411 'localizable' => FALSE,
412 'sig' => 'civicrm_email::0::is_billing',
413 ],
414 ];
415 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
416 }
417
418 }