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