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