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:4587ad732a1c0eee767b2180c1a79dcf)
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',
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',
196 'bao' => 'CRM_Core_BAO_Email',
198 'FKClassName' => 'CRM_Contact_DAO_Contact',
200 'label' => ts("Contact"),
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',
212 'bao' => 'CRM_Core_BAO_Email',
217 'pseudoconstant' => [
218 'table' => 'civicrm_location_type',
220 'labelColumn' => 'display_name',
226 'type' => CRM_Utils_Type
::T_STRING
,
227 'title' => ts('Email'),
228 'description' => ts('Email address'),
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]$/',
237 'table_name' => 'civicrm_email',
239 'bao' => 'CRM_Core_BAO_Email',
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',
253 'table_name' => 'civicrm_email',
255 'bao' => 'CRM_Core_BAO_Email',
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',
269 'table_name' => 'civicrm_email',
271 'bao' => 'CRM_Core_BAO_Email',
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.'),
281 'where' => 'civicrm_email.on_hold',
284 'table_name' => 'civicrm_email',
286 'bao' => 'CRM_Core_BAO_Email',
291 'pseudoconstant' => [
292 'callback' => 'CRM_Core_PseudoConstant::emailOnHoldOptions',
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 ?'),
302 'where' => 'civicrm_email.is_bulkmail',
305 'table_name' => 'civicrm_email',
307 'bao' => 'CRM_Core_BAO_Email',
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',
319 'bao' => 'CRM_Core_BAO_Email',
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',
331 'bao' => 'CRM_Core_BAO_Email',
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.'),
341 'where' => 'civicrm_email.signature_text',
344 'table_name' => 'civicrm_email',
346 'bao' => 'CRM_Core_BAO_Email',
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.'),
356 'where' => 'civicrm_email.signature_html',
359 'table_name' => 'civicrm_email',
361 'bao' => 'CRM_Core_BAO_Email',
366 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
368 return Civi
::$statics[__CLASS__
]['fields'];
372 * Return a mapping from field-name to the corresponding key (as used in fields()).
375 * Array(string $name => string $uniqueName).
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()));
381 return Civi
::$statics[__CLASS__
]['fieldKeys'];
385 * Returns the names of this table
389 public static function getTableName() {
390 return self
::$_tableName;
394 * Returns if this table needs to be logged
398 public function getLog() {
403 * Returns the list of fields that can be imported
405 * @param bool $prefix
409 public static function &import($prefix = FALSE) {
410 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'email', $prefix, []);
415 * Returns the list of fields that can be exported
417 * @param bool $prefix
421 public static function &export($prefix = FALSE) {
422 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'email', $prefix, []);
427 * Returns the list of indices
429 * @param bool $localize
433 public static function indices($localize = TRUE) {
435 'index_location_type' => [
436 'name' => 'index_location_type',
438 0 => 'location_type_id',
440 'localizable' => FALSE,
441 'sig' => 'civicrm_email::0::location_type_id',
444 'name' => 'UI_email',
448 'localizable' => FALSE,
449 'sig' => 'civicrm_email::0::email',
451 'index_is_primary' => [
452 'name' => 'index_is_primary',
456 'localizable' => FALSE,
457 'sig' => 'civicrm_email::0::is_primary',
459 'index_is_billing' => [
460 'name' => 'index_is_billing',
464 'localizable' => FALSE,
465 'sig' => 'civicrm_email::0::is_billing',
468 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;