5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Core/Email.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:58fe115e0962f83c3906bce5f663f0fc)
13 * Database access object for the Email entity.
15 class CRM_Core_DAO_Email
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '1.1';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_email';
27 * Icon associated with this entity.
31 public static $_icon = 'fa-envelope-o';
34 * Field to show when displaying a record.
38 public static $_labelField = 'email';
41 * Should CiviCRM log any modifications to this table in the civicrm_log table.
45 public static $_log = TRUE;
50 * @var int|string|null
51 * (SQL type: int unsigned)
52 * Note that values will be retrieved from the database as a string.
59 * @var int|string|null
60 * (SQL type: int unsigned)
61 * Note that values will be retrieved from the database as a string.
66 * Which Location does this email belong to.
68 * @var int|string|null
69 * (SQL type: int unsigned)
70 * Note that values will be retrieved from the database as a string.
72 public $location_type_id;
78 * (SQL type: varchar(254))
79 * Note that values will be retrieved from the database as a string.
84 * Is this the primary email address
88 * Note that values will be retrieved from the database as a string.
93 * Is this the billing?
97 * Note that values will be retrieved from the database as a string.
102 * Implicit FK to civicrm_option_value where option_group = email_on_hold.
105 * (SQL type: int unsigned)
106 * Note that values will be retrieved from the database as a string.
111 * Is this address for bulk mail ?
114 * (SQL type: tinyint)
115 * Note that values will be retrieved from the database as a string.
120 * When the address went on bounce hold
123 * (SQL type: datetime)
124 * Note that values will be retrieved from the database as a string.
129 * When the address bounce status was last reset
132 * (SQL type: datetime)
133 * Note that values will be retrieved from the database as a string.
138 * Text formatted signature for the email.
142 * Note that values will be retrieved from the database as a string.
144 public $signature_text;
147 * HTML formatted signature for the email.
151 * Note that values will be retrieved from the database as a string.
153 public $signature_html;
158 public function __construct() {
159 $this->__table
= 'civicrm_email';
160 parent
::__construct();
164 * Returns localized title of this entity.
166 * @param bool $plural
167 * Whether to return the plural version of the title.
169 public static function getEntityTitle($plural = FALSE) {
170 return $plural ?
ts('Emails') : ts('Email');
174 * Returns foreign keys and entity references.
177 * [CRM_Core_Reference_Interface]
179 public static function getReferenceColumns() {
180 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
181 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
182 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
183 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
185 return Civi
::$statics[__CLASS__
]['links'];
189 * Returns all the column names of this table
193 public static function &fields() {
194 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
195 Civi
::$statics[__CLASS__
]['fields'] = [
198 'type' => CRM_Utils_Type
::T_INT
,
199 'title' => ts('Email ID'),
200 'description' => ts('Unique Email ID'),
202 'where' => 'civicrm_email.id',
203 'table_name' => 'civicrm_email',
205 'bao' => 'CRM_Core_BAO_Email',
214 'name' => 'contact_id',
215 'type' => CRM_Utils_Type
::T_INT
,
216 'title' => ts('Contact ID'),
217 'description' => ts('FK to Contact ID'),
218 'where' => 'civicrm_email.contact_id',
219 'table_name' => 'civicrm_email',
221 'bao' => 'CRM_Core_BAO_Email',
223 'FKClassName' => 'CRM_Contact_DAO_Contact',
225 'label' => ts("Contact"),
229 'location_type_id' => [
230 'name' => 'location_type_id',
231 'type' => CRM_Utils_Type
::T_INT
,
232 'title' => ts('Email Location Type'),
233 'description' => ts('Which Location does this email belong to.'),
234 'where' => 'civicrm_email.location_type_id',
235 'table_name' => 'civicrm_email',
237 'bao' => 'CRM_Core_BAO_Email',
242 'pseudoconstant' => [
243 'table' => 'civicrm_location_type',
245 'labelColumn' => 'display_name',
251 'type' => CRM_Utils_Type
::T_STRING
,
252 'title' => ts('Email'),
253 'description' => ts('Email address'),
257 'where' => 'civicrm_email.email',
258 'headerPattern' => '/e.?mail/i',
259 '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]$/',
262 'table_name' => 'civicrm_email',
264 'bao' => 'CRM_Core_BAO_Email',
272 'name' => 'is_primary',
273 'type' => CRM_Utils_Type
::T_BOOLEAN
,
274 'title' => ts('Primary email'),
275 'description' => ts('Is this the primary email address'),
277 'where' => 'civicrm_email.is_primary',
279 'table_name' => 'civicrm_email',
281 'bao' => 'CRM_Core_BAO_Email',
289 'name' => 'is_billing',
290 'type' => CRM_Utils_Type
::T_BOOLEAN
,
291 'title' => ts('Is Billing Email?'),
292 'description' => ts('Is this the billing?'),
294 'where' => 'civicrm_email.is_billing',
296 'table_name' => 'civicrm_email',
298 'bao' => 'CRM_Core_BAO_Email',
304 'type' => CRM_Utils_Type
::T_INT
,
305 'title' => ts('On Hold'),
306 'description' => ts('Implicit FK to civicrm_option_value where option_group = email_on_hold.'),
308 'where' => 'civicrm_email.on_hold',
311 'table_name' => 'civicrm_email',
313 'bao' => 'CRM_Core_BAO_Email',
318 'pseudoconstant' => [
319 'callback' => 'CRM_Core_PseudoConstant::emailOnHoldOptions',
324 'name' => 'is_bulkmail',
325 'type' => CRM_Utils_Type
::T_BOOLEAN
,
326 'title' => ts('Use for Bulk Mail'),
327 'description' => ts('Is this address for bulk mail ?'),
329 'where' => 'civicrm_email.is_bulkmail',
332 'table_name' => 'civicrm_email',
334 'bao' => 'CRM_Core_BAO_Email',
339 'name' => 'hold_date',
340 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
341 'title' => ts('Hold Date'),
342 'description' => ts('When the address went on bounce hold'),
343 'where' => 'civicrm_email.hold_date',
344 'table_name' => 'civicrm_email',
346 'bao' => 'CRM_Core_BAO_Email',
349 'type' => 'Select Date',
350 'formatType' => 'activityDateTime',
351 'label' => ts("Hold Date"),
356 'name' => 'reset_date',
357 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
358 'title' => ts('Reset Date'),
359 'description' => ts('When the address bounce status was last reset'),
360 'where' => 'civicrm_email.reset_date',
361 'table_name' => 'civicrm_email',
363 'bao' => 'CRM_Core_BAO_Email',
366 'type' => 'Select Date',
367 'formatType' => 'activityDateTime',
368 'label' => ts("Reset Date"),
372 'signature_text' => [
373 'name' => 'signature_text',
374 'type' => CRM_Utils_Type
::T_TEXT
,
375 'title' => ts('Signature Text'),
376 'description' => ts('Text formatted signature for the email.'),
378 'where' => 'civicrm_email.signature_text',
381 'table_name' => 'civicrm_email',
383 'bao' => 'CRM_Core_BAO_Email',
386 'label' => ts("Signature Text"),
390 'signature_html' => [
391 'name' => 'signature_html',
392 'type' => CRM_Utils_Type
::T_TEXT
,
393 'title' => ts('Signature Html'),
394 'description' => ts('HTML formatted signature for the email.'),
396 'where' => 'civicrm_email.signature_html',
399 'table_name' => 'civicrm_email',
401 'bao' => 'CRM_Core_BAO_Email',
404 'label' => ts("Signature HTML"),
409 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
411 return Civi
::$statics[__CLASS__
]['fields'];
415 * Return a mapping from field-name to the corresponding key (as used in fields()).
418 * Array(string $name => string $uniqueName).
420 public static function &fieldKeys() {
421 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
422 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
424 return Civi
::$statics[__CLASS__
]['fieldKeys'];
428 * Returns the names of this table
432 public static function getTableName() {
433 return self
::$_tableName;
437 * Returns if this table needs to be logged
441 public function getLog() {
446 * Returns the list of fields that can be imported
448 * @param bool $prefix
452 public static function &import($prefix = FALSE) {
453 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'email', $prefix, []);
458 * Returns the list of fields that can be exported
460 * @param bool $prefix
464 public static function &export($prefix = FALSE) {
465 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'email', $prefix, []);
470 * Returns the list of indices
472 * @param bool $localize
476 public static function indices($localize = TRUE) {
478 'index_location_type' => [
479 'name' => 'index_location_type',
481 0 => 'location_type_id',
483 'localizable' => FALSE,
484 'sig' => 'civicrm_email::0::location_type_id',
487 'name' => 'UI_email',
491 'localizable' => FALSE,
492 'sig' => 'civicrm_email::0::email',
494 'index_is_primary' => [
495 'name' => 'index_is_primary',
499 'localizable' => FALSE,
500 'sig' => 'civicrm_email::0::is_primary',
502 'index_is_billing' => [
503 'name' => 'index_is_billing',
507 'localizable' => FALSE,
508 'sig' => 'civicrm_email::0::is_billing',
511 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;