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