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:032cf9c0a45f5d15baaf7a9087741569)
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 * Should CiviCRM log any modifications to this table in the civicrm_log table.
38 public static $_log = TRUE;
55 * Which Location does this email belong to.
59 public $location_type_id;
69 * Is this the primary email address
76 * Is this the billing?
83 * Implicit FK to civicrm_option_value where option_group = email_on_hold.
90 * Is this address for bulk mail ?
97 * When the address went on bounce hold
104 * When the address bounce status was last reset
111 * Text formatted signature for the email.
115 public $signature_text;
118 * HTML formatted signature for the email.
122 public $signature_html;
127 public function __construct() {
128 $this->__table
= 'civicrm_email';
129 parent
::__construct();
133 * Returns localized title of this entity.
135 * @param bool $plural
136 * Whether to return the plural version of the title.
138 public static function getEntityTitle($plural = FALSE) {
139 return $plural ?
ts('Emails') : ts('Email');
143 * Returns foreign keys and entity references.
146 * [CRM_Core_Reference_Interface]
148 public static function getReferenceColumns() {
149 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
150 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
151 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
152 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
154 return Civi
::$statics[__CLASS__
]['links'];
158 * Returns all the column names of this table
162 public static function &fields() {
163 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
164 Civi
::$statics[__CLASS__
]['fields'] = [
167 'type' => CRM_Utils_Type
::T_INT
,
168 'title' => ts('Email ID'),
169 'description' => ts('Unique Email ID'),
171 'where' => 'civicrm_email.id',
172 'table_name' => 'civicrm_email',
174 'bao' => 'CRM_Core_BAO_Email',
179 'name' => 'contact_id',
180 'type' => CRM_Utils_Type
::T_INT
,
181 'title' => ts('Email Contact'),
182 'description' => ts('FK to Contact ID'),
183 'where' => 'civicrm_email.contact_id',
184 'table_name' => 'civicrm_email',
186 'bao' => 'CRM_Core_BAO_Email',
188 'FKClassName' => 'CRM_Contact_DAO_Contact',
191 'location_type_id' => [
192 'name' => 'location_type_id',
193 'type' => CRM_Utils_Type
::T_INT
,
194 'title' => ts('Email Location Type'),
195 'description' => ts('Which Location does this email belong to.'),
196 'where' => 'civicrm_email.location_type_id',
197 'table_name' => 'civicrm_email',
199 'bao' => 'CRM_Core_BAO_Email',
204 'pseudoconstant' => [
205 'table' => 'civicrm_location_type',
207 'labelColumn' => 'display_name',
213 'type' => CRM_Utils_Type
::T_STRING
,
214 'title' => ts('Email'),
215 'description' => ts('Email address'),
219 'where' => 'civicrm_email.email',
220 'headerPattern' => '/e.?mail/i',
221 '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]$/',
224 'table_name' => 'civicrm_email',
226 'bao' => 'CRM_Core_BAO_Email',
234 'name' => 'is_primary',
235 'type' => CRM_Utils_Type
::T_BOOLEAN
,
236 'title' => ts('Primary email'),
237 'description' => ts('Is this the primary email address'),
238 'where' => 'civicrm_email.is_primary',
240 'table_name' => 'civicrm_email',
242 'bao' => 'CRM_Core_BAO_Email',
250 'name' => 'is_billing',
251 'type' => CRM_Utils_Type
::T_BOOLEAN
,
252 'title' => ts('Is Billing Email?'),
253 'description' => ts('Is this the billing?'),
254 'where' => 'civicrm_email.is_billing',
256 'table_name' => 'civicrm_email',
258 'bao' => 'CRM_Core_BAO_Email',
264 'type' => CRM_Utils_Type
::T_INT
,
265 'title' => ts('On Hold'),
266 'description' => ts('Implicit FK to civicrm_option_value where option_group = email_on_hold.'),
268 'where' => 'civicrm_email.on_hold',
271 'table_name' => 'civicrm_email',
273 'bao' => 'CRM_Core_BAO_Email',
278 'pseudoconstant' => [
279 'callback' => 'CRM_Core_PseudoConstant::emailOnHoldOptions',
284 'name' => 'is_bulkmail',
285 'type' => CRM_Utils_Type
::T_BOOLEAN
,
286 'title' => ts('Use for Bulk Mail'),
287 'description' => ts('Is this address for bulk mail ?'),
289 'where' => 'civicrm_email.is_bulkmail',
292 'table_name' => 'civicrm_email',
294 'bao' => 'CRM_Core_BAO_Email',
299 'name' => 'hold_date',
300 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
301 'title' => ts('Hold Date'),
302 'description' => ts('When the address went on bounce hold'),
303 'where' => 'civicrm_email.hold_date',
304 'table_name' => 'civicrm_email',
306 'bao' => 'CRM_Core_BAO_Email',
311 'name' => 'reset_date',
312 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
313 'title' => ts('Reset Date'),
314 'description' => ts('When the address bounce status was last reset'),
315 'where' => 'civicrm_email.reset_date',
316 'table_name' => 'civicrm_email',
318 'bao' => 'CRM_Core_BAO_Email',
322 'signature_text' => [
323 'name' => 'signature_text',
324 'type' => CRM_Utils_Type
::T_TEXT
,
325 'title' => ts('Signature Text'),
326 'description' => ts('Text formatted signature for the email.'),
328 'where' => 'civicrm_email.signature_text',
331 'table_name' => 'civicrm_email',
333 'bao' => 'CRM_Core_BAO_Email',
337 'signature_html' => [
338 'name' => 'signature_html',
339 'type' => CRM_Utils_Type
::T_TEXT
,
340 'title' => ts('Signature Html'),
341 'description' => ts('HTML formatted signature for the email.'),
343 'where' => 'civicrm_email.signature_html',
346 'table_name' => 'civicrm_email',
348 'bao' => 'CRM_Core_BAO_Email',
353 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
355 return Civi
::$statics[__CLASS__
]['fields'];
359 * Return a mapping from field-name to the corresponding key (as used in fields()).
362 * Array(string $name => string $uniqueName).
364 public static function &fieldKeys() {
365 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
366 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
368 return Civi
::$statics[__CLASS__
]['fieldKeys'];
372 * Returns the names of this table
376 public static function getTableName() {
377 return self
::$_tableName;
381 * Returns if this table needs to be logged
385 public function getLog() {
390 * Returns the list of fields that can be imported
392 * @param bool $prefix
396 public static function &import($prefix = FALSE) {
397 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'email', $prefix, []);
402 * Returns the list of fields that can be exported
404 * @param bool $prefix
408 public static function &export($prefix = FALSE) {
409 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'email', $prefix, []);
414 * Returns the list of indices
416 * @param bool $localize
420 public static function indices($localize = TRUE) {
422 'index_location_type' => [
423 'name' => 'index_location_type',
425 0 => 'location_type_id',
427 'localizable' => FALSE,
428 'sig' => 'civicrm_email::0::location_type_id',
431 'name' => 'UI_email',
435 'localizable' => FALSE,
436 'sig' => 'civicrm_email::0::email',
438 'index_is_primary' => [
439 'name' => 'index_is_primary',
443 'localizable' => FALSE,
444 'sig' => 'civicrm_email::0::is_primary',
446 'index_is_billing' => [
447 'name' => 'index_is_billing',
451 'localizable' => FALSE,
452 'sig' => 'civicrm_email::0::is_billing',
455 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;