Merge pull request #18911 from totten/master-mail-test
[civicrm-core.git] / CRM / Campaign / DAO / Campaign.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Campaign/Campaign.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:1356a7073a6caa15e0da58422c6763b9)
10 */
11
12 /**
13 * Database access object for the Campaign entity.
14 */
15 class CRM_Campaign_DAO_Campaign extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '3.3';
18
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
24 public static $_tableName = 'civicrm_campaign';
25
26 /**
27 * Icon associated with this entity.
28 *
29 * @var string
30 */
31 public static $_icon = 'fa-bullhorn';
32
33 /**
34 * Should CiviCRM log any modifications to this table in the civicrm_log table.
35 *
36 * @var bool
37 */
38 public static $_log = FALSE;
39
40 /**
41 * Paths for accessing this entity in the UI.
42 *
43 * @var string[]
44 */
45 protected static $_paths = [
46 'add' => 'civicrm/campaign/add?reset=1',
47 'update' => 'civicrm/campaign/add?reset=1&action=update&id=[id]',
48 'delete' => 'civicrm/campaign/add?reset=1&action=delete&id=[id]',
49 ];
50
51 /**
52 * Unique Campaign ID.
53 *
54 * @var int
55 */
56 public $id;
57
58 /**
59 * Name of the Campaign.
60 *
61 * @var string
62 */
63 public $name;
64
65 /**
66 * Title of the Campaign.
67 *
68 * @var string
69 */
70 public $title;
71
72 /**
73 * Full description of Campaign.
74 *
75 * @var text
76 */
77 public $description;
78
79 /**
80 * Date and time that Campaign starts.
81 *
82 * @var datetime
83 */
84 public $start_date;
85
86 /**
87 * Date and time that Campaign ends.
88 *
89 * @var datetime
90 */
91 public $end_date;
92
93 /**
94 * Campaign Type ID.Implicit FK to civicrm_option_value where option_group = campaign_type
95 *
96 * @var int
97 */
98 public $campaign_type_id;
99
100 /**
101 * Campaign status ID.Implicit FK to civicrm_option_value where option_group = campaign_status
102 *
103 * @var int
104 */
105 public $status_id;
106
107 /**
108 * Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.
109 *
110 * @var string
111 */
112 public $external_identifier;
113
114 /**
115 * Optional parent id for this Campaign.
116 *
117 * @var int
118 */
119 public $parent_id;
120
121 /**
122 * Is this Campaign enabled or disabled/cancelled?
123 *
124 * @var bool
125 */
126 public $is_active;
127
128 /**
129 * FK to civicrm_contact, who created this Campaign.
130 *
131 * @var int
132 */
133 public $created_id;
134
135 /**
136 * Date and time that Campaign was created.
137 *
138 * @var datetime
139 */
140 public $created_date;
141
142 /**
143 * FK to civicrm_contact, who recently edited this Campaign.
144 *
145 * @var int
146 */
147 public $last_modified_id;
148
149 /**
150 * Date and time that Campaign was edited last time.
151 *
152 * @var datetime
153 */
154 public $last_modified_date;
155
156 /**
157 * General goals for Campaign.
158 *
159 * @var text
160 */
161 public $goal_general;
162
163 /**
164 * The target revenue for this campaign.
165 *
166 * @var float
167 */
168 public $goal_revenue;
169
170 /**
171 * Class constructor.
172 */
173 public function __construct() {
174 $this->__table = 'civicrm_campaign';
175 parent::__construct();
176 }
177
178 /**
179 * Returns localized title of this entity.
180 *
181 * @param bool $plural
182 * Whether to return the plural version of the title.
183 */
184 public static function getEntityTitle($plural = FALSE) {
185 return $plural ? ts('Campaigns') : ts('Campaign');
186 }
187
188 /**
189 * Returns foreign keys and entity references.
190 *
191 * @return array
192 * [CRM_Core_Reference_Interface]
193 */
194 public static function getReferenceColumns() {
195 if (!isset(Civi::$statics[__CLASS__]['links'])) {
196 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
197 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'parent_id', 'civicrm_campaign', 'id');
198 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id');
199 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'last_modified_id', 'civicrm_contact', 'id');
200 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
201 }
202 return Civi::$statics[__CLASS__]['links'];
203 }
204
205 /**
206 * Returns all the column names of this table
207 *
208 * @return array
209 */
210 public static function &fields() {
211 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
212 Civi::$statics[__CLASS__]['fields'] = [
213 'id' => [
214 'name' => 'id',
215 'type' => CRM_Utils_Type::T_INT,
216 'title' => ts('Campaign ID'),
217 'description' => ts('Unique Campaign ID.'),
218 'required' => TRUE,
219 'import' => TRUE,
220 'where' => 'civicrm_campaign.id',
221 'export' => TRUE,
222 'table_name' => 'civicrm_campaign',
223 'entity' => 'Campaign',
224 'bao' => 'CRM_Campaign_BAO_Campaign',
225 'localizable' => 0,
226 'add' => '3.3',
227 ],
228 'name' => [
229 'name' => 'name',
230 'type' => CRM_Utils_Type::T_STRING,
231 'title' => ts('Campaign Name'),
232 'description' => ts('Name of the Campaign.'),
233 'required' => TRUE,
234 'maxlength' => 255,
235 'size' => CRM_Utils_Type::HUGE,
236 'import' => TRUE,
237 'where' => 'civicrm_campaign.name',
238 'export' => TRUE,
239 'table_name' => 'civicrm_campaign',
240 'entity' => 'Campaign',
241 'bao' => 'CRM_Campaign_BAO_Campaign',
242 'localizable' => 0,
243 'html' => [
244 'type' => 'Text',
245 ],
246 'add' => '3.3',
247 ],
248 'title' => [
249 'name' => 'title',
250 'type' => CRM_Utils_Type::T_STRING,
251 'title' => ts('Campaign Title'),
252 'description' => ts('Title of the Campaign.'),
253 'maxlength' => 255,
254 'size' => CRM_Utils_Type::HUGE,
255 'import' => TRUE,
256 'where' => 'civicrm_campaign.title',
257 'export' => TRUE,
258 'table_name' => 'civicrm_campaign',
259 'entity' => 'Campaign',
260 'bao' => 'CRM_Campaign_BAO_Campaign',
261 'localizable' => 0,
262 'html' => [
263 'type' => 'Text',
264 ],
265 'add' => '3.3',
266 ],
267 'description' => [
268 'name' => 'description',
269 'type' => CRM_Utils_Type::T_TEXT,
270 'title' => ts('Campaign Description'),
271 'description' => ts('Full description of Campaign.'),
272 'rows' => 8,
273 'cols' => 60,
274 'where' => 'civicrm_campaign.description',
275 'table_name' => 'civicrm_campaign',
276 'entity' => 'Campaign',
277 'bao' => 'CRM_Campaign_BAO_Campaign',
278 'localizable' => 0,
279 'html' => [
280 'type' => 'TextArea',
281 ],
282 'add' => '3.3',
283 ],
284 'start_date' => [
285 'name' => 'start_date',
286 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
287 'title' => ts('Campaign Start Date'),
288 'description' => ts('Date and time that Campaign starts.'),
289 'import' => TRUE,
290 'where' => 'civicrm_campaign.start_date',
291 'headerPattern' => '/^start|(s(tart\s)?date)$/i',
292 'export' => TRUE,
293 'table_name' => 'civicrm_campaign',
294 'entity' => 'Campaign',
295 'bao' => 'CRM_Campaign_BAO_Campaign',
296 'localizable' => 0,
297 'html' => [
298 'type' => 'Select Date',
299 'formatType' => 'activityDateTime',
300 ],
301 'add' => '3.3',
302 ],
303 'end_date' => [
304 'name' => 'end_date',
305 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
306 'title' => ts('Campaign End Date'),
307 'description' => ts('Date and time that Campaign ends.'),
308 'import' => TRUE,
309 'where' => 'civicrm_campaign.end_date',
310 'headerPattern' => '/^end|(e(nd\s)?date)$/i',
311 'export' => TRUE,
312 'table_name' => 'civicrm_campaign',
313 'entity' => 'Campaign',
314 'bao' => 'CRM_Campaign_BAO_Campaign',
315 'localizable' => 0,
316 'html' => [
317 'type' => 'Select Date',
318 'formatType' => 'activityDateTime',
319 ],
320 'add' => '3.3',
321 ],
322 'campaign_type_id' => [
323 'name' => 'campaign_type_id',
324 'type' => CRM_Utils_Type::T_INT,
325 'title' => ts('Campaign Type'),
326 'description' => ts('Campaign Type ID.Implicit FK to civicrm_option_value where option_group = campaign_type'),
327 'import' => TRUE,
328 'where' => 'civicrm_campaign.campaign_type_id',
329 'export' => TRUE,
330 'default' => 'NULL',
331 'table_name' => 'civicrm_campaign',
332 'entity' => 'Campaign',
333 'bao' => 'CRM_Campaign_BAO_Campaign',
334 'localizable' => 0,
335 'html' => [
336 'type' => 'Select',
337 ],
338 'pseudoconstant' => [
339 'optionGroupName' => 'campaign_type',
340 'optionEditPath' => 'civicrm/admin/options/campaign_type',
341 ],
342 'add' => '3.3',
343 ],
344 'status_id' => [
345 'name' => 'status_id',
346 'type' => CRM_Utils_Type::T_INT,
347 'title' => ts('Campaign Status'),
348 'description' => ts('Campaign status ID.Implicit FK to civicrm_option_value where option_group = campaign_status'),
349 'import' => TRUE,
350 'where' => 'civicrm_campaign.status_id',
351 'export' => TRUE,
352 'default' => 'NULL',
353 'table_name' => 'civicrm_campaign',
354 'entity' => 'Campaign',
355 'bao' => 'CRM_Campaign_BAO_Campaign',
356 'localizable' => 0,
357 'html' => [
358 'type' => 'Select',
359 ],
360 'pseudoconstant' => [
361 'optionGroupName' => 'campaign_status',
362 'optionEditPath' => 'civicrm/admin/options/campaign_status',
363 ],
364 'add' => '3.3',
365 ],
366 'external_identifier' => [
367 'name' => 'external_identifier',
368 'type' => CRM_Utils_Type::T_STRING,
369 'title' => ts('Campaign External ID'),
370 'description' => ts('Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.'),
371 'maxlength' => 32,
372 'size' => CRM_Utils_Type::MEDIUM,
373 'import' => TRUE,
374 'where' => 'civicrm_campaign.external_identifier',
375 'headerPattern' => '/external\s?id/i',
376 'dataPattern' => '/^\d{11,}$/',
377 'export' => TRUE,
378 'table_name' => 'civicrm_campaign',
379 'entity' => 'Campaign',
380 'bao' => 'CRM_Campaign_BAO_Campaign',
381 'localizable' => 0,
382 'html' => [
383 'type' => 'Text',
384 ],
385 'add' => '3.3',
386 ],
387 'parent_id' => [
388 'name' => 'parent_id',
389 'type' => CRM_Utils_Type::T_INT,
390 'title' => ts('Parent Campaign'),
391 'description' => ts('Optional parent id for this Campaign.'),
392 'import' => TRUE,
393 'where' => 'civicrm_campaign.parent_id',
394 'export' => TRUE,
395 'default' => 'NULL',
396 'table_name' => 'civicrm_campaign',
397 'entity' => 'Campaign',
398 'bao' => 'CRM_Campaign_BAO_Campaign',
399 'localizable' => 0,
400 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
401 'html' => [
402 'type' => 'EntityRef',
403 ],
404 'add' => '3.3',
405 ],
406 'is_active' => [
407 'name' => 'is_active',
408 'type' => CRM_Utils_Type::T_BOOLEAN,
409 'title' => ts('Is Campaign Active?'),
410 'description' => ts('Is this Campaign enabled or disabled/cancelled?'),
411 'where' => 'civicrm_campaign.is_active',
412 'default' => '1',
413 'table_name' => 'civicrm_campaign',
414 'entity' => 'Campaign',
415 'bao' => 'CRM_Campaign_BAO_Campaign',
416 'localizable' => 0,
417 'html' => [
418 'type' => 'CheckBox',
419 ],
420 'add' => '3.3',
421 ],
422 'created_id' => [
423 'name' => 'created_id',
424 'type' => CRM_Utils_Type::T_INT,
425 'title' => ts('Campaign Created By'),
426 'description' => ts('FK to civicrm_contact, who created this Campaign.'),
427 'where' => 'civicrm_campaign.created_id',
428 'table_name' => 'civicrm_campaign',
429 'entity' => 'Campaign',
430 'bao' => 'CRM_Campaign_BAO_Campaign',
431 'localizable' => 0,
432 'FKClassName' => 'CRM_Contact_DAO_Contact',
433 'add' => '3.3',
434 ],
435 'created_date' => [
436 'name' => 'created_date',
437 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
438 'title' => ts('Campaign Created Date'),
439 'description' => ts('Date and time that Campaign was created.'),
440 'where' => 'civicrm_campaign.created_date',
441 'table_name' => 'civicrm_campaign',
442 'entity' => 'Campaign',
443 'bao' => 'CRM_Campaign_BAO_Campaign',
444 'localizable' => 0,
445 'html' => [
446 'type' => 'Select Date',
447 'formatType' => 'activityDateTime',
448 ],
449 'add' => '3.3',
450 ],
451 'last_modified_id' => [
452 'name' => 'last_modified_id',
453 'type' => CRM_Utils_Type::T_INT,
454 'title' => ts('Campaign Modified By'),
455 'description' => ts('FK to civicrm_contact, who recently edited this Campaign.'),
456 'where' => 'civicrm_campaign.last_modified_id',
457 'table_name' => 'civicrm_campaign',
458 'entity' => 'Campaign',
459 'bao' => 'CRM_Campaign_BAO_Campaign',
460 'localizable' => 0,
461 'FKClassName' => 'CRM_Contact_DAO_Contact',
462 'add' => '3.3',
463 ],
464 'last_modified_date' => [
465 'name' => 'last_modified_date',
466 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
467 'title' => ts('Campaign Modified Date'),
468 'description' => ts('Date and time that Campaign was edited last time.'),
469 'where' => 'civicrm_campaign.last_modified_date',
470 'table_name' => 'civicrm_campaign',
471 'entity' => 'Campaign',
472 'bao' => 'CRM_Campaign_BAO_Campaign',
473 'localizable' => 0,
474 'add' => '3.3',
475 ],
476 'goal_general' => [
477 'name' => 'goal_general',
478 'type' => CRM_Utils_Type::T_TEXT,
479 'title' => ts('Campaign Goals'),
480 'description' => ts('General goals for Campaign.'),
481 'where' => 'civicrm_campaign.goal_general',
482 'table_name' => 'civicrm_campaign',
483 'entity' => 'Campaign',
484 'bao' => 'CRM_Campaign_BAO_Campaign',
485 'localizable' => 0,
486 'html' => [
487 'type' => 'RichTextEditor',
488 ],
489 'add' => '3.4',
490 ],
491 'goal_revenue' => [
492 'name' => 'goal_revenue',
493 'type' => CRM_Utils_Type::T_MONEY,
494 'title' => ts('Goal Revenue'),
495 'description' => ts('The target revenue for this campaign.'),
496 'precision' => [
497 20,
498 2,
499 ],
500 'where' => 'civicrm_campaign.goal_revenue',
501 'table_name' => 'civicrm_campaign',
502 'entity' => 'Campaign',
503 'bao' => 'CRM_Campaign_BAO_Campaign',
504 'localizable' => 0,
505 'html' => [
506 'type' => 'Text',
507 ],
508 'add' => '3.4',
509 ],
510 ];
511 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
512 }
513 return Civi::$statics[__CLASS__]['fields'];
514 }
515
516 /**
517 * Return a mapping from field-name to the corresponding key (as used in fields()).
518 *
519 * @return array
520 * Array(string $name => string $uniqueName).
521 */
522 public static function &fieldKeys() {
523 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
524 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
525 }
526 return Civi::$statics[__CLASS__]['fieldKeys'];
527 }
528
529 /**
530 * Returns the names of this table
531 *
532 * @return string
533 */
534 public static function getTableName() {
535 return self::$_tableName;
536 }
537
538 /**
539 * Returns if this table needs to be logged
540 *
541 * @return bool
542 */
543 public function getLog() {
544 return self::$_log;
545 }
546
547 /**
548 * Returns the list of fields that can be imported
549 *
550 * @param bool $prefix
551 *
552 * @return array
553 */
554 public static function &import($prefix = FALSE) {
555 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'campaign', $prefix, []);
556 return $r;
557 }
558
559 /**
560 * Returns the list of fields that can be exported
561 *
562 * @param bool $prefix
563 *
564 * @return array
565 */
566 public static function &export($prefix = FALSE) {
567 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'campaign', $prefix, []);
568 return $r;
569 }
570
571 /**
572 * Returns the list of indices
573 *
574 * @param bool $localize
575 *
576 * @return array
577 */
578 public static function indices($localize = TRUE) {
579 $indices = [
580 'UI_campaign_type_id' => [
581 'name' => 'UI_campaign_type_id',
582 'field' => [
583 0 => 'campaign_type_id',
584 ],
585 'localizable' => FALSE,
586 'sig' => 'civicrm_campaign::0::campaign_type_id',
587 ],
588 'UI_campaign_status_id' => [
589 'name' => 'UI_campaign_status_id',
590 'field' => [
591 0 => 'status_id',
592 ],
593 'localizable' => FALSE,
594 'sig' => 'civicrm_campaign::0::status_id',
595 ],
596 'UI_external_identifier' => [
597 'name' => 'UI_external_identifier',
598 'field' => [
599 0 => 'external_identifier',
600 ],
601 'localizable' => FALSE,
602 'unique' => TRUE,
603 'sig' => 'civicrm_campaign::1::external_identifier',
604 ],
605 ];
606 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
607 }
608
609 }