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:1356a7073a6caa15e0da58422c6763b9)
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';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_campaign';
27 * Icon associated with this entity.
31 public static $_icon = 'fa-bullhorn';
34 * Should CiviCRM log any modifications to this table in the civicrm_log table.
38 public static $_log = FALSE;
41 * Paths for accessing this entity in the UI.
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]',
59 * Name of the Campaign.
66 * Title of the Campaign.
73 * Full description of Campaign.
80 * Date and time that Campaign starts.
87 * Date and time that Campaign ends.
94 * Campaign Type ID.Implicit FK to civicrm_option_value where option_group = campaign_type
98 public $campaign_type_id;
101 * Campaign status ID.Implicit FK to civicrm_option_value where option_group = campaign_status
108 * Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.
112 public $external_identifier;
115 * Optional parent id for this Campaign.
122 * Is this Campaign enabled or disabled/cancelled?
129 * FK to civicrm_contact, who created this Campaign.
136 * Date and time that Campaign was created.
140 public $created_date;
143 * FK to civicrm_contact, who recently edited this Campaign.
147 public $last_modified_id;
150 * Date and time that Campaign was edited last time.
154 public $last_modified_date;
157 * General goals for Campaign.
161 public $goal_general;
164 * The target revenue for this campaign.
168 public $goal_revenue;
173 public function __construct() {
174 $this->__table
= 'civicrm_campaign';
175 parent
::__construct();
179 * Returns localized title of this entity.
181 * @param bool $plural
182 * Whether to return the plural version of the title.
184 public static function getEntityTitle($plural = FALSE) {
185 return $plural ?
ts('Campaigns') : ts('Campaign');
189 * Returns foreign keys and entity references.
192 * [CRM_Core_Reference_Interface]
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']);
202 return Civi
::$statics[__CLASS__
]['links'];
206 * Returns all the column names of this table
210 public static function &fields() {
211 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
212 Civi
::$statics[__CLASS__
]['fields'] = [
215 'type' => CRM_Utils_Type
::T_INT
,
216 'title' => ts('Campaign ID'),
217 'description' => ts('Unique Campaign ID.'),
220 'where' => 'civicrm_campaign.id',
222 'table_name' => 'civicrm_campaign',
223 'entity' => 'Campaign',
224 'bao' => 'CRM_Campaign_BAO_Campaign',
230 'type' => CRM_Utils_Type
::T_STRING
,
231 'title' => ts('Campaign Name'),
232 'description' => ts('Name of the Campaign.'),
235 'size' => CRM_Utils_Type
::HUGE
,
237 'where' => 'civicrm_campaign.name',
239 'table_name' => 'civicrm_campaign',
240 'entity' => 'Campaign',
241 'bao' => 'CRM_Campaign_BAO_Campaign',
250 'type' => CRM_Utils_Type
::T_STRING
,
251 'title' => ts('Campaign Title'),
252 'description' => ts('Title of the Campaign.'),
254 'size' => CRM_Utils_Type
::HUGE
,
256 'where' => 'civicrm_campaign.title',
258 'table_name' => 'civicrm_campaign',
259 'entity' => 'Campaign',
260 'bao' => 'CRM_Campaign_BAO_Campaign',
268 'name' => 'description',
269 'type' => CRM_Utils_Type
::T_TEXT
,
270 'title' => ts('Campaign Description'),
271 'description' => ts('Full description of Campaign.'),
274 'where' => 'civicrm_campaign.description',
275 'table_name' => 'civicrm_campaign',
276 'entity' => 'Campaign',
277 'bao' => 'CRM_Campaign_BAO_Campaign',
280 'type' => 'TextArea',
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.'),
290 'where' => 'civicrm_campaign.start_date',
291 'headerPattern' => '/^start|(s(tart\s)?date)$/i',
293 'table_name' => 'civicrm_campaign',
294 'entity' => 'Campaign',
295 'bao' => 'CRM_Campaign_BAO_Campaign',
298 'type' => 'Select Date',
299 'formatType' => 'activityDateTime',
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.'),
309 'where' => 'civicrm_campaign.end_date',
310 'headerPattern' => '/^end|(e(nd\s)?date)$/i',
312 'table_name' => 'civicrm_campaign',
313 'entity' => 'Campaign',
314 'bao' => 'CRM_Campaign_BAO_Campaign',
317 'type' => 'Select Date',
318 'formatType' => 'activityDateTime',
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'),
328 'where' => 'civicrm_campaign.campaign_type_id',
331 'table_name' => 'civicrm_campaign',
332 'entity' => 'Campaign',
333 'bao' => 'CRM_Campaign_BAO_Campaign',
338 'pseudoconstant' => [
339 'optionGroupName' => 'campaign_type',
340 'optionEditPath' => 'civicrm/admin/options/campaign_type',
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'),
350 'where' => 'civicrm_campaign.status_id',
353 'table_name' => 'civicrm_campaign',
354 'entity' => 'Campaign',
355 'bao' => 'CRM_Campaign_BAO_Campaign',
360 'pseudoconstant' => [
361 'optionGroupName' => 'campaign_status',
362 'optionEditPath' => 'civicrm/admin/options/campaign_status',
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.'),
372 'size' => CRM_Utils_Type
::MEDIUM
,
374 'where' => 'civicrm_campaign.external_identifier',
375 'headerPattern' => '/external\s?id/i',
376 'dataPattern' => '/^\d{11,}$/',
378 'table_name' => 'civicrm_campaign',
379 'entity' => 'Campaign',
380 'bao' => 'CRM_Campaign_BAO_Campaign',
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.'),
393 'where' => 'civicrm_campaign.parent_id',
396 'table_name' => 'civicrm_campaign',
397 'entity' => 'Campaign',
398 'bao' => 'CRM_Campaign_BAO_Campaign',
400 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
402 'type' => 'EntityRef',
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',
413 'table_name' => 'civicrm_campaign',
414 'entity' => 'Campaign',
415 'bao' => 'CRM_Campaign_BAO_Campaign',
418 'type' => 'CheckBox',
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',
432 'FKClassName' => 'CRM_Contact_DAO_Contact',
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',
446 'type' => 'Select Date',
447 'formatType' => 'activityDateTime',
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',
461 'FKClassName' => 'CRM_Contact_DAO_Contact',
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',
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',
487 'type' => 'RichTextEditor',
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.'),
500 'where' => 'civicrm_campaign.goal_revenue',
501 'table_name' => 'civicrm_campaign',
502 'entity' => 'Campaign',
503 'bao' => 'CRM_Campaign_BAO_Campaign',
511 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
513 return Civi
::$statics[__CLASS__
]['fields'];
517 * Return a mapping from field-name to the corresponding key (as used in fields()).
520 * Array(string $name => string $uniqueName).
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()));
526 return Civi
::$statics[__CLASS__
]['fieldKeys'];
530 * Returns the names of this table
534 public static function getTableName() {
535 return self
::$_tableName;
539 * Returns if this table needs to be logged
543 public function getLog() {
548 * Returns the list of fields that can be imported
550 * @param bool $prefix
554 public static function &import($prefix = FALSE) {
555 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'campaign', $prefix, []);
560 * Returns the list of fields that can be exported
562 * @param bool $prefix
566 public static function &export($prefix = FALSE) {
567 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'campaign', $prefix, []);
572 * Returns the list of indices
574 * @param bool $localize
578 public static function indices($localize = TRUE) {
580 'UI_campaign_type_id' => [
581 'name' => 'UI_campaign_type_id',
583 0 => 'campaign_type_id',
585 'localizable' => FALSE,
586 'sig' => 'civicrm_campaign::0::campaign_type_id',
588 'UI_campaign_status_id' => [
589 'name' => 'UI_campaign_status_id',
593 'localizable' => FALSE,
594 'sig' => 'civicrm_campaign::0::status_id',
596 'UI_external_identifier' => [
597 'name' => 'UI_external_identifier',
599 0 => 'external_identifier',
601 'localizable' => FALSE,
603 'sig' => 'civicrm_campaign::1::external_identifier',
606 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;