Commit | Line | Data |
---|---|---|
e501603b | 1 | <?php |
c3fc2621 | 2 | |
e501603b TO |
3 | /** |
4 | * @package CRM | |
8c9251b3 | 5 | * @copyright CiviCRM LLC (c) 2004-2018 |
e501603b TO |
6 | * |
7 | * Generated from xml/schema/CRM/Core/Email.xml | |
8 | * DO NOT EDIT. Generated by CRM_Core_CodeGen | |
e7a6b91a | 9 | * (GenCodeChecksum:08f53d44527d7d174b4aa1bd545b028c) |
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 | */ | |
22 | 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 | */ |
c3fc2621 CW |
29 | static $_log = TRUE; |
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 TO |
73 | /** |
74 | * Is this address on bounce hold? | |
75 | * | |
76 | * @var boolean | |
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 TO |
130 | if (!isset(Civi::$statics[__CLASS__]['links'])) { |
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'), |
e501603b | 150 | 'description' => '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'), |
e501603b | 161 | 'description' => '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'), |
e501603b | 172 | 'description' => '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'), |
e501603b TO |
190 | 'description' => 'Email address', |
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'), |
e501603b | 211 | 'description' => 'Is this the primary?', |
522a26c9 | 212 | 'table_name' => 'civicrm_email', |
213 | 'entity' => 'Email', | |
214 | 'bao' => 'CRM_Core_BAO_Email', | |
6a7e5e5d | 215 | 'localizable' => 0, |
c3fc2621 CW |
216 | ], |
217 | 'is_billing' => [ | |
e501603b TO |
218 | 'name' => 'is_billing', |
219 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
c3fc2621 | 220 | 'title' => ts('Is Billing Email?'), |
e501603b | 221 | 'description' => 'Is this the billing?', |
522a26c9 | 222 | 'table_name' => 'civicrm_email', |
223 | 'entity' => 'Email', | |
224 | 'bao' => 'CRM_Core_BAO_Email', | |
6a7e5e5d | 225 | 'localizable' => 0, |
c3fc2621 CW |
226 | ], |
227 | 'on_hold' => [ | |
e501603b TO |
228 | 'name' => 'on_hold', |
229 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
c3fc2621 | 230 | 'title' => ts('On Hold'), |
e501603b | 231 | 'description' => 'Is this address on bounce hold?', |
c3fc2621 CW |
232 | 'required' => TRUE, |
233 | 'export' => TRUE, | |
e501603b TO |
234 | 'where' => 'civicrm_email.on_hold', |
235 | 'headerPattern' => '', | |
236 | 'dataPattern' => '', | |
522a26c9 | 237 | 'table_name' => 'civicrm_email', |
238 | 'entity' => 'Email', | |
239 | 'bao' => 'CRM_Core_BAO_Email', | |
6a7e5e5d | 240 | 'localizable' => 0, |
c3fc2621 | 241 | 'html' => [ |
e501603b | 242 | 'type' => 'CheckBox', |
c3fc2621 CW |
243 | ], |
244 | ], | |
245 | 'is_bulkmail' => [ | |
e501603b TO |
246 | 'name' => 'is_bulkmail', |
247 | 'type' => CRM_Utils_Type::T_BOOLEAN, | |
c3fc2621 | 248 | 'title' => ts('Use for Bulk Mail'), |
e501603b | 249 | 'description' => 'Is this address for bulk mail ?', |
c3fc2621 CW |
250 | 'required' => TRUE, |
251 | 'export' => TRUE, | |
e501603b TO |
252 | 'where' => 'civicrm_email.is_bulkmail', |
253 | 'headerPattern' => '', | |
254 | 'dataPattern' => '', | |
522a26c9 | 255 | 'table_name' => 'civicrm_email', |
256 | 'entity' => 'Email', | |
257 | 'bao' => 'CRM_Core_BAO_Email', | |
6a7e5e5d | 258 | 'localizable' => 0, |
c3fc2621 CW |
259 | ], |
260 | 'hold_date' => [ | |
e501603b TO |
261 | 'name' => 'hold_date', |
262 | 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME, | |
c3fc2621 | 263 | 'title' => ts('Hold Date'), |
e501603b | 264 | 'description' => 'When the address went on bounce hold', |
522a26c9 | 265 | 'table_name' => 'civicrm_email', |
266 | 'entity' => 'Email', | |
267 | 'bao' => 'CRM_Core_BAO_Email', | |
6a7e5e5d | 268 | 'localizable' => 0, |
c3fc2621 CW |
269 | ], |
270 | 'reset_date' => [ | |
e501603b TO |
271 | 'name' => 'reset_date', |
272 | 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME, | |
c3fc2621 | 273 | 'title' => ts('Reset Date'), |
e501603b | 274 | 'description' => 'When the address bounce status was last reset', |
522a26c9 | 275 | 'table_name' => 'civicrm_email', |
276 | 'entity' => 'Email', | |
277 | 'bao' => 'CRM_Core_BAO_Email', | |
6a7e5e5d | 278 | 'localizable' => 0, |
c3fc2621 CW |
279 | ], |
280 | 'signature_text' => [ | |
e501603b TO |
281 | 'name' => 'signature_text', |
282 | 'type' => CRM_Utils_Type::T_TEXT, | |
c3fc2621 | 283 | 'title' => ts('Signature Text'), |
e501603b | 284 | 'description' => 'Text formatted signature for the email.', |
c3fc2621 | 285 | 'import' => TRUE, |
e501603b TO |
286 | 'where' => 'civicrm_email.signature_text', |
287 | 'headerPattern' => '', | |
288 | 'dataPattern' => '', | |
c3fc2621 | 289 | 'export' => TRUE, |
e501603b | 290 | 'default' => 'NULL', |
522a26c9 | 291 | 'table_name' => 'civicrm_email', |
292 | 'entity' => 'Email', | |
293 | 'bao' => 'CRM_Core_BAO_Email', | |
6a7e5e5d | 294 | 'localizable' => 0, |
c3fc2621 CW |
295 | ], |
296 | 'signature_html' => [ | |
e501603b TO |
297 | 'name' => 'signature_html', |
298 | 'type' => CRM_Utils_Type::T_TEXT, | |
c3fc2621 | 299 | 'title' => ts('Signature Html'), |
e501603b | 300 | 'description' => 'HTML formatted signature for the email.', |
c3fc2621 | 301 | 'import' => TRUE, |
e501603b TO |
302 | 'where' => 'civicrm_email.signature_html', |
303 | 'headerPattern' => '', | |
304 | 'dataPattern' => '', | |
c3fc2621 | 305 | 'export' => TRUE, |
e501603b | 306 | 'default' => 'NULL', |
522a26c9 | 307 | 'table_name' => 'civicrm_email', |
308 | 'entity' => 'Email', | |
309 | 'bao' => 'CRM_Core_BAO_Email', | |
6a7e5e5d | 310 | 'localizable' => 0, |
c3fc2621 CW |
311 | ], |
312 | ]; | |
346aaaba | 313 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); |
e501603b | 314 | } |
346aaaba | 315 | return Civi::$statics[__CLASS__]['fields']; |
e501603b | 316 | } |
c3fc2621 | 317 | |
e501603b | 318 | /** |
bd8e0b14 | 319 | * Return a mapping from field-name to the corresponding key (as used in fields()). |
e501603b TO |
320 | * |
321 | * @return array | |
bd8e0b14 | 322 | * Array(string $name => string $uniqueName). |
e501603b | 323 | */ |
c3fc2621 | 324 | public static function &fieldKeys() { |
bd8e0b14 TO |
325 | if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { |
326 | Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); | |
e501603b | 327 | } |
bd8e0b14 | 328 | return Civi::$statics[__CLASS__]['fieldKeys']; |
e501603b | 329 | } |
c3fc2621 | 330 | |
e501603b TO |
331 | /** |
332 | * Returns the names of this table | |
333 | * | |
334 | * @return string | |
335 | */ | |
c3fc2621 | 336 | public static function getTableName() { |
e501603b TO |
337 | return self::$_tableName; |
338 | } | |
c3fc2621 | 339 | |
e501603b TO |
340 | /** |
341 | * Returns if this table needs to be logged | |
342 | * | |
c3fc2621 | 343 | * @return bool |
e501603b | 344 | */ |
c3fc2621 | 345 | public function getLog() { |
e501603b TO |
346 | return self::$_log; |
347 | } | |
c3fc2621 | 348 | |
e501603b TO |
349 | /** |
350 | * Returns the list of fields that can be imported | |
351 | * | |
352 | * @param bool $prefix | |
353 | * | |
354 | * @return array | |
355 | */ | |
c3fc2621 CW |
356 | public static function &import($prefix = FALSE) { |
357 | $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'email', $prefix, []); | |
60808919 | 358 | return $r; |
e501603b | 359 | } |
c3fc2621 | 360 | |
e501603b TO |
361 | /** |
362 | * Returns the list of fields that can be exported | |
363 | * | |
364 | * @param bool $prefix | |
365 | * | |
366 | * @return array | |
367 | */ | |
c3fc2621 CW |
368 | public static function &export($prefix = FALSE) { |
369 | $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'email', $prefix, []); | |
60808919 | 370 | return $r; |
e501603b | 371 | } |
c3fc2621 | 372 | |
e7a6b91a AS |
373 | /** |
374 | * Returns the list of indices | |
c3fc2621 CW |
375 | * |
376 | * @param bool $localize | |
377 | * | |
378 | * @return array | |
e7a6b91a AS |
379 | */ |
380 | public static function indices($localize = TRUE) { | |
c3fc2621 CW |
381 | $indices = [ |
382 | 'index_location_type' => [ | |
e7a6b91a | 383 | 'name' => 'index_location_type', |
c3fc2621 | 384 | 'field' => [ |
e7a6b91a | 385 | 0 => 'location_type_id', |
c3fc2621 CW |
386 | ], |
387 | 'localizable' => FALSE, | |
e7a6b91a | 388 | 'sig' => 'civicrm_email::0::location_type_id', |
c3fc2621 CW |
389 | ], |
390 | 'UI_email' => [ | |
e7a6b91a | 391 | 'name' => 'UI_email', |
c3fc2621 | 392 | 'field' => [ |
e7a6b91a | 393 | 0 => 'email', |
c3fc2621 CW |
394 | ], |
395 | 'localizable' => FALSE, | |
e7a6b91a | 396 | 'sig' => 'civicrm_email::0::email', |
c3fc2621 CW |
397 | ], |
398 | 'index_is_primary' => [ | |
e7a6b91a | 399 | 'name' => 'index_is_primary', |
c3fc2621 | 400 | 'field' => [ |
e7a6b91a | 401 | 0 => 'is_primary', |
c3fc2621 CW |
402 | ], |
403 | 'localizable' => FALSE, | |
e7a6b91a | 404 | 'sig' => 'civicrm_email::0::is_primary', |
c3fc2621 CW |
405 | ], |
406 | 'index_is_billing' => [ | |
e7a6b91a | 407 | 'name' => 'index_is_billing', |
c3fc2621 | 408 | 'field' => [ |
e7a6b91a | 409 | 0 => 'is_billing', |
c3fc2621 CW |
410 | ], |
411 | 'localizable' => FALSE, | |
e7a6b91a | 412 | 'sig' => 'civicrm_email::0::is_billing', |
c3fc2621 CW |
413 | ], |
414 | ]; | |
e7a6b91a AS |
415 | return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; |
416 | } | |
c3fc2621 | 417 | |
e501603b | 418 | } |