Regenerate DAO files
[civicrm-core.git] / CRM / Core / DAO / Email.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC (c) 2004-2019
6 *
7 * Generated from xml/schema/CRM/Core/Email.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:6da9864657d2b5e46956386ab414d8d6)
10 */
11
12 /**
13 * Database access object for the Email entity.
14 */
15 class CRM_Core_DAO_Email extends CRM_Core_DAO {
16
17 /**
18 * Static instance to hold the table name.
19 *
20 * @var string
21 */
22 public static $_tableName = 'civicrm_email';
23
24 /**
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
26 *
27 * @var bool
28 */
29 public static $_log = TRUE;
30
31 /**
32 * Unique Email ID
33 *
34 * @var int
35 */
36 public $id;
37
38 /**
39 * FK to Contact ID
40 *
41 * @var int
42 */
43 public $contact_id;
44
45 /**
46 * Which Location does this email belong to.
47 *
48 * @var int
49 */
50 public $location_type_id;
51
52 /**
53 * Email address
54 *
55 * @var string
56 */
57 public $email;
58
59 /**
60 * Is this the primary?
61 *
62 * @var bool
63 */
64 public $is_primary;
65
66 /**
67 * Is this the billing?
68 *
69 * @var bool
70 */
71 public $is_billing;
72
73 /**
74 * Implicit FK to civicrm_option_value where option_group = email_on_hold.
75 *
76 * @var int
77 */
78 public $on_hold;
79
80 /**
81 * Is this address for bulk mail ?
82 *
83 * @var bool
84 */
85 public $is_bulkmail;
86
87 /**
88 * When the address went on bounce hold
89 *
90 * @var datetime
91 */
92 public $hold_date;
93
94 /**
95 * When the address bounce status was last reset
96 *
97 * @var datetime
98 */
99 public $reset_date;
100
101 /**
102 * Text formatted signature for the email.
103 *
104 * @var text
105 */
106 public $signature_text;
107
108 /**
109 * HTML formatted signature for the email.
110 *
111 * @var text
112 */
113 public $signature_html;
114
115 /**
116 * Class constructor.
117 */
118 public function __construct() {
119 $this->__table = 'civicrm_email';
120 parent::__construct();
121 }
122
123 /**
124 * Returns foreign keys and entity references.
125 *
126 * @return array
127 * [CRM_Core_Reference_Interface]
128 */
129 public static function getReferenceColumns() {
130 if (!isset(Civi::$statics[__CLASS__]['links'])) {
131 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
132 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
133 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
134 }
135 return Civi::$statics[__CLASS__]['links'];
136 }
137
138 /**
139 * Returns all the column names of this table
140 *
141 * @return array
142 */
143 public static function &fields() {
144 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
145 Civi::$statics[__CLASS__]['fields'] = [
146 'id' => [
147 'name' => 'id',
148 'type' => CRM_Utils_Type::T_INT,
149 'title' => ts('Email ID'),
150 'description' => ts('Unique Email ID'),
151 'required' => TRUE,
152 'where' => 'civicrm_email.id',
153 'table_name' => 'civicrm_email',
154 'entity' => 'Email',
155 'bao' => 'CRM_Core_BAO_Email',
156 'localizable' => 0,
157 ],
158 'contact_id' => [
159 'name' => 'contact_id',
160 'type' => CRM_Utils_Type::T_INT,
161 'title' => ts('Email Contact'),
162 'description' => ts('FK to Contact ID'),
163 'where' => 'civicrm_email.contact_id',
164 'table_name' => 'civicrm_email',
165 'entity' => 'Email',
166 'bao' => 'CRM_Core_BAO_Email',
167 'localizable' => 0,
168 'FKClassName' => 'CRM_Contact_DAO_Contact',
169 ],
170 'location_type_id' => [
171 'name' => 'location_type_id',
172 'type' => CRM_Utils_Type::T_INT,
173 'title' => ts('Email Location Type'),
174 'description' => ts('Which Location does this email belong to.'),
175 'where' => 'civicrm_email.location_type_id',
176 'table_name' => 'civicrm_email',
177 'entity' => 'Email',
178 'bao' => 'CRM_Core_BAO_Email',
179 'localizable' => 0,
180 'html' => [
181 'type' => 'Select',
182 ],
183 'pseudoconstant' => [
184 'table' => 'civicrm_location_type',
185 'keyColumn' => 'id',
186 'labelColumn' => 'display_name',
187 ],
188 ],
189 'email' => [
190 'name' => 'email',
191 'type' => CRM_Utils_Type::T_STRING,
192 'title' => ts('Email'),
193 'description' => ts('Email address'),
194 'maxlength' => 254,
195 'size' => 30,
196 'import' => TRUE,
197 'where' => 'civicrm_email.email',
198 'headerPattern' => '/e.?mail/i',
199 '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]$/',
200 'export' => TRUE,
201 'rule' => 'email',
202 'table_name' => 'civicrm_email',
203 'entity' => 'Email',
204 'bao' => 'CRM_Core_BAO_Email',
205 'localizable' => 0,
206 'html' => [
207 'type' => 'Text',
208 ],
209 ],
210 'is_primary' => [
211 'name' => 'is_primary',
212 'type' => CRM_Utils_Type::T_BOOLEAN,
213 'title' => ts('Is Primary email'),
214 'description' => ts('Is this the primary?'),
215 'where' => 'civicrm_email.is_primary',
216 'default' => '0',
217 'table_name' => 'civicrm_email',
218 'entity' => 'Email',
219 'bao' => 'CRM_Core_BAO_Email',
220 'localizable' => 0,
221 ],
222 'is_billing' => [
223 'name' => 'is_billing',
224 'type' => CRM_Utils_Type::T_BOOLEAN,
225 'title' => ts('Is Billing Email?'),
226 'description' => ts('Is this the billing?'),
227 'where' => 'civicrm_email.is_billing',
228 'default' => '0',
229 'table_name' => 'civicrm_email',
230 'entity' => 'Email',
231 'bao' => 'CRM_Core_BAO_Email',
232 'localizable' => 0,
233 ],
234 'on_hold' => [
235 'name' => 'on_hold',
236 'type' => CRM_Utils_Type::T_INT,
237 'title' => ts('On Hold'),
238 'description' => ts('Implicit FK to civicrm_option_value where option_group = email_on_hold.'),
239 'required' => TRUE,
240 'where' => 'civicrm_email.on_hold',
241 'export' => TRUE,
242 'default' => '0',
243 'table_name' => 'civicrm_email',
244 'entity' => 'Email',
245 'bao' => 'CRM_Core_BAO_Email',
246 'localizable' => 0,
247 'html' => [
248 'type' => 'Select',
249 ],
250 'pseudoconstant' => [
251 'callback' => 'CRM_Core_PseudoConstant::emailOnHoldOptions',
252 ],
253 ],
254 'is_bulkmail' => [
255 'name' => 'is_bulkmail',
256 'type' => CRM_Utils_Type::T_BOOLEAN,
257 'title' => ts('Use for Bulk Mail'),
258 'description' => ts('Is this address for bulk mail ?'),
259 'required' => TRUE,
260 'where' => 'civicrm_email.is_bulkmail',
261 'export' => TRUE,
262 'default' => '0',
263 'table_name' => 'civicrm_email',
264 'entity' => 'Email',
265 'bao' => 'CRM_Core_BAO_Email',
266 'localizable' => 0,
267 ],
268 'hold_date' => [
269 'name' => 'hold_date',
270 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
271 'title' => ts('Hold Date'),
272 'description' => ts('When the address went on bounce hold'),
273 'where' => 'civicrm_email.hold_date',
274 'table_name' => 'civicrm_email',
275 'entity' => 'Email',
276 'bao' => 'CRM_Core_BAO_Email',
277 'localizable' => 0,
278 ],
279 'reset_date' => [
280 'name' => 'reset_date',
281 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
282 'title' => ts('Reset Date'),
283 'description' => ts('When the address bounce status was last reset'),
284 'where' => 'civicrm_email.reset_date',
285 'table_name' => 'civicrm_email',
286 'entity' => 'Email',
287 'bao' => 'CRM_Core_BAO_Email',
288 'localizable' => 0,
289 ],
290 'signature_text' => [
291 'name' => 'signature_text',
292 'type' => CRM_Utils_Type::T_TEXT,
293 'title' => ts('Signature Text'),
294 'description' => ts('Text formatted signature for the email.'),
295 'import' => TRUE,
296 'where' => 'civicrm_email.signature_text',
297 'export' => TRUE,
298 'default' => 'NULL',
299 'table_name' => 'civicrm_email',
300 'entity' => 'Email',
301 'bao' => 'CRM_Core_BAO_Email',
302 'localizable' => 0,
303 ],
304 'signature_html' => [
305 'name' => 'signature_html',
306 'type' => CRM_Utils_Type::T_TEXT,
307 'title' => ts('Signature Html'),
308 'description' => ts('HTML formatted signature for the email.'),
309 'import' => TRUE,
310 'where' => 'civicrm_email.signature_html',
311 'export' => TRUE,
312 'default' => 'NULL',
313 'table_name' => 'civicrm_email',
314 'entity' => 'Email',
315 'bao' => 'CRM_Core_BAO_Email',
316 'localizable' => 0,
317 ],
318 ];
319 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
320 }
321 return Civi::$statics[__CLASS__]['fields'];
322 }
323
324 /**
325 * Return a mapping from field-name to the corresponding key (as used in fields()).
326 *
327 * @return array
328 * Array(string $name => string $uniqueName).
329 */
330 public static function &fieldKeys() {
331 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
332 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
333 }
334 return Civi::$statics[__CLASS__]['fieldKeys'];
335 }
336
337 /**
338 * Returns the names of this table
339 *
340 * @return string
341 */
342 public static function getTableName() {
343 return self::$_tableName;
344 }
345
346 /**
347 * Returns if this table needs to be logged
348 *
349 * @return bool
350 */
351 public function getLog() {
352 return self::$_log;
353 }
354
355 /**
356 * Returns the list of fields that can be imported
357 *
358 * @param bool $prefix
359 *
360 * @return array
361 */
362 public static function &import($prefix = FALSE) {
363 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'email', $prefix, []);
364 return $r;
365 }
366
367 /**
368 * Returns the list of fields that can be exported
369 *
370 * @param bool $prefix
371 *
372 * @return array
373 */
374 public static function &export($prefix = FALSE) {
375 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'email', $prefix, []);
376 return $r;
377 }
378
379 /**
380 * Returns the list of indices
381 *
382 * @param bool $localize
383 *
384 * @return array
385 */
386 public static function indices($localize = TRUE) {
387 $indices = [
388 'index_location_type' => [
389 'name' => 'index_location_type',
390 'field' => [
391 0 => 'location_type_id',
392 ],
393 'localizable' => FALSE,
394 'sig' => 'civicrm_email::0::location_type_id',
395 ],
396 'UI_email' => [
397 'name' => 'UI_email',
398 'field' => [
399 0 => 'email',
400 ],
401 'localizable' => FALSE,
402 'sig' => 'civicrm_email::0::email',
403 ],
404 'index_is_primary' => [
405 'name' => 'index_is_primary',
406 'field' => [
407 0 => 'is_primary',
408 ],
409 'localizable' => FALSE,
410 'sig' => 'civicrm_email::0::is_primary',
411 ],
412 'index_is_billing' => [
413 'name' => 'index_is_billing',
414 'field' => [
415 0 => 'is_billing',
416 ],
417 'localizable' => FALSE,
418 'sig' => 'civicrm_email::0::is_billing',
419 ],
420 ];
421 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
422 }
423
424 }