5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Campaign/Campaign.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:9d4da1f7966af86e8426aa449826f41c)
13 * Database access object for the Campaign entity.
15 class CRM_Campaign_DAO_Campaign
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '3.3';
18 const COMPONENT
= 'CiviCampaign';
21 * Static instance to hold the table name.
25 public static $_tableName = 'civicrm_campaign';
28 * Icon associated with this entity.
32 public static $_icon = 'fa-bullhorn';
35 * Field to show when displaying a record.
39 public static $_labelField = 'title';
42 * Should CiviCRM log any modifications to this table in the civicrm_log table.
46 public static $_log = FALSE;
49 * Paths for accessing this entity in the UI.
53 protected static $_paths = [
54 'add' => 'civicrm/campaign/add?reset=1',
55 'update' => 'civicrm/campaign/add?reset=1&action=update&id=[id]',
56 'delete' => 'civicrm/campaign/add?reset=1&action=delete&id=[id]',
67 * Name of the Campaign.
74 * Title of the Campaign.
81 * Full description of Campaign.
88 * Date and time that Campaign starts.
95 * Date and time that Campaign ends.
102 * Campaign Type ID.Implicit FK to civicrm_option_value where option_group = campaign_type
106 public $campaign_type_id;
109 * Campaign status ID.Implicit FK to civicrm_option_value where option_group = campaign_status
116 * Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.
120 public $external_identifier;
123 * Optional parent id for this Campaign.
130 * Is this Campaign enabled or disabled/cancelled?
137 * FK to civicrm_contact, who created this Campaign.
144 * Date and time that Campaign was created.
148 public $created_date;
151 * FK to civicrm_contact, who recently edited this Campaign.
155 public $last_modified_id;
158 * Date and time that Campaign was edited last time.
162 public $last_modified_date;
165 * General goals for Campaign.
169 public $goal_general;
172 * The target revenue for this campaign.
176 public $goal_revenue;
181 public function __construct() {
182 $this->__table
= 'civicrm_campaign';
183 parent
::__construct();
187 * Returns localized title of this entity.
189 * @param bool $plural
190 * Whether to return the plural version of the title.
192 public static function getEntityTitle($plural = FALSE) {
193 return $plural ?
ts('Campaigns') : ts('Campaign');
197 * Returns user-friendly description of this entity.
201 public static function getEntityDescription() {
202 return ts('Campaigns link activities, contributions, mailings, etc. that share a programmatic goal.');
206 * Returns foreign keys and entity references.
209 * [CRM_Core_Reference_Interface]
211 public static function getReferenceColumns() {
212 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
213 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
214 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'parent_id', 'civicrm_campaign', 'id');
215 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'created_id', 'civicrm_contact', 'id');
216 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'last_modified_id', 'civicrm_contact', 'id');
217 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
219 return Civi
::$statics[__CLASS__
]['links'];
223 * Returns all the column names of this table
227 public static function &fields() {
228 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
229 Civi
::$statics[__CLASS__
]['fields'] = [
232 'type' => CRM_Utils_Type
::T_INT
,
233 'title' => ts('Campaign ID'),
234 'description' => ts('Unique Campaign ID.'),
237 'where' => 'civicrm_campaign.id',
239 'table_name' => 'civicrm_campaign',
240 'entity' => 'Campaign',
241 'bao' => 'CRM_Campaign_BAO_Campaign',
251 'type' => CRM_Utils_Type
::T_STRING
,
252 'title' => ts('Campaign Name'),
253 'description' => ts('Name of the Campaign.'),
256 'size' => CRM_Utils_Type
::HUGE
,
258 'where' => 'civicrm_campaign.name',
260 'table_name' => 'civicrm_campaign',
261 'entity' => 'Campaign',
262 'bao' => 'CRM_Campaign_BAO_Campaign',
271 'type' => CRM_Utils_Type
::T_STRING
,
272 'title' => ts('Campaign Title'),
273 'description' => ts('Title of the Campaign.'),
275 'size' => CRM_Utils_Type
::HUGE
,
277 'where' => 'civicrm_campaign.title',
279 'table_name' => 'civicrm_campaign',
280 'entity' => 'Campaign',
281 'bao' => 'CRM_Campaign_BAO_Campaign',
289 'name' => 'description',
290 'type' => CRM_Utils_Type
::T_TEXT
,
291 'title' => ts('Campaign Description'),
292 'description' => ts('Full description of Campaign.'),
295 'where' => 'civicrm_campaign.description',
296 'table_name' => 'civicrm_campaign',
297 'entity' => 'Campaign',
298 'bao' => 'CRM_Campaign_BAO_Campaign',
301 'type' => 'TextArea',
306 'name' => 'start_date',
307 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
308 'title' => ts('Campaign Start Date'),
309 'description' => ts('Date and time that Campaign starts.'),
311 'where' => 'civicrm_campaign.start_date',
312 'headerPattern' => '/^start|(s(tart\s)?date)$/i',
314 'table_name' => 'civicrm_campaign',
315 'entity' => 'Campaign',
316 'bao' => 'CRM_Campaign_BAO_Campaign',
319 'type' => 'Select Date',
320 'formatType' => 'activityDateTime',
325 'name' => 'end_date',
326 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
327 'title' => ts('Campaign End Date'),
328 'description' => ts('Date and time that Campaign ends.'),
330 'where' => 'civicrm_campaign.end_date',
331 'headerPattern' => '/^end|(e(nd\s)?date)$/i',
333 'table_name' => 'civicrm_campaign',
334 'entity' => 'Campaign',
335 'bao' => 'CRM_Campaign_BAO_Campaign',
338 'type' => 'Select Date',
339 'formatType' => 'activityDateTime',
343 'campaign_type_id' => [
344 'name' => 'campaign_type_id',
345 'type' => CRM_Utils_Type
::T_INT
,
346 'title' => ts('Campaign Type'),
347 'description' => ts('Campaign Type ID.Implicit FK to civicrm_option_value where option_group = campaign_type'),
349 'where' => 'civicrm_campaign.campaign_type_id',
352 'table_name' => 'civicrm_campaign',
353 'entity' => 'Campaign',
354 'bao' => 'CRM_Campaign_BAO_Campaign',
359 'pseudoconstant' => [
360 'optionGroupName' => 'campaign_type',
361 'optionEditPath' => 'civicrm/admin/options/campaign_type',
366 'name' => 'status_id',
367 'type' => CRM_Utils_Type
::T_INT
,
368 'title' => ts('Campaign Status'),
369 'description' => ts('Campaign status ID.Implicit FK to civicrm_option_value where option_group = campaign_status'),
371 'where' => 'civicrm_campaign.status_id',
374 'table_name' => 'civicrm_campaign',
375 'entity' => 'Campaign',
376 'bao' => 'CRM_Campaign_BAO_Campaign',
381 'pseudoconstant' => [
382 'optionGroupName' => 'campaign_status',
383 'optionEditPath' => 'civicrm/admin/options/campaign_status',
387 'external_identifier' => [
388 'name' => 'external_identifier',
389 'type' => CRM_Utils_Type
::T_STRING
,
390 'title' => ts('Campaign External ID'),
391 'description' => ts('Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.'),
393 'size' => CRM_Utils_Type
::MEDIUM
,
395 'where' => 'civicrm_campaign.external_identifier',
396 'headerPattern' => '/external\s?id/i',
397 'dataPattern' => '/^\d{11,}$/',
399 'table_name' => 'civicrm_campaign',
400 'entity' => 'Campaign',
401 'bao' => 'CRM_Campaign_BAO_Campaign',
409 'name' => 'parent_id',
410 'type' => CRM_Utils_Type
::T_INT
,
411 'title' => ts('Parent Campaign ID'),
412 'description' => ts('Optional parent id for this Campaign.'),
414 'where' => 'civicrm_campaign.parent_id',
417 'table_name' => 'civicrm_campaign',
418 'entity' => 'Campaign',
419 'bao' => 'CRM_Campaign_BAO_Campaign',
421 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
423 'type' => 'EntityRef',
424 'label' => ts("Parent Campaign"),
429 'name' => 'is_active',
430 'type' => CRM_Utils_Type
::T_BOOLEAN
,
431 'title' => ts('Is Campaign Active?'),
432 'description' => ts('Is this Campaign enabled or disabled/cancelled?'),
433 'where' => 'civicrm_campaign.is_active',
435 'table_name' => 'civicrm_campaign',
436 'entity' => 'Campaign',
437 'bao' => 'CRM_Campaign_BAO_Campaign',
440 'type' => 'CheckBox',
445 'name' => 'created_id',
446 'type' => CRM_Utils_Type
::T_INT
,
447 'title' => ts('Created By Contact ID'),
448 'description' => ts('FK to civicrm_contact, who created this Campaign.'),
449 'where' => 'civicrm_campaign.created_id',
450 'table_name' => 'civicrm_campaign',
451 'entity' => 'Campaign',
452 'bao' => 'CRM_Campaign_BAO_Campaign',
454 'FKClassName' => 'CRM_Contact_DAO_Contact',
456 'label' => ts("Created By"),
461 'name' => 'created_date',
462 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
463 'title' => ts('Campaign Created Date'),
464 'description' => ts('Date and time that Campaign was created.'),
465 'where' => 'civicrm_campaign.created_date',
466 'table_name' => 'civicrm_campaign',
467 'entity' => 'Campaign',
468 'bao' => 'CRM_Campaign_BAO_Campaign',
471 'type' => 'Select Date',
472 'formatType' => 'activityDateTime',
476 'last_modified_id' => [
477 'name' => 'last_modified_id',
478 'type' => CRM_Utils_Type
::T_INT
,
479 'title' => ts('Modified By Contact ID'),
480 'description' => ts('FK to civicrm_contact, who recently edited this Campaign.'),
481 'where' => 'civicrm_campaign.last_modified_id',
482 'table_name' => 'civicrm_campaign',
483 'entity' => 'Campaign',
484 'bao' => 'CRM_Campaign_BAO_Campaign',
486 'FKClassName' => 'CRM_Contact_DAO_Contact',
488 'label' => ts("Modified By"),
492 'last_modified_date' => [
493 'name' => 'last_modified_date',
494 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
495 'title' => ts('Campaign Modified Date'),
496 'description' => ts('Date and time that Campaign was edited last time.'),
497 'where' => 'civicrm_campaign.last_modified_date',
498 'table_name' => 'civicrm_campaign',
499 'entity' => 'Campaign',
500 'bao' => 'CRM_Campaign_BAO_Campaign',
505 'name' => 'goal_general',
506 'type' => CRM_Utils_Type
::T_TEXT
,
507 'title' => ts('Campaign Goals'),
508 'description' => ts('General goals for Campaign.'),
509 'where' => 'civicrm_campaign.goal_general',
510 'table_name' => 'civicrm_campaign',
511 'entity' => 'Campaign',
512 'bao' => 'CRM_Campaign_BAO_Campaign',
515 'type' => 'RichTextEditor',
520 'name' => 'goal_revenue',
521 'type' => CRM_Utils_Type
::T_MONEY
,
522 'title' => ts('Goal Revenue'),
523 'description' => ts('The target revenue for this campaign.'),
528 'where' => 'civicrm_campaign.goal_revenue',
529 'table_name' => 'civicrm_campaign',
530 'entity' => 'Campaign',
531 'bao' => 'CRM_Campaign_BAO_Campaign',
535 'label' => ts("Goal Revenue"),
540 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
542 return Civi
::$statics[__CLASS__
]['fields'];
546 * Return a mapping from field-name to the corresponding key (as used in fields()).
549 * Array(string $name => string $uniqueName).
551 public static function &fieldKeys() {
552 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
553 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
555 return Civi
::$statics[__CLASS__
]['fieldKeys'];
559 * Returns the names of this table
563 public static function getTableName() {
564 return self
::$_tableName;
568 * Returns if this table needs to be logged
572 public function getLog() {
577 * Returns the list of fields that can be imported
579 * @param bool $prefix
583 public static function &import($prefix = FALSE) {
584 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'campaign', $prefix, []);
589 * Returns the list of fields that can be exported
591 * @param bool $prefix
595 public static function &export($prefix = FALSE) {
596 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'campaign', $prefix, []);
601 * Returns the list of indices
603 * @param bool $localize
607 public static function indices($localize = TRUE) {
609 'UI_campaign_name' => [
610 'name' => 'UI_campaign_name',
614 'localizable' => FALSE,
615 'sig' => 'civicrm_campaign::0::name',
617 'UI_campaign_type_id' => [
618 'name' => 'UI_campaign_type_id',
620 0 => 'campaign_type_id',
622 'localizable' => FALSE,
623 'sig' => 'civicrm_campaign::0::campaign_type_id',
625 'UI_campaign_status_id' => [
626 'name' => 'UI_campaign_status_id',
630 'localizable' => FALSE,
631 'sig' => 'civicrm_campaign::0::status_id',
633 'UI_external_identifier' => [
634 'name' => 'UI_external_identifier',
636 0 => 'external_identifier',
638 'localizable' => FALSE,
640 'sig' => 'civicrm_campaign::1::external_identifier',
643 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;