Merge pull request #19159 from colemanw/api4DynamicJoinFix
[civicrm-core.git] / CRM / Core / DAO / Email.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Core/Email.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:032cf9c0a45f5d15baaf7a9087741569)
10 */
11
12 /**
13 * Database access object for the Email entity.
14 */
15 class CRM_Core_DAO_Email extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.1';
18
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
24 public static $_tableName = 'civicrm_email';
25
26 /**
27 * Icon associated with this entity.
28 *
29 * @var string
30 */
31 public static $_icon = 'fa-envelope-o';
32
33 /**
34 * Should CiviCRM log any modifications to this table in the civicrm_log table.
35 *
36 * @var bool
37 */
38 public static $_log = TRUE;
39
40 /**
41 * Unique Email ID
42 *
43 * @var int
44 */
45 public $id;
46
47 /**
48 * FK to Contact ID
49 *
50 * @var int
51 */
52 public $contact_id;
53
54 /**
55 * Which Location does this email belong to.
56 *
57 * @var int
58 */
59 public $location_type_id;
60
61 /**
62 * Email address
63 *
64 * @var string
65 */
66 public $email;
67
68 /**
69 * Is this the primary email address
70 *
71 * @var bool
72 */
73 public $is_primary;
74
75 /**
76 * Is this the billing?
77 *
78 * @var bool
79 */
80 public $is_billing;
81
82 /**
83 * Implicit FK to civicrm_option_value where option_group = email_on_hold.
84 *
85 * @var int
86 */
87 public $on_hold;
88
89 /**
90 * Is this address for bulk mail ?
91 *
92 * @var bool
93 */
94 public $is_bulkmail;
95
96 /**
97 * When the address went on bounce hold
98 *
99 * @var datetime
100 */
101 public $hold_date;
102
103 /**
104 * When the address bounce status was last reset
105 *
106 * @var datetime
107 */
108 public $reset_date;
109
110 /**
111 * Text formatted signature for the email.
112 *
113 * @var text
114 */
115 public $signature_text;
116
117 /**
118 * HTML formatted signature for the email.
119 *
120 * @var text
121 */
122 public $signature_html;
123
124 /**
125 * Class constructor.
126 */
127 public function __construct() {
128 $this->__table = 'civicrm_email';
129 parent::__construct();
130 }
131
132 /**
133 * Returns localized title of this entity.
134 *
135 * @param bool $plural
136 * Whether to return the plural version of the title.
137 */
138 public static function getEntityTitle($plural = FALSE) {
139 return $plural ? ts('Emails') : ts('Email');
140 }
141
142 /**
143 * Returns foreign keys and entity references.
144 *
145 * @return array
146 * [CRM_Core_Reference_Interface]
147 */
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']);
153 }
154 return Civi::$statics[__CLASS__]['links'];
155 }
156
157 /**
158 * Returns all the column names of this table
159 *
160 * @return array
161 */
162 public static function &fields() {
163 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
164 Civi::$statics[__CLASS__]['fields'] = [
165 'id' => [
166 'name' => 'id',
167 'type' => CRM_Utils_Type::T_INT,
168 'title' => ts('Email ID'),
169 'description' => ts('Unique Email ID'),
170 'required' => TRUE,
171 'where' => 'civicrm_email.id',
172 'table_name' => 'civicrm_email',
173 'entity' => 'Email',
174 'bao' => 'CRM_Core_BAO_Email',
175 'localizable' => 0,
176 'add' => '1.1',
177 ],
178 'contact_id' => [
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',
185 'entity' => 'Email',
186 'bao' => 'CRM_Core_BAO_Email',
187 'localizable' => 0,
188 'FKClassName' => 'CRM_Contact_DAO_Contact',
189 'add' => '2.0',
190 ],
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',
198 'entity' => 'Email',
199 'bao' => 'CRM_Core_BAO_Email',
200 'localizable' => 0,
201 'html' => [
202 'type' => 'Select',
203 ],
204 'pseudoconstant' => [
205 'table' => 'civicrm_location_type',
206 'keyColumn' => 'id',
207 'labelColumn' => 'display_name',
208 ],
209 'add' => '2.0',
210 ],
211 'email' => [
212 'name' => 'email',
213 'type' => CRM_Utils_Type::T_STRING,
214 'title' => ts('Email'),
215 'description' => ts('Email address'),
216 'maxlength' => 254,
217 'size' => 30,
218 'import' => TRUE,
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]$/',
222 'export' => TRUE,
223 'rule' => 'email',
224 'table_name' => 'civicrm_email',
225 'entity' => 'Email',
226 'bao' => 'CRM_Core_BAO_Email',
227 'localizable' => 0,
228 'html' => [
229 'type' => 'Text',
230 ],
231 'add' => '1.1',
232 ],
233 'is_primary' => [
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',
239 'default' => '0',
240 'table_name' => 'civicrm_email',
241 'entity' => 'Email',
242 'bao' => 'CRM_Core_BAO_Email',
243 'localizable' => 0,
244 'html' => [
245 'type' => 'Radio',
246 ],
247 'add' => '1.1',
248 ],
249 'is_billing' => [
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',
255 'default' => '0',
256 'table_name' => 'civicrm_email',
257 'entity' => 'Email',
258 'bao' => 'CRM_Core_BAO_Email',
259 'localizable' => 0,
260 'add' => '2.0',
261 ],
262 'on_hold' => [
263 'name' => 'on_hold',
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.'),
267 'required' => TRUE,
268 'where' => 'civicrm_email.on_hold',
269 'export' => TRUE,
270 'default' => '0',
271 'table_name' => 'civicrm_email',
272 'entity' => 'Email',
273 'bao' => 'CRM_Core_BAO_Email',
274 'localizable' => 0,
275 'html' => [
276 'type' => 'Select',
277 ],
278 'pseudoconstant' => [
279 'callback' => 'CRM_Core_PseudoConstant::emailOnHoldOptions',
280 ],
281 'add' => '1.1',
282 ],
283 'is_bulkmail' => [
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 ?'),
288 'required' => TRUE,
289 'where' => 'civicrm_email.is_bulkmail',
290 'export' => TRUE,
291 'default' => '0',
292 'table_name' => 'civicrm_email',
293 'entity' => 'Email',
294 'bao' => 'CRM_Core_BAO_Email',
295 'localizable' => 0,
296 'add' => '1.9',
297 ],
298 'hold_date' => [
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',
305 'entity' => 'Email',
306 'bao' => 'CRM_Core_BAO_Email',
307 'localizable' => 0,
308 'add' => '1.1',
309 ],
310 'reset_date' => [
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',
317 'entity' => 'Email',
318 'bao' => 'CRM_Core_BAO_Email',
319 'localizable' => 0,
320 'add' => '1.1',
321 ],
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.'),
327 'import' => TRUE,
328 'where' => 'civicrm_email.signature_text',
329 'export' => TRUE,
330 'default' => 'NULL',
331 'table_name' => 'civicrm_email',
332 'entity' => 'Email',
333 'bao' => 'CRM_Core_BAO_Email',
334 'localizable' => 0,
335 'add' => '3.2',
336 ],
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.'),
342 'import' => TRUE,
343 'where' => 'civicrm_email.signature_html',
344 'export' => TRUE,
345 'default' => 'NULL',
346 'table_name' => 'civicrm_email',
347 'entity' => 'Email',
348 'bao' => 'CRM_Core_BAO_Email',
349 'localizable' => 0,
350 'add' => '3.2',
351 ],
352 ];
353 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
354 }
355 return Civi::$statics[__CLASS__]['fields'];
356 }
357
358 /**
359 * Return a mapping from field-name to the corresponding key (as used in fields()).
360 *
361 * @return array
362 * Array(string $name => string $uniqueName).
363 */
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()));
367 }
368 return Civi::$statics[__CLASS__]['fieldKeys'];
369 }
370
371 /**
372 * Returns the names of this table
373 *
374 * @return string
375 */
376 public static function getTableName() {
377 return self::$_tableName;
378 }
379
380 /**
381 * Returns if this table needs to be logged
382 *
383 * @return bool
384 */
385 public function getLog() {
386 return self::$_log;
387 }
388
389 /**
390 * Returns the list of fields that can be imported
391 *
392 * @param bool $prefix
393 *
394 * @return array
395 */
396 public static function &import($prefix = FALSE) {
397 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'email', $prefix, []);
398 return $r;
399 }
400
401 /**
402 * Returns the list of fields that can be exported
403 *
404 * @param bool $prefix
405 *
406 * @return array
407 */
408 public static function &export($prefix = FALSE) {
409 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'email', $prefix, []);
410 return $r;
411 }
412
413 /**
414 * Returns the list of indices
415 *
416 * @param bool $localize
417 *
418 * @return array
419 */
420 public static function indices($localize = TRUE) {
421 $indices = [
422 'index_location_type' => [
423 'name' => 'index_location_type',
424 'field' => [
425 0 => 'location_type_id',
426 ],
427 'localizable' => FALSE,
428 'sig' => 'civicrm_email::0::location_type_id',
429 ],
430 'UI_email' => [
431 'name' => 'UI_email',
432 'field' => [
433 0 => 'email',
434 ],
435 'localizable' => FALSE,
436 'sig' => 'civicrm_email::0::email',
437 ],
438 'index_is_primary' => [
439 'name' => 'index_is_primary',
440 'field' => [
441 0 => 'is_primary',
442 ],
443 'localizable' => FALSE,
444 'sig' => 'civicrm_email::0::is_primary',
445 ],
446 'index_is_billing' => [
447 'name' => 'index_is_billing',
448 'field' => [
449 0 => 'is_billing',
450 ],
451 'localizable' => FALSE,
452 'sig' => 'civicrm_email::0::is_billing',
453 ],
454 ];
455 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
456 }
457
458 }