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:a27331994abb64995fc5491434eeed7f)
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 foreign keys and entity references.
200 * [CRM_Core_Reference_Interface]
202 public static function getReferenceColumns() {
203 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
204 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
205 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'parent_id', 'civicrm_campaign', 'id');
206 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'created_id', 'civicrm_contact', 'id');
207 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'last_modified_id', 'civicrm_contact', 'id');
208 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
210 return Civi
::$statics[__CLASS__
]['links'];
214 * Returns all the column names of this table
218 public static function &fields() {
219 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
220 Civi
::$statics[__CLASS__
]['fields'] = [
223 'type' => CRM_Utils_Type
::T_INT
,
224 'title' => ts('Campaign ID'),
225 'description' => ts('Unique Campaign ID.'),
228 'where' => 'civicrm_campaign.id',
230 'table_name' => 'civicrm_campaign',
231 'entity' => 'Campaign',
232 'bao' => 'CRM_Campaign_BAO_Campaign',
242 'type' => CRM_Utils_Type
::T_STRING
,
243 'title' => ts('Campaign Name'),
244 'description' => ts('Name of the Campaign.'),
247 'size' => CRM_Utils_Type
::HUGE
,
249 'where' => 'civicrm_campaign.name',
251 'table_name' => 'civicrm_campaign',
252 'entity' => 'Campaign',
253 'bao' => 'CRM_Campaign_BAO_Campaign',
262 'type' => CRM_Utils_Type
::T_STRING
,
263 'title' => ts('Campaign Title'),
264 'description' => ts('Title of the Campaign.'),
266 'size' => CRM_Utils_Type
::HUGE
,
268 'where' => 'civicrm_campaign.title',
270 'table_name' => 'civicrm_campaign',
271 'entity' => 'Campaign',
272 'bao' => 'CRM_Campaign_BAO_Campaign',
280 'name' => 'description',
281 'type' => CRM_Utils_Type
::T_TEXT
,
282 'title' => ts('Campaign Description'),
283 'description' => ts('Full description of Campaign.'),
286 'where' => 'civicrm_campaign.description',
287 'table_name' => 'civicrm_campaign',
288 'entity' => 'Campaign',
289 'bao' => 'CRM_Campaign_BAO_Campaign',
292 'type' => 'TextArea',
297 'name' => 'start_date',
298 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
299 'title' => ts('Campaign Start Date'),
300 'description' => ts('Date and time that Campaign starts.'),
302 'where' => 'civicrm_campaign.start_date',
303 'headerPattern' => '/^start|(s(tart\s)?date)$/i',
305 'table_name' => 'civicrm_campaign',
306 'entity' => 'Campaign',
307 'bao' => 'CRM_Campaign_BAO_Campaign',
310 'type' => 'Select Date',
311 'formatType' => 'activityDateTime',
316 'name' => 'end_date',
317 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
318 'title' => ts('Campaign End Date'),
319 'description' => ts('Date and time that Campaign ends.'),
321 'where' => 'civicrm_campaign.end_date',
322 'headerPattern' => '/^end|(e(nd\s)?date)$/i',
324 'table_name' => 'civicrm_campaign',
325 'entity' => 'Campaign',
326 'bao' => 'CRM_Campaign_BAO_Campaign',
329 'type' => 'Select Date',
330 'formatType' => 'activityDateTime',
334 'campaign_type_id' => [
335 'name' => 'campaign_type_id',
336 'type' => CRM_Utils_Type
::T_INT
,
337 'title' => ts('Campaign Type'),
338 'description' => ts('Campaign Type ID.Implicit FK to civicrm_option_value where option_group = campaign_type'),
340 'where' => 'civicrm_campaign.campaign_type_id',
343 'table_name' => 'civicrm_campaign',
344 'entity' => 'Campaign',
345 'bao' => 'CRM_Campaign_BAO_Campaign',
350 'pseudoconstant' => [
351 'optionGroupName' => 'campaign_type',
352 'optionEditPath' => 'civicrm/admin/options/campaign_type',
357 'name' => 'status_id',
358 'type' => CRM_Utils_Type
::T_INT
,
359 'title' => ts('Campaign Status'),
360 'description' => ts('Campaign status ID.Implicit FK to civicrm_option_value where option_group = campaign_status'),
362 'where' => 'civicrm_campaign.status_id',
365 'table_name' => 'civicrm_campaign',
366 'entity' => 'Campaign',
367 'bao' => 'CRM_Campaign_BAO_Campaign',
372 'pseudoconstant' => [
373 'optionGroupName' => 'campaign_status',
374 'optionEditPath' => 'civicrm/admin/options/campaign_status',
378 'external_identifier' => [
379 'name' => 'external_identifier',
380 'type' => CRM_Utils_Type
::T_STRING
,
381 'title' => ts('Campaign External ID'),
382 'description' => ts('Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.'),
384 'size' => CRM_Utils_Type
::MEDIUM
,
386 'where' => 'civicrm_campaign.external_identifier',
387 'headerPattern' => '/external\s?id/i',
388 'dataPattern' => '/^\d{11,}$/',
390 'table_name' => 'civicrm_campaign',
391 'entity' => 'Campaign',
392 'bao' => 'CRM_Campaign_BAO_Campaign',
400 'name' => 'parent_id',
401 'type' => CRM_Utils_Type
::T_INT
,
402 'title' => ts('Parent Campaign ID'),
403 'description' => ts('Optional parent id for this Campaign.'),
405 'where' => 'civicrm_campaign.parent_id',
408 'table_name' => 'civicrm_campaign',
409 'entity' => 'Campaign',
410 'bao' => 'CRM_Campaign_BAO_Campaign',
412 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
414 'type' => 'EntityRef',
415 'label' => ts("Parent Campaign"),
420 'name' => 'is_active',
421 'type' => CRM_Utils_Type
::T_BOOLEAN
,
422 'title' => ts('Is Campaign Active?'),
423 'description' => ts('Is this Campaign enabled or disabled/cancelled?'),
424 'where' => 'civicrm_campaign.is_active',
426 'table_name' => 'civicrm_campaign',
427 'entity' => 'Campaign',
428 'bao' => 'CRM_Campaign_BAO_Campaign',
431 'type' => 'CheckBox',
436 'name' => 'created_id',
437 'type' => CRM_Utils_Type
::T_INT
,
438 'title' => ts('Created By Contact ID'),
439 'description' => ts('FK to civicrm_contact, who created this Campaign.'),
440 'where' => 'civicrm_campaign.created_id',
441 'table_name' => 'civicrm_campaign',
442 'entity' => 'Campaign',
443 'bao' => 'CRM_Campaign_BAO_Campaign',
445 'FKClassName' => 'CRM_Contact_DAO_Contact',
447 'label' => ts("Created By"),
452 'name' => 'created_date',
453 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
454 'title' => ts('Campaign Created Date'),
455 'description' => ts('Date and time that Campaign was created.'),
456 'where' => 'civicrm_campaign.created_date',
457 'table_name' => 'civicrm_campaign',
458 'entity' => 'Campaign',
459 'bao' => 'CRM_Campaign_BAO_Campaign',
462 'type' => 'Select Date',
463 'formatType' => 'activityDateTime',
467 'last_modified_id' => [
468 'name' => 'last_modified_id',
469 'type' => CRM_Utils_Type
::T_INT
,
470 'title' => ts('Modified By Contact ID'),
471 'description' => ts('FK to civicrm_contact, who recently edited this Campaign.'),
472 'where' => 'civicrm_campaign.last_modified_id',
473 'table_name' => 'civicrm_campaign',
474 'entity' => 'Campaign',
475 'bao' => 'CRM_Campaign_BAO_Campaign',
477 'FKClassName' => 'CRM_Contact_DAO_Contact',
479 'label' => ts("Modified By"),
483 'last_modified_date' => [
484 'name' => 'last_modified_date',
485 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
486 'title' => ts('Campaign Modified Date'),
487 'description' => ts('Date and time that Campaign was edited last time.'),
488 'where' => 'civicrm_campaign.last_modified_date',
489 'table_name' => 'civicrm_campaign',
490 'entity' => 'Campaign',
491 'bao' => 'CRM_Campaign_BAO_Campaign',
496 'name' => 'goal_general',
497 'type' => CRM_Utils_Type
::T_TEXT
,
498 'title' => ts('Campaign Goals'),
499 'description' => ts('General goals for Campaign.'),
500 'where' => 'civicrm_campaign.goal_general',
501 'table_name' => 'civicrm_campaign',
502 'entity' => 'Campaign',
503 'bao' => 'CRM_Campaign_BAO_Campaign',
506 'type' => 'RichTextEditor',
511 'name' => 'goal_revenue',
512 'type' => CRM_Utils_Type
::T_MONEY
,
513 'title' => ts('Goal Revenue'),
514 'description' => ts('The target revenue for this campaign.'),
519 'where' => 'civicrm_campaign.goal_revenue',
520 'table_name' => 'civicrm_campaign',
521 'entity' => 'Campaign',
522 'bao' => 'CRM_Campaign_BAO_Campaign',
526 'label' => ts("Goal Revenue"),
531 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
533 return Civi
::$statics[__CLASS__
]['fields'];
537 * Return a mapping from field-name to the corresponding key (as used in fields()).
540 * Array(string $name => string $uniqueName).
542 public static function &fieldKeys() {
543 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
544 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
546 return Civi
::$statics[__CLASS__
]['fieldKeys'];
550 * Returns the names of this table
554 public static function getTableName() {
555 return self
::$_tableName;
559 * Returns if this table needs to be logged
563 public function getLog() {
568 * Returns the list of fields that can be imported
570 * @param bool $prefix
574 public static function &import($prefix = FALSE) {
575 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'campaign', $prefix, []);
580 * Returns the list of fields that can be exported
582 * @param bool $prefix
586 public static function &export($prefix = FALSE) {
587 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'campaign', $prefix, []);
592 * Returns the list of indices
594 * @param bool $localize
598 public static function indices($localize = TRUE) {
600 'UI_campaign_name' => [
601 'name' => 'UI_campaign_name',
605 'localizable' => FALSE,
606 'sig' => 'civicrm_campaign::0::name',
608 'UI_campaign_type_id' => [
609 'name' => 'UI_campaign_type_id',
611 0 => 'campaign_type_id',
613 'localizable' => FALSE,
614 'sig' => 'civicrm_campaign::0::campaign_type_id',
616 'UI_campaign_status_id' => [
617 'name' => 'UI_campaign_status_id',
621 'localizable' => FALSE,
622 'sig' => 'civicrm_campaign::0::status_id',
624 'UI_external_identifier' => [
625 'name' => 'UI_external_identifier',
627 0 => 'external_identifier',
629 'localizable' => FALSE,
631 'sig' => 'civicrm_campaign::1::external_identifier',
634 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;