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