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:a5a49e13e66a5d32b690835a49baf535)
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;
48 * Name of the Campaign.
55 * Title of the Campaign.
62 * Full description of Campaign.
69 * Date and time that Campaign starts.
76 * Date and time that Campaign ends.
83 * Campaign Type ID.Implicit FK to civicrm_option_value where option_group = campaign_type
87 public $campaign_type_id;
90 * Campaign status ID.Implicit FK to civicrm_option_value where option_group = campaign_status
97 * Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.
101 public $external_identifier;
104 * Optional parent id for this Campaign.
111 * Is this Campaign enabled or disabled/cancelled?
118 * FK to civicrm_contact, who created this Campaign.
125 * Date and time that Campaign was created.
129 public $created_date;
132 * FK to civicrm_contact, who recently edited this Campaign.
136 public $last_modified_id;
139 * Date and time that Campaign was edited last time.
143 public $last_modified_date;
146 * General goals for Campaign.
150 public $goal_general;
153 * The target revenue for this campaign.
157 public $goal_revenue;
162 public function __construct() {
163 $this->__table
= 'civicrm_campaign';
164 parent
::__construct();
168 * Returns localized title of this entity.
170 * @param bool $plural
171 * Whether to return the plural version of the title.
173 public static function getEntityTitle($plural = FALSE) {
174 return $plural ?
ts('Campaigns') : ts('Campaign');
178 * Returns foreign keys and entity references.
181 * [CRM_Core_Reference_Interface]
183 public static function getReferenceColumns() {
184 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
185 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
186 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'parent_id', 'civicrm_campaign', 'id');
187 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'created_id', 'civicrm_contact', 'id');
188 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'last_modified_id', 'civicrm_contact', 'id');
189 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
191 return Civi
::$statics[__CLASS__
]['links'];
195 * Returns all the column names of this table
199 public static function &fields() {
200 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
201 Civi
::$statics[__CLASS__
]['fields'] = [
204 'type' => CRM_Utils_Type
::T_INT
,
205 'title' => ts('Campaign ID'),
206 'description' => ts('Unique Campaign ID.'),
209 'where' => 'civicrm_campaign.id',
211 'table_name' => 'civicrm_campaign',
212 'entity' => 'Campaign',
213 'bao' => 'CRM_Campaign_BAO_Campaign',
219 'type' => CRM_Utils_Type
::T_STRING
,
220 'title' => ts('Campaign Name'),
221 'description' => ts('Name of the Campaign.'),
224 'size' => CRM_Utils_Type
::HUGE
,
226 'where' => 'civicrm_campaign.name',
228 'table_name' => 'civicrm_campaign',
229 'entity' => 'Campaign',
230 'bao' => 'CRM_Campaign_BAO_Campaign',
239 'type' => CRM_Utils_Type
::T_STRING
,
240 'title' => ts('Campaign Title'),
241 'description' => ts('Title of the Campaign.'),
243 'size' => CRM_Utils_Type
::HUGE
,
245 'where' => 'civicrm_campaign.title',
247 'table_name' => 'civicrm_campaign',
248 'entity' => 'Campaign',
249 'bao' => 'CRM_Campaign_BAO_Campaign',
257 'name' => 'description',
258 'type' => CRM_Utils_Type
::T_TEXT
,
259 'title' => ts('Campaign Description'),
260 'description' => ts('Full description of Campaign.'),
263 'where' => 'civicrm_campaign.description',
264 'table_name' => 'civicrm_campaign',
265 'entity' => 'Campaign',
266 'bao' => 'CRM_Campaign_BAO_Campaign',
269 'type' => 'TextArea',
274 'name' => 'start_date',
275 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
276 'title' => ts('Campaign Start Date'),
277 'description' => ts('Date and time that Campaign starts.'),
279 'where' => 'civicrm_campaign.start_date',
280 'headerPattern' => '/^start|(s(tart\s)?date)$/i',
282 'table_name' => 'civicrm_campaign',
283 'entity' => 'Campaign',
284 'bao' => 'CRM_Campaign_BAO_Campaign',
287 'type' => 'Select Date',
288 'formatType' => 'activityDateTime',
293 'name' => 'end_date',
294 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
295 'title' => ts('Campaign End Date'),
296 'description' => ts('Date and time that Campaign ends.'),
298 'where' => 'civicrm_campaign.end_date',
299 'headerPattern' => '/^end|(e(nd\s)?date)$/i',
301 'table_name' => 'civicrm_campaign',
302 'entity' => 'Campaign',
303 'bao' => 'CRM_Campaign_BAO_Campaign',
306 'type' => 'Select Date',
307 'formatType' => 'activityDateTime',
311 'campaign_type_id' => [
312 'name' => 'campaign_type_id',
313 'type' => CRM_Utils_Type
::T_INT
,
314 'title' => ts('Campaign Type'),
315 'description' => ts('Campaign Type ID.Implicit FK to civicrm_option_value where option_group = campaign_type'),
317 'where' => 'civicrm_campaign.campaign_type_id',
320 'table_name' => 'civicrm_campaign',
321 'entity' => 'Campaign',
322 'bao' => 'CRM_Campaign_BAO_Campaign',
327 'pseudoconstant' => [
328 'optionGroupName' => 'campaign_type',
329 'optionEditPath' => 'civicrm/admin/options/campaign_type',
334 'name' => 'status_id',
335 'type' => CRM_Utils_Type
::T_INT
,
336 'title' => ts('Campaign Status'),
337 'description' => ts('Campaign status ID.Implicit FK to civicrm_option_value where option_group = campaign_status'),
339 'where' => 'civicrm_campaign.status_id',
342 'table_name' => 'civicrm_campaign',
343 'entity' => 'Campaign',
344 'bao' => 'CRM_Campaign_BAO_Campaign',
349 'pseudoconstant' => [
350 'optionGroupName' => 'campaign_status',
351 'optionEditPath' => 'civicrm/admin/options/campaign_status',
355 'external_identifier' => [
356 'name' => 'external_identifier',
357 'type' => CRM_Utils_Type
::T_STRING
,
358 'title' => ts('Campaign External ID'),
359 'description' => ts('Unique trusted external ID (generally from a legacy app/datasource). Particularly useful for deduping operations.'),
361 'size' => CRM_Utils_Type
::MEDIUM
,
363 'where' => 'civicrm_campaign.external_identifier',
364 'headerPattern' => '/external\s?id/i',
365 'dataPattern' => '/^\d{11,}$/',
367 'table_name' => 'civicrm_campaign',
368 'entity' => 'Campaign',
369 'bao' => 'CRM_Campaign_BAO_Campaign',
377 'name' => 'parent_id',
378 'type' => CRM_Utils_Type
::T_INT
,
379 'title' => ts('Parent Campaign'),
380 'description' => ts('Optional parent id for this Campaign.'),
382 'where' => 'civicrm_campaign.parent_id',
385 'table_name' => 'civicrm_campaign',
386 'entity' => 'Campaign',
387 'bao' => 'CRM_Campaign_BAO_Campaign',
389 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
391 'type' => 'EntityRef',
396 'name' => 'is_active',
397 'type' => CRM_Utils_Type
::T_BOOLEAN
,
398 'title' => ts('Is Campaign Active?'),
399 'description' => ts('Is this Campaign enabled or disabled/cancelled?'),
400 'where' => 'civicrm_campaign.is_active',
402 'table_name' => 'civicrm_campaign',
403 'entity' => 'Campaign',
404 'bao' => 'CRM_Campaign_BAO_Campaign',
407 'type' => 'CheckBox',
412 'name' => 'created_id',
413 'type' => CRM_Utils_Type
::T_INT
,
414 'title' => ts('Campaign Created By'),
415 'description' => ts('FK to civicrm_contact, who created this Campaign.'),
416 'where' => 'civicrm_campaign.created_id',
417 'table_name' => 'civicrm_campaign',
418 'entity' => 'Campaign',
419 'bao' => 'CRM_Campaign_BAO_Campaign',
421 'FKClassName' => 'CRM_Contact_DAO_Contact',
425 'name' => 'created_date',
426 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
427 'title' => ts('Campaign Created Date'),
428 'description' => ts('Date and time that Campaign was created.'),
429 'where' => 'civicrm_campaign.created_date',
430 'table_name' => 'civicrm_campaign',
431 'entity' => 'Campaign',
432 'bao' => 'CRM_Campaign_BAO_Campaign',
435 'type' => 'Select Date',
436 'formatType' => 'activityDateTime',
440 'last_modified_id' => [
441 'name' => 'last_modified_id',
442 'type' => CRM_Utils_Type
::T_INT
,
443 'title' => ts('Campaign Modified By'),
444 'description' => ts('FK to civicrm_contact, who recently edited this Campaign.'),
445 'where' => 'civicrm_campaign.last_modified_id',
446 'table_name' => 'civicrm_campaign',
447 'entity' => 'Campaign',
448 'bao' => 'CRM_Campaign_BAO_Campaign',
450 'FKClassName' => 'CRM_Contact_DAO_Contact',
453 'last_modified_date' => [
454 'name' => 'last_modified_date',
455 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
456 'title' => ts('Campaign Modified Date'),
457 'description' => ts('Date and time that Campaign was edited last time.'),
458 'where' => 'civicrm_campaign.last_modified_date',
459 'table_name' => 'civicrm_campaign',
460 'entity' => 'Campaign',
461 'bao' => 'CRM_Campaign_BAO_Campaign',
466 'name' => 'goal_general',
467 'type' => CRM_Utils_Type
::T_TEXT
,
468 'title' => ts('Campaign Goals'),
469 'description' => ts('General goals for Campaign.'),
470 'where' => 'civicrm_campaign.goal_general',
471 'table_name' => 'civicrm_campaign',
472 'entity' => 'Campaign',
473 'bao' => 'CRM_Campaign_BAO_Campaign',
476 'type' => 'RichTextEditor',
481 'name' => 'goal_revenue',
482 'type' => CRM_Utils_Type
::T_MONEY
,
483 'title' => ts('Goal Revenue'),
484 'description' => ts('The target revenue for this campaign.'),
489 'where' => 'civicrm_campaign.goal_revenue',
490 'table_name' => 'civicrm_campaign',
491 'entity' => 'Campaign',
492 'bao' => 'CRM_Campaign_BAO_Campaign',
500 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
502 return Civi
::$statics[__CLASS__
]['fields'];
506 * Return a mapping from field-name to the corresponding key (as used in fields()).
509 * Array(string $name => string $uniqueName).
511 public static function &fieldKeys() {
512 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
513 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
515 return Civi
::$statics[__CLASS__
]['fieldKeys'];
519 * Returns the names of this table
523 public static function getTableName() {
524 return self
::$_tableName;
528 * Returns if this table needs to be logged
532 public function getLog() {
537 * Returns the list of fields that can be imported
539 * @param bool $prefix
543 public static function &import($prefix = FALSE) {
544 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'campaign', $prefix, []);
549 * Returns the list of fields that can be exported
551 * @param bool $prefix
555 public static function &export($prefix = FALSE) {
556 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'campaign', $prefix, []);
561 * Returns the list of indices
563 * @param bool $localize
567 public static function indices($localize = TRUE) {
569 'UI_campaign_type_id' => [
570 'name' => 'UI_campaign_type_id',
572 0 => 'campaign_type_id',
574 'localizable' => FALSE,
575 'sig' => 'civicrm_campaign::0::campaign_type_id',
577 'UI_campaign_status_id' => [
578 'name' => 'UI_campaign_status_id',
582 'localizable' => FALSE,
583 'sig' => 'civicrm_campaign::0::status_id',
585 'UI_external_identifier' => [
586 'name' => 'UI_external_identifier',
588 0 => 'external_identifier',
590 'localizable' => FALSE,
592 'sig' => 'civicrm_campaign::1::external_identifier',
595 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;