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