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:7e30aa415b50a25add79b9553b5d7657)
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;
62 * Which Location does this email belong to.
66 public $location_type_id;
76 * Is this the primary email address
83 * Is this the billing?
90 * Implicit FK to civicrm_option_value where option_group = email_on_hold.
97 * Is this address for bulk mail ?
104 * When the address went on bounce hold
111 * When the address bounce status was last reset
118 * Text formatted signature for the email.
122 public $signature_text;
125 * HTML formatted signature for the email.
129 public $signature_html;
134 public function __construct() {
135 $this->__table
= 'civicrm_email';
136 parent
::__construct();
140 * Returns localized title of this entity.
142 * @param bool $plural
143 * Whether to return the plural version of the title.
145 public static function getEntityTitle($plural = FALSE) {
146 return $plural ?
ts('Emails') : ts('Email');
150 * Returns foreign keys and entity references.
153 * [CRM_Core_Reference_Interface]
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']);
161 return Civi
::$statics[__CLASS__
]['links'];
165 * Returns all the column names of this table
169 public static function &fields() {
170 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
171 Civi
::$statics[__CLASS__
]['fields'] = [
174 'type' => CRM_Utils_Type
::T_INT
,
175 'title' => ts('Email ID'),
176 'description' => ts('Unique Email ID'),
178 'where' => 'civicrm_email.id',
179 'table_name' => 'civicrm_email',
181 'bao' => 'CRM_Core_BAO_Email',
190 'name' => 'contact_id',
191 'type' => CRM_Utils_Type
::T_INT
,
192 'title' => ts('Contact ID'),
193 'description' => ts('FK to Contact ID'),
194 'where' => 'civicrm_email.contact_id',
195 'table_name' => 'civicrm_email',
197 'bao' => 'CRM_Core_BAO_Email',
199 'FKClassName' => 'CRM_Contact_DAO_Contact',
201 'label' => ts("Contact"),
205 'location_type_id' => [
206 'name' => 'location_type_id',
207 'type' => CRM_Utils_Type
::T_INT
,
208 'title' => ts('Email Location Type'),
209 'description' => ts('Which Location does this email belong to.'),
210 'where' => 'civicrm_email.location_type_id',
211 'table_name' => 'civicrm_email',
213 'bao' => 'CRM_Core_BAO_Email',
218 'pseudoconstant' => [
219 'table' => 'civicrm_location_type',
221 'labelColumn' => 'display_name',
227 'type' => CRM_Utils_Type
::T_STRING
,
228 'title' => ts('Email'),
229 'description' => ts('Email address'),
233 'where' => 'civicrm_email.email',
234 'headerPattern' => '/e.?mail/i',
235 '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]$/',
238 'table_name' => 'civicrm_email',
240 'bao' => 'CRM_Core_BAO_Email',
248 'name' => 'is_primary',
249 'type' => CRM_Utils_Type
::T_BOOLEAN
,
250 'title' => ts('Primary email'),
251 'description' => ts('Is this the primary email address'),
252 'where' => 'civicrm_email.is_primary',
254 'table_name' => 'civicrm_email',
256 'bao' => 'CRM_Core_BAO_Email',
264 'name' => 'is_billing',
265 'type' => CRM_Utils_Type
::T_BOOLEAN
,
266 'title' => ts('Is Billing Email?'),
267 'description' => ts('Is this the billing?'),
268 'where' => 'civicrm_email.is_billing',
270 'table_name' => 'civicrm_email',
272 'bao' => 'CRM_Core_BAO_Email',
278 'type' => CRM_Utils_Type
::T_INT
,
279 'title' => ts('On Hold'),
280 'description' => ts('Implicit FK to civicrm_option_value where option_group = email_on_hold.'),
282 'where' => 'civicrm_email.on_hold',
285 'table_name' => 'civicrm_email',
287 'bao' => 'CRM_Core_BAO_Email',
292 'pseudoconstant' => [
293 'callback' => 'CRM_Core_PseudoConstant::emailOnHoldOptions',
298 'name' => 'is_bulkmail',
299 'type' => CRM_Utils_Type
::T_BOOLEAN
,
300 'title' => ts('Use for Bulk Mail'),
301 'description' => ts('Is this address for bulk mail ?'),
303 'where' => 'civicrm_email.is_bulkmail',
306 'table_name' => 'civicrm_email',
308 'bao' => 'CRM_Core_BAO_Email',
313 'name' => 'hold_date',
314 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
315 'title' => ts('Hold Date'),
316 'description' => ts('When the address went on bounce hold'),
317 'where' => 'civicrm_email.hold_date',
318 'table_name' => 'civicrm_email',
320 'bao' => 'CRM_Core_BAO_Email',
323 'type' => 'Select Date',
324 'formatType' => 'activityDateTime',
325 'label' => ts("Hold Date"),
330 'name' => 'reset_date',
331 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
332 'title' => ts('Reset Date'),
333 'description' => ts('When the address bounce status was last reset'),
334 'where' => 'civicrm_email.reset_date',
335 'table_name' => 'civicrm_email',
337 'bao' => 'CRM_Core_BAO_Email',
340 'type' => 'Select Date',
341 'formatType' => 'activityDateTime',
342 'label' => ts("Reset Date"),
346 'signature_text' => [
347 'name' => 'signature_text',
348 'type' => CRM_Utils_Type
::T_TEXT
,
349 'title' => ts('Signature Text'),
350 'description' => ts('Text formatted signature for the email.'),
352 'where' => 'civicrm_email.signature_text',
355 'table_name' => 'civicrm_email',
357 'bao' => 'CRM_Core_BAO_Email',
360 'label' => ts("Signature Text"),
364 'signature_html' => [
365 'name' => 'signature_html',
366 'type' => CRM_Utils_Type
::T_TEXT
,
367 'title' => ts('Signature Html'),
368 'description' => ts('HTML formatted signature for the email.'),
370 'where' => 'civicrm_email.signature_html',
373 'table_name' => 'civicrm_email',
375 'bao' => 'CRM_Core_BAO_Email',
378 'label' => ts("Signature HTML"),
383 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
385 return Civi
::$statics[__CLASS__
]['fields'];
389 * Return a mapping from field-name to the corresponding key (as used in fields()).
392 * Array(string $name => string $uniqueName).
394 public static function &fieldKeys() {
395 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
396 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
398 return Civi
::$statics[__CLASS__
]['fieldKeys'];
402 * Returns the names of this table
406 public static function getTableName() {
407 return self
::$_tableName;
411 * Returns if this table needs to be logged
415 public function getLog() {
420 * Returns the list of fields that can be imported
422 * @param bool $prefix
426 public static function &import($prefix = FALSE) {
427 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'email', $prefix, []);
432 * Returns the list of fields that can be exported
434 * @param bool $prefix
438 public static function &export($prefix = FALSE) {
439 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'email', $prefix, []);
444 * Returns the list of indices
446 * @param bool $localize
450 public static function indices($localize = TRUE) {
452 'index_location_type' => [
453 'name' => 'index_location_type',
455 0 => 'location_type_id',
457 'localizable' => FALSE,
458 'sig' => 'civicrm_email::0::location_type_id',
461 'name' => 'UI_email',
465 'localizable' => FALSE,
466 'sig' => 'civicrm_email::0::email',
468 'index_is_primary' => [
469 'name' => 'index_is_primary',
473 'localizable' => FALSE,
474 'sig' => 'civicrm_email::0::is_primary',
476 'index_is_billing' => [
477 'name' => 'index_is_billing',
481 'localizable' => FALSE,
482 'sig' => 'civicrm_email::0::is_billing',
485 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;