Merge pull request #13988 from seamuslee001/coder_upgrade_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:198627a1fa129294e4c7be52939883e1)
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 unsigned
35 */
36 public $id;
37
38 /**
39 * FK to Contact ID
40 *
41 * @var int unsigned
42 */
43 public $contact_id;
44
45 /**
46 * Which Location does this email belong to.
47 *
48 * @var int unsigned
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 boolean
63 */
64 public $is_primary;
65
66 /**
67 * Is this the billing?
68 *
69 * @var boolean
70 */
71 public $is_billing;
72
73 /**
74 * Implicit FK to civicrm_option_value where option_group = email_on_hold.
75 *
76 * @var int unsigned
77 */
78 public $on_hold;
79
80 /**
81 * Is this address for bulk mail ?
82 *
83 * @var boolean
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 'table_name' => 'civicrm_email',
153 'entity' => 'Email',
154 'bao' => 'CRM_Core_BAO_Email',
155 'localizable' => 0,
156 ],
157 'contact_id' => [
158 'name' => 'contact_id',
159 'type' => CRM_Utils_Type::T_INT,
160 'title' => ts('Email Contact'),
161 'description' => ts('FK to Contact ID'),
162 'table_name' => 'civicrm_email',
163 'entity' => 'Email',
164 'bao' => 'CRM_Core_BAO_Email',
165 'localizable' => 0,
166 'FKClassName' => 'CRM_Contact_DAO_Contact',
167 ],
168 'location_type_id' => [
169 'name' => 'location_type_id',
170 'type' => CRM_Utils_Type::T_INT,
171 'title' => ts('Email Location Type'),
172 'description' => ts('Which Location does this email belong to.'),
173 'table_name' => 'civicrm_email',
174 'entity' => 'Email',
175 'bao' => 'CRM_Core_BAO_Email',
176 'localizable' => 0,
177 'html' => [
178 'type' => 'Select',
179 ],
180 'pseudoconstant' => [
181 'table' => 'civicrm_location_type',
182 'keyColumn' => 'id',
183 'labelColumn' => 'display_name',
184 ]
185 ],
186 'email' => [
187 'name' => 'email',
188 'type' => CRM_Utils_Type::T_STRING,
189 'title' => ts('Email'),
190 'description' => ts('Email address'),
191 'maxlength' => 254,
192 'size' => 30,
193 'import' => TRUE,
194 'where' => 'civicrm_email.email',
195 'headerPattern' => '/e.?mail/i',
196 '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]$/',
197 'export' => TRUE,
198 'rule' => 'email',
199 'table_name' => 'civicrm_email',
200 'entity' => 'Email',
201 'bao' => 'CRM_Core_BAO_Email',
202 'localizable' => 0,
203 'html' => [
204 'type' => 'Text',
205 ],
206 ],
207 'is_primary' => [
208 'name' => 'is_primary',
209 'type' => CRM_Utils_Type::T_BOOLEAN,
210 'title' => ts('Is Primary email'),
211 'description' => ts('Is this the primary?'),
212 'default' => '0',
213 'table_name' => 'civicrm_email',
214 'entity' => 'Email',
215 'bao' => 'CRM_Core_BAO_Email',
216 'localizable' => 0,
217 ],
218 'is_billing' => [
219 'name' => 'is_billing',
220 'type' => CRM_Utils_Type::T_BOOLEAN,
221 'title' => ts('Is Billing Email?'),
222 'description' => ts('Is this the billing?'),
223 'default' => '0',
224 'table_name' => 'civicrm_email',
225 'entity' => 'Email',
226 'bao' => 'CRM_Core_BAO_Email',
227 'localizable' => 0,
228 ],
229 'on_hold' => [
230 'name' => 'on_hold',
231 'type' => CRM_Utils_Type::T_INT,
232 'title' => ts('On Hold'),
233 'description' => ts('Implicit FK to civicrm_option_value where option_group = email_on_hold.'),
234 'required' => TRUE,
235 'export' => TRUE,
236 'where' => 'civicrm_email.on_hold',
237 'headerPattern' => '',
238 'dataPattern' => '',
239 'default' => '0',
240 'table_name' => 'civicrm_email',
241 'entity' => 'Email',
242 'bao' => 'CRM_Core_BAO_Email',
243 'localizable' => 0,
244 'html' => [
245 'type' => 'Select',
246 ],
247 'pseudoconstant' => [
248 'callback' => 'CRM_Core_PseudoConstant::emailOnHoldOptions',
249 ]
250 ],
251 'is_bulkmail' => [
252 'name' => 'is_bulkmail',
253 'type' => CRM_Utils_Type::T_BOOLEAN,
254 'title' => ts('Use for Bulk Mail'),
255 'description' => ts('Is this address for bulk mail ?'),
256 'required' => TRUE,
257 'export' => TRUE,
258 'where' => 'civicrm_email.is_bulkmail',
259 'headerPattern' => '',
260 'dataPattern' => '',
261 'default' => '0',
262 'table_name' => 'civicrm_email',
263 'entity' => 'Email',
264 'bao' => 'CRM_Core_BAO_Email',
265 'localizable' => 0,
266 ],
267 'hold_date' => [
268 'name' => 'hold_date',
269 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
270 'title' => ts('Hold Date'),
271 'description' => ts('When the address went on bounce hold'),
272 'table_name' => 'civicrm_email',
273 'entity' => 'Email',
274 'bao' => 'CRM_Core_BAO_Email',
275 'localizable' => 0,
276 ],
277 'reset_date' => [
278 'name' => 'reset_date',
279 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
280 'title' => ts('Reset Date'),
281 'description' => ts('When the address bounce status was last reset'),
282 'table_name' => 'civicrm_email',
283 'entity' => 'Email',
284 'bao' => 'CRM_Core_BAO_Email',
285 'localizable' => 0,
286 ],
287 'signature_text' => [
288 'name' => 'signature_text',
289 'type' => CRM_Utils_Type::T_TEXT,
290 'title' => ts('Signature Text'),
291 'description' => ts('Text formatted signature for the email.'),
292 'import' => TRUE,
293 'where' => 'civicrm_email.signature_text',
294 'headerPattern' => '',
295 'dataPattern' => '',
296 'export' => TRUE,
297 'default' => 'NULL',
298 'table_name' => 'civicrm_email',
299 'entity' => 'Email',
300 'bao' => 'CRM_Core_BAO_Email',
301 'localizable' => 0,
302 ],
303 'signature_html' => [
304 'name' => 'signature_html',
305 'type' => CRM_Utils_Type::T_TEXT,
306 'title' => ts('Signature Html'),
307 'description' => ts('HTML formatted signature for the email.'),
308 'import' => TRUE,
309 'where' => 'civicrm_email.signature_html',
310 'headerPattern' => '',
311 'dataPattern' => '',
312 'export' => TRUE,
313 'default' => 'NULL',
314 'table_name' => 'civicrm_email',
315 'entity' => 'Email',
316 'bao' => 'CRM_Core_BAO_Email',
317 'localizable' => 0,
318 ],
319 ];
320 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
321 }
322 return Civi::$statics[__CLASS__]['fields'];
323 }
324
325 /**
326 * Return a mapping from field-name to the corresponding key (as used in fields()).
327 *
328 * @return array
329 * Array(string $name => string $uniqueName).
330 */
331 public static function &fieldKeys() {
332 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
333 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
334 }
335 return Civi::$statics[__CLASS__]['fieldKeys'];
336 }
337
338 /**
339 * Returns the names of this table
340 *
341 * @return string
342 */
343 public static function getTableName() {
344 return self::$_tableName;
345 }
346
347 /**
348 * Returns if this table needs to be logged
349 *
350 * @return bool
351 */
352 public function getLog() {
353 return self::$_log;
354 }
355
356 /**
357 * Returns the list of fields that can be imported
358 *
359 * @param bool $prefix
360 *
361 * @return array
362 */
363 public static function &import($prefix = FALSE) {
364 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'email', $prefix, []);
365 return $r;
366 }
367
368 /**
369 * Returns the list of fields that can be exported
370 *
371 * @param bool $prefix
372 *
373 * @return array
374 */
375 public static function &export($prefix = FALSE) {
376 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'email', $prefix, []);
377 return $r;
378 }
379
380 /**
381 * Returns the list of indices
382 *
383 * @param bool $localize
384 *
385 * @return array
386 */
387 public static function indices($localize = TRUE) {
388 $indices = [
389 'index_location_type' => [
390 'name' => 'index_location_type',
391 'field' => [
392 0 => 'location_type_id',
393 ],
394 'localizable' => FALSE,
395 'sig' => 'civicrm_email::0::location_type_id',
396 ],
397 'UI_email' => [
398 'name' => 'UI_email',
399 'field' => [
400 0 => 'email',
401 ],
402 'localizable' => FALSE,
403 'sig' => 'civicrm_email::0::email',
404 ],
405 'index_is_primary' => [
406 'name' => 'index_is_primary',
407 'field' => [
408 0 => 'is_primary',
409 ],
410 'localizable' => FALSE,
411 'sig' => 'civicrm_email::0::is_primary',
412 ],
413 'index_is_billing' => [
414 'name' => 'index_is_billing',
415 'field' => [
416 0 => 'is_billing',
417 ],
418 'localizable' => FALSE,
419 'sig' => 'civicrm_email::0::is_billing',
420 ],
421 ];
422 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
423 }
424
425 }