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:2a48ebd09a4f1de290856c1e7315ce69)
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
86 * @var bool|string|null
88 * Note that values will be retrieved from the database as a string.
93 * Is this the billing?
95 * @var bool|string|null
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'),
276 'where' => 'civicrm_email.is_primary',
278 'table_name' => 'civicrm_email',
280 'bao' => 'CRM_Core_BAO_Email',
288 'name' => 'is_billing',
289 'type' => CRM_Utils_Type
::T_BOOLEAN
,
290 'title' => ts('Is Billing Email?'),
291 'description' => ts('Is this the billing?'),
292 'where' => 'civicrm_email.is_billing',
294 'table_name' => 'civicrm_email',
296 'bao' => 'CRM_Core_BAO_Email',
302 'type' => CRM_Utils_Type
::T_INT
,
303 'title' => ts('On Hold'),
304 'description' => ts('Implicit FK to civicrm_option_value where option_group = email_on_hold.'),
306 'where' => 'civicrm_email.on_hold',
309 'table_name' => 'civicrm_email',
311 'bao' => 'CRM_Core_BAO_Email',
316 'pseudoconstant' => [
317 'callback' => 'CRM_Core_PseudoConstant::emailOnHoldOptions',
322 'name' => 'is_bulkmail',
323 'type' => CRM_Utils_Type
::T_BOOLEAN
,
324 'title' => ts('Use for Bulk Mail'),
325 'description' => ts('Is this address for bulk mail ?'),
327 'where' => 'civicrm_email.is_bulkmail',
330 'table_name' => 'civicrm_email',
332 'bao' => 'CRM_Core_BAO_Email',
337 'name' => 'hold_date',
338 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
339 'title' => ts('Hold Date'),
340 'description' => ts('When the address went on bounce hold'),
341 'where' => 'civicrm_email.hold_date',
342 'table_name' => 'civicrm_email',
344 'bao' => 'CRM_Core_BAO_Email',
347 'type' => 'Select Date',
348 'formatType' => 'activityDateTime',
349 'label' => ts("Hold Date"),
354 'name' => 'reset_date',
355 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
356 'title' => ts('Reset Date'),
357 'description' => ts('When the address bounce status was last reset'),
358 'where' => 'civicrm_email.reset_date',
359 'table_name' => 'civicrm_email',
361 'bao' => 'CRM_Core_BAO_Email',
364 'type' => 'Select Date',
365 'formatType' => 'activityDateTime',
366 'label' => ts("Reset Date"),
370 'signature_text' => [
371 'name' => 'signature_text',
372 'type' => CRM_Utils_Type
::T_TEXT
,
373 'title' => ts('Signature Text'),
374 'description' => ts('Text formatted signature for the email.'),
376 'where' => 'civicrm_email.signature_text',
379 'table_name' => 'civicrm_email',
381 'bao' => 'CRM_Core_BAO_Email',
384 'label' => ts("Signature Text"),
388 'signature_html' => [
389 'name' => 'signature_html',
390 'type' => CRM_Utils_Type
::T_TEXT
,
391 'title' => ts('Signature Html'),
392 'description' => ts('HTML formatted signature for the email.'),
394 'where' => 'civicrm_email.signature_html',
397 'table_name' => 'civicrm_email',
399 'bao' => 'CRM_Core_BAO_Email',
402 'label' => ts("Signature HTML"),
407 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
409 return Civi
::$statics[__CLASS__
]['fields'];
413 * Return a mapping from field-name to the corresponding key (as used in fields()).
416 * Array(string $name => string $uniqueName).
418 public static function &fieldKeys() {
419 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
420 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
422 return Civi
::$statics[__CLASS__
]['fieldKeys'];
426 * Returns the names of this table
430 public static function getTableName() {
431 return self
::$_tableName;
435 * Returns if this table needs to be logged
439 public function getLog() {
444 * Returns the list of fields that can be imported
446 * @param bool $prefix
450 public static function &import($prefix = FALSE) {
451 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'email', $prefix, []);
456 * Returns the list of fields that can be exported
458 * @param bool $prefix
462 public static function &export($prefix = FALSE) {
463 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'email', $prefix, []);
468 * Returns the list of indices
470 * @param bool $localize
474 public static function indices($localize = TRUE) {
476 'index_location_type' => [
477 'name' => 'index_location_type',
479 0 => 'location_type_id',
481 'localizable' => FALSE,
482 'sig' => 'civicrm_email::0::location_type_id',
485 'name' => 'UI_email',
489 'localizable' => FALSE,
490 'sig' => 'civicrm_email::0::email',
492 'index_is_primary' => [
493 'name' => 'index_is_primary',
497 'localizable' => FALSE,
498 'sig' => 'civicrm_email::0::is_primary',
500 'index_is_billing' => [
501 'name' => 'index_is_billing',
505 'localizable' => FALSE,
506 'sig' => 'civicrm_email::0::is_billing',
509 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;