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