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