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