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