Merge pull request #18276 from civicrm/5.29
[civicrm-core.git] / CRM / PCP / DAO / PCP.php
CommitLineData
e501603b 1<?php
c3fc2621 2
e501603b
TO
3/**
4 * @package CRM
ca5cec67 5 * @copyright CiviCRM LLC https://civicrm.org/licensing
e501603b
TO
6 *
7 * Generated from xml/schema/CRM/PCP/PCP.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
929a1c14 9 * (GenCodeChecksum:286225e46c4e2f3c12b17cd5f83b210d)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the PCP entity.
f41f0342 14 */
e501603b 15class CRM_PCP_DAO_PCP extends CRM_Core_DAO {
929a1c14
CW
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '2.2';
c3fc2621 18
e501603b 19 /**
f41f0342 20 * Static instance to hold the table name.
e501603b
TO
21 *
22 * @var string
23 */
fa45b5b9 24 public static $_tableName = 'civicrm_pcp';
c3fc2621 25
e501603b 26 /**
f41f0342 27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b 28 *
c3fc2621 29 * @var bool
e501603b 30 */
fa45b5b9 31 public static $_log = TRUE;
c3fc2621 32
e501603b
TO
33 /**
34 * Personal Campaign Page ID
35 *
e6ca0a57 36 * @var int
e501603b
TO
37 */
38 public $id;
c3fc2621 39
e501603b
TO
40 /**
41 * FK to Contact ID
42 *
e6ca0a57 43 * @var int
e501603b
TO
44 */
45 public $contact_id;
c3fc2621 46
e501603b 47 /**
e6ca0a57 48 * @var int
e501603b
TO
49 */
50 public $status_id;
c3fc2621 51
e501603b 52 /**
e501603b
TO
53 * @var string
54 */
55 public $title;
c3fc2621 56
e501603b 57 /**
e501603b
TO
58 * @var text
59 */
60 public $intro_text;
c3fc2621 61
e501603b 62 /**
e501603b
TO
63 * @var text
64 */
65 public $page_text;
c3fc2621 66
e501603b 67 /**
e501603b
TO
68 * @var string
69 */
70 public $donate_link_text;
c3fc2621 71
e501603b
TO
72 /**
73 * The Contribution or Event Page which triggered this pcp
74 *
e6ca0a57 75 * @var int
e501603b
TO
76 */
77 public $page_id;
c3fc2621 78
e501603b
TO
79 /**
80 * The type of PCP this is: contribute or event
81 *
82 * @var string
83 */
84 public $page_type;
c3fc2621 85
e501603b
TO
86 /**
87 * The pcp block that this pcp page was created from
88 *
e6ca0a57 89 * @var int
e501603b
TO
90 */
91 public $pcp_block_id;
c3fc2621 92
e501603b 93 /**
e6ca0a57 94 * @var int
e501603b
TO
95 */
96 public $is_thermometer;
c3fc2621 97
e501603b 98 /**
e6ca0a57 99 * @var int
e501603b
TO
100 */
101 public $is_honor_roll;
c3fc2621 102
e501603b
TO
103 /**
104 * Goal amount of this Personal Campaign Page.
105 *
106 * @var float
107 */
108 public $goal_amount;
c3fc2621 109
e501603b
TO
110 /**
111 * 3 character string, value from config setting or input via user.
112 *
113 * @var string
114 */
115 public $currency;
c3fc2621 116
e501603b
TO
117 /**
118 * Is Personal Campaign Page enabled/active?
119 *
e6ca0a57 120 * @var bool
e501603b
TO
121 */
122 public $is_active;
c3fc2621 123
e501603b
TO
124 /**
125 * Notify owner via email when someone donates to page?
126 *
e6ca0a57 127 * @var bool
e501603b
TO
128 */
129 public $is_notify;
c3fc2621 130
e501603b 131 /**
f41f0342 132 * Class constructor.
e501603b 133 */
c3fc2621 134 public function __construct() {
e501603b
TO
135 $this->__table = 'civicrm_pcp';
136 parent::__construct();
137 }
c3fc2621 138
449c4e6b
CW
139 /**
140 * Returns localized title of this entity.
141 */
142 public static function getEntityTitle() {
143 return ts('PCPs');
144 }
145
e501603b 146 /**
f41f0342 147 * Returns foreign keys and entity references.
e501603b
TO
148 *
149 * @return array
150 * [CRM_Core_Reference_Interface]
151 */
c3fc2621 152 public static function getReferenceColumns() {
346aaaba 153 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 154 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621 155 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
346aaaba 156 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 157 }
346aaaba 158 return Civi::$statics[__CLASS__]['links'];
e501603b 159 }
c3fc2621 160
e501603b
TO
161 /**
162 * Returns all the column names of this table
163 *
164 * @return array
165 */
c3fc2621 166 public static function &fields() {
346aaaba 167 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
168 Civi::$statics[__CLASS__]['fields'] = [
169 'pcp_id' => [
e501603b
TO
170 'name' => 'id',
171 'type' => CRM_Utils_Type::T_INT,
c3fc2621 172 'title' => ts('Personal Campaign Page ID'),
215b423e 173 'description' => ts('Personal Campaign Page ID'),
c3fc2621 174 'required' => TRUE,
a36434b9 175 'where' => 'civicrm_pcp.id',
522a26c9 176 'table_name' => 'civicrm_pcp',
177 'entity' => 'PCP',
178 'bao' => 'CRM_PCP_BAO_PCP',
6a7e5e5d 179 'localizable' => 0,
a9d0587b 180 'add' => '2.2',
c3fc2621
CW
181 ],
182 'pcp_contact_id' => [
e501603b
TO
183 'name' => 'contact_id',
184 'type' => CRM_Utils_Type::T_INT,
c3fc2621 185 'title' => ts('Contact ID'),
215b423e 186 'description' => ts('FK to Contact ID'),
c3fc2621 187 'required' => TRUE,
a36434b9 188 'where' => 'civicrm_pcp.contact_id',
522a26c9 189 'table_name' => 'civicrm_pcp',
190 'entity' => 'PCP',
191 'bao' => 'CRM_PCP_BAO_PCP',
6a7e5e5d 192 'localizable' => 0,
e501603b 193 'FKClassName' => 'CRM_Contact_DAO_Contact',
c3fc2621 194 'html' => [
e501603b 195 'type' => 'EntityRef',
c3fc2621 196 ],
a9d0587b 197 'add' => '2.2',
c3fc2621
CW
198 ],
199 'status_id' => [
e501603b
TO
200 'name' => 'status_id',
201 'type' => CRM_Utils_Type::T_INT,
c3fc2621
CW
202 'title' => ts('Personal Campaign Page Status'),
203 'required' => TRUE,
a36434b9 204 'where' => 'civicrm_pcp.status_id',
522a26c9 205 'table_name' => 'civicrm_pcp',
206 'entity' => 'PCP',
207 'bao' => 'CRM_PCP_BAO_PCP',
6a7e5e5d 208 'localizable' => 0,
c3fc2621 209 'html' => [
e501603b 210 'type' => 'Select',
c3fc2621
CW
211 ],
212 'pseudoconstant' => [
e501603b
TO
213 'optionGroupName' => 'pcp_status',
214 'optionEditPath' => 'civicrm/admin/options/pcp_status',
e6ca0a57 215 ],
a9d0587b 216 'add' => '2.2',
c3fc2621
CW
217 ],
218 'title' => [
e501603b
TO
219 'name' => 'title',
220 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 221 'title' => ts('Personal Campaign Page Title'),
e501603b
TO
222 'maxlength' => 255,
223 'size' => CRM_Utils_Type::HUGE,
a36434b9 224 'where' => 'civicrm_pcp.title',
e501603b 225 'default' => 'NULL',
522a26c9 226 'table_name' => 'civicrm_pcp',
227 'entity' => 'PCP',
228 'bao' => 'CRM_PCP_BAO_PCP',
6a7e5e5d 229 'localizable' => 0,
c3fc2621 230 'html' => [
e501603b 231 'type' => 'Text',
c3fc2621 232 ],
a9d0587b 233 'add' => '2.2',
c3fc2621
CW
234 ],
235 'intro_text' => [
e501603b
TO
236 'name' => 'intro_text',
237 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 238 'title' => ts('Intro Text'),
a36434b9 239 'where' => 'civicrm_pcp.intro_text',
e501603b 240 'default' => 'NULL',
522a26c9 241 'table_name' => 'civicrm_pcp',
242 'entity' => 'PCP',
243 'bao' => 'CRM_PCP_BAO_PCP',
6a7e5e5d 244 'localizable' => 0,
c3fc2621 245 'html' => [
a510f6fb 246 'type' => 'TextArea',
c3fc2621 247 ],
a9d0587b 248 'add' => '2.2',
c3fc2621
CW
249 ],
250 'page_text' => [
e501603b
TO
251 'name' => 'page_text',
252 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 253 'title' => ts('Page Text'),
a36434b9 254 'where' => 'civicrm_pcp.page_text',
e501603b 255 'default' => 'NULL',
522a26c9 256 'table_name' => 'civicrm_pcp',
257 'entity' => 'PCP',
258 'bao' => 'CRM_PCP_BAO_PCP',
6a7e5e5d 259 'localizable' => 0,
c3fc2621 260 'html' => [
a510f6fb 261 'type' => 'TextArea',
c3fc2621 262 ],
a9d0587b 263 'add' => '2.2',
c3fc2621
CW
264 ],
265 'donate_link_text' => [
e501603b
TO
266 'name' => 'donate_link_text',
267 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 268 'title' => ts('Donate Link Text'),
e501603b
TO
269 'maxlength' => 255,
270 'size' => CRM_Utils_Type::HUGE,
a36434b9 271 'where' => 'civicrm_pcp.donate_link_text',
e501603b 272 'default' => 'NULL',
522a26c9 273 'table_name' => 'civicrm_pcp',
274 'entity' => 'PCP',
275 'bao' => 'CRM_PCP_BAO_PCP',
6a7e5e5d 276 'localizable' => 0,
c3fc2621 277 'html' => [
e501603b 278 'type' => 'Text',
c3fc2621 279 ],
a9d0587b 280 'add' => '2.2',
c3fc2621
CW
281 ],
282 'page_id' => [
e501603b
TO
283 'name' => 'page_id',
284 'type' => CRM_Utils_Type::T_INT,
c3fc2621 285 'title' => ts('Contribution Page'),
215b423e 286 'description' => ts('The Contribution or Event Page which triggered this pcp'),
c3fc2621 287 'required' => TRUE,
a36434b9 288 'where' => 'civicrm_pcp.page_id',
522a26c9 289 'table_name' => 'civicrm_pcp',
290 'entity' => 'PCP',
291 'bao' => 'CRM_PCP_BAO_PCP',
6a7e5e5d 292 'localizable' => 0,
a9d0587b 293 'add' => '4.1',
c3fc2621
CW
294 ],
295 'page_type' => [
e501603b
TO
296 'name' => 'page_type',
297 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 298 'title' => ts('PCP Page Type'),
215b423e 299 'description' => ts('The type of PCP this is: contribute or event'),
e501603b
TO
300 'maxlength' => 64,
301 'size' => CRM_Utils_Type::BIG,
a36434b9 302 'where' => 'civicrm_pcp.page_type',
e501603b 303 'default' => 'contribute',
522a26c9 304 'table_name' => 'civicrm_pcp',
305 'entity' => 'PCP',
306 'bao' => 'CRM_PCP_BAO_PCP',
6a7e5e5d 307 'localizable' => 0,
c3fc2621 308 'html' => [
e501603b 309 'type' => 'Select',
c3fc2621 310 ],
a9d0587b 311 'add' => '2.2',
c3fc2621
CW
312 ],
313 'pcp_block_id' => [
e501603b
TO
314 'name' => 'pcp_block_id',
315 'type' => CRM_Utils_Type::T_INT,
c3fc2621 316 'title' => ts('PCP Block'),
215b423e 317 'description' => ts('The pcp block that this pcp page was created from'),
c3fc2621 318 'required' => TRUE,
a36434b9 319 'where' => 'civicrm_pcp.pcp_block_id',
522a26c9 320 'table_name' => 'civicrm_pcp',
321 'entity' => 'PCP',
322 'bao' => 'CRM_PCP_BAO_PCP',
6a7e5e5d 323 'localizable' => 0,
a9d0587b 324 'add' => '4.1',
c3fc2621
CW
325 ],
326 'is_thermometer' => [
e501603b
TO
327 'name' => 'is_thermometer',
328 'type' => CRM_Utils_Type::T_INT,
c3fc2621 329 'title' => ts('Use Thermometer?'),
a36434b9 330 'where' => 'civicrm_pcp.is_thermometer',
45a83e42 331 'default' => '0',
522a26c9 332 'table_name' => 'civicrm_pcp',
333 'entity' => 'PCP',
334 'bao' => 'CRM_PCP_BAO_PCP',
6a7e5e5d 335 'localizable' => 0,
c3fc2621 336 'html' => [
e501603b 337 'type' => 'CheckBox',
c3fc2621 338 ],
a9d0587b 339 'add' => '2.2',
c3fc2621
CW
340 ],
341 'is_honor_roll' => [
e501603b
TO
342 'name' => 'is_honor_roll',
343 'type' => CRM_Utils_Type::T_INT,
c3fc2621 344 'title' => ts('Show Honor Roll?'),
a36434b9 345 'where' => 'civicrm_pcp.is_honor_roll',
45a83e42 346 'default' => '0',
522a26c9 347 'table_name' => 'civicrm_pcp',
348 'entity' => 'PCP',
349 'bao' => 'CRM_PCP_BAO_PCP',
6a7e5e5d 350 'localizable' => 0,
c3fc2621 351 'html' => [
e501603b 352 'type' => 'CheckBox',
c3fc2621 353 ],
a9d0587b 354 'add' => '2.2',
c3fc2621
CW
355 ],
356 'goal_amount' => [
e501603b
TO
357 'name' => 'goal_amount',
358 'type' => CRM_Utils_Type::T_MONEY,
c3fc2621 359 'title' => ts('Goal Amount'),
215b423e 360 'description' => ts('Goal amount of this Personal Campaign Page.'),
c3fc2621 361 'precision' => [
e501603b 362 20,
fb607354 363 2,
c3fc2621 364 ],
a36434b9 365 'where' => 'civicrm_pcp.goal_amount',
522a26c9 366 'table_name' => 'civicrm_pcp',
367 'entity' => 'PCP',
368 'bao' => 'CRM_PCP_BAO_PCP',
6a7e5e5d 369 'localizable' => 0,
c3fc2621 370 'html' => [
e501603b 371 'type' => 'Text',
c3fc2621 372 ],
a9d0587b 373 'add' => '2.2',
c3fc2621
CW
374 ],
375 'currency' => [
e501603b
TO
376 'name' => 'currency',
377 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 378 'title' => ts('Currency'),
215b423e 379 'description' => ts('3 character string, value from config setting or input via user.'),
e501603b
TO
380 'maxlength' => 3,
381 'size' => CRM_Utils_Type::FOUR,
a36434b9 382 'where' => 'civicrm_pcp.currency',
e501603b 383 'default' => 'NULL',
522a26c9 384 'table_name' => 'civicrm_pcp',
385 'entity' => 'PCP',
386 'bao' => 'CRM_PCP_BAO_PCP',
6a7e5e5d 387 'localizable' => 0,
c3fc2621 388 'html' => [
e501603b 389 'type' => 'Select',
c3fc2621
CW
390 ],
391 'pseudoconstant' => [
e501603b
TO
392 'table' => 'civicrm_currency',
393 'keyColumn' => 'name',
394 'labelColumn' => 'full_name',
395 'nameColumn' => 'name',
a8fdb24e 396 'abbrColumn' => 'symbol',
e6ca0a57 397 ],
a9d0587b 398 'add' => '3.2',
c3fc2621
CW
399 ],
400 'is_active' => [
e501603b
TO
401 'name' => 'is_active',
402 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 403 'title' => ts('Enabled?'),
215b423e 404 'description' => ts('Is Personal Campaign Page enabled/active?'),
a36434b9 405 'where' => 'civicrm_pcp.is_active',
45a83e42 406 'default' => '0',
522a26c9 407 'table_name' => 'civicrm_pcp',
408 'entity' => 'PCP',
409 'bao' => 'CRM_PCP_BAO_PCP',
6a7e5e5d 410 'localizable' => 0,
c3fc2621 411 'html' => [
e501603b 412 'type' => 'CheckBox',
c3fc2621 413 ],
a9d0587b 414 'add' => '2.2',
c3fc2621
CW
415 ],
416 'is_notify' => [
e501603b
TO
417 'name' => 'is_notify',
418 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 419 'title' => ts('Notify Owner?'),
215b423e 420 'description' => ts('Notify owner via email when someone donates to page?'),
a36434b9 421 'where' => 'civicrm_pcp.is_notify',
45a83e42 422 'default' => '0',
522a26c9 423 'table_name' => 'civicrm_pcp',
424 'entity' => 'PCP',
425 'bao' => 'CRM_PCP_BAO_PCP',
6a7e5e5d 426 'localizable' => 0,
c3fc2621 427 'html' => [
e501603b 428 'type' => 'CheckBox',
c3fc2621 429 ],
a9d0587b 430 'add' => '4.6',
c3fc2621
CW
431 ],
432 ];
346aaaba 433 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 434 }
346aaaba 435 return Civi::$statics[__CLASS__]['fields'];
e501603b 436 }
c3fc2621 437
e501603b 438 /**
bd8e0b14 439 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
440 *
441 * @return array
bd8e0b14 442 * Array(string $name => string $uniqueName).
e501603b 443 */
c3fc2621 444 public static function &fieldKeys() {
bd8e0b14
TO
445 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
446 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 447 }
bd8e0b14 448 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 449 }
c3fc2621 450
e501603b
TO
451 /**
452 * Returns the names of this table
453 *
454 * @return string
455 */
c3fc2621 456 public static function getTableName() {
e501603b
TO
457 return self::$_tableName;
458 }
c3fc2621 459
e501603b
TO
460 /**
461 * Returns if this table needs to be logged
462 *
c3fc2621 463 * @return bool
e501603b 464 */
c3fc2621 465 public function getLog() {
e501603b
TO
466 return self::$_log;
467 }
c3fc2621 468
e501603b
TO
469 /**
470 * Returns the list of fields that can be imported
471 *
472 * @param bool $prefix
473 *
474 * @return array
475 */
c3fc2621
CW
476 public static function &import($prefix = FALSE) {
477 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'pcp', $prefix, []);
60808919 478 return $r;
e501603b 479 }
c3fc2621 480
e501603b
TO
481 /**
482 * Returns the list of fields that can be exported
483 *
484 * @param bool $prefix
485 *
486 * @return array
487 */
c3fc2621
CW
488 public static function &export($prefix = FALSE) {
489 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'pcp', $prefix, []);
60808919 490 return $r;
e501603b 491 }
c3fc2621 492
e7a6b91a
AS
493 /**
494 * Returns the list of indices
c3fc2621
CW
495 *
496 * @param bool $localize
497 *
498 * @return array
e7a6b91a
AS
499 */
500 public static function indices($localize = TRUE) {
c3fc2621 501 $indices = [];
e7a6b91a
AS
502 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
503 }
c3fc2621 504
e501603b 505}