Merge pull request #18419 from colemanw/improveCustomFieldForm
[civicrm-core.git] / CRM / PCP / DAO / PCPBlock.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/PCPBlock.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
929a1c14 9 * (GenCodeChecksum:ea1b4158570c5a79356b1dc0ad80db6a)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the PCPBlock entity.
f41f0342 14 */
e501603b 15class CRM_PCP_DAO_PCPBlock 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_block';
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 * PCP block Id
35 *
e6ca0a57 36 * @var int
e501603b
TO
37 */
38 public $id;
c3fc2621 39
e501603b 40 /**
e501603b
TO
41 * @var string
42 */
43 public $entity_table;
c3fc2621 44
e501603b
TO
45 /**
46 * FK to civicrm_contribution_page.id OR civicrm_event.id
47 *
e6ca0a57 48 * @var int
e501603b
TO
49 */
50 public $entity_id;
c3fc2621 51
e501603b
TO
52 /**
53 * The type of entity that this pcp targets
54 *
55 * @var string
56 */
57 public $target_entity_type;
c3fc2621 58
e501603b
TO
59 /**
60 * The entity that this pcp targets
61 *
e6ca0a57 62 * @var int
e501603b
TO
63 */
64 public $target_entity_id;
c3fc2621 65
e501603b
TO
66 /**
67 * FK to civicrm_uf_group.id. Does Personal Campaign Page require manual activation by administrator? (is inactive by default after setup)?
68 *
e6ca0a57 69 * @var int
e501603b
TO
70 */
71 public $supporter_profile_id;
c3fc2621 72
e501603b
TO
73 /**
74 * FK to civicrm_option_group with name = PCP owner notifications
75 *
e6ca0a57 76 * @var int
e501603b
TO
77 */
78 public $owner_notify_id;
c3fc2621 79
e501603b
TO
80 /**
81 * Does Personal Campaign Page require manual activation by administrator? (is inactive by default after setup)?
82 *
e6ca0a57 83 * @var bool
e501603b
TO
84 */
85 public $is_approval_needed;
c3fc2621 86
e501603b
TO
87 /**
88 * Does Personal Campaign Page allow using tell a friend?
89 *
e6ca0a57 90 * @var bool
e501603b
TO
91 */
92 public $is_tellfriend_enabled;
c3fc2621 93
e501603b
TO
94 /**
95 * Maximum recipient fields allowed in tell a friend
96 *
e6ca0a57 97 * @var int
e501603b
TO
98 */
99 public $tellfriend_limit;
c3fc2621 100
e501603b
TO
101 /**
102 * Link text for PCP.
103 *
104 * @var string
105 */
106 public $link_text;
c3fc2621 107
e501603b
TO
108 /**
109 * Is Personal Campaign Page Block enabled/active?
110 *
e6ca0a57 111 * @var bool
e501603b
TO
112 */
113 public $is_active;
c3fc2621 114
e501603b
TO
115 /**
116 * If set, notification is automatically emailed to this email-address on create/update Personal Campaign Page
117 *
118 * @var string
119 */
120 public $notify_email;
c3fc2621 121
e501603b 122 /**
f41f0342 123 * Class constructor.
e501603b 124 */
c3fc2621 125 public function __construct() {
e501603b
TO
126 $this->__table = 'civicrm_pcp_block';
127 parent::__construct();
128 }
c3fc2621 129
449c4e6b
CW
130 /**
131 * Returns localized title of this entity.
132 */
133 public static function getEntityTitle() {
134 return ts('PCPBlocks');
135 }
136
e501603b 137 /**
f41f0342 138 * Returns foreign keys and entity references.
e501603b
TO
139 *
140 * @return array
141 * [CRM_Core_Reference_Interface]
142 */
c3fc2621 143 public static function getReferenceColumns() {
346aaaba 144 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 145 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621
CW
146 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'supporter_profile_id', 'civicrm_uf_group', 'id');
147 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
148 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'target_entity_id', NULL, 'id', 'target_entity_type');
346aaaba 149 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 150 }
346aaaba 151 return Civi::$statics[__CLASS__]['links'];
e501603b 152 }
c3fc2621 153
e501603b
TO
154 /**
155 * Returns all the column names of this table
156 *
157 * @return array
158 */
c3fc2621 159 public static function &fields() {
346aaaba 160 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
161 Civi::$statics[__CLASS__]['fields'] = [
162 'id' => [
e501603b
TO
163 'name' => 'id',
164 'type' => CRM_Utils_Type::T_INT,
c3fc2621 165 'title' => ts('PCP Block ID'),
215b423e 166 'description' => ts('PCP block Id'),
c3fc2621 167 'required' => TRUE,
a36434b9 168 'where' => 'civicrm_pcp_block.id',
522a26c9 169 'table_name' => 'civicrm_pcp_block',
170 'entity' => 'PCPBlock',
171 'bao' => 'CRM_PCP_BAO_PCPBlock',
6a7e5e5d 172 'localizable' => 0,
a9d0587b 173 'add' => '2.2',
c3fc2621
CW
174 ],
175 'entity_table' => [
e501603b
TO
176 'name' => 'entity_table',
177 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 178 'title' => ts('Entity Table'),
e501603b
TO
179 'maxlength' => 64,
180 'size' => CRM_Utils_Type::BIG,
a36434b9 181 'where' => 'civicrm_pcp_block.entity_table',
522a26c9 182 'table_name' => 'civicrm_pcp_block',
183 'entity' => 'PCPBlock',
184 'bao' => 'CRM_PCP_BAO_PCPBlock',
6a7e5e5d 185 'localizable' => 0,
a9d0587b 186 'add' => '2.2',
c3fc2621
CW
187 ],
188 'entity_id' => [
e501603b
TO
189 'name' => 'entity_id',
190 'type' => CRM_Utils_Type::T_INT,
c3fc2621 191 'title' => ts('Entity'),
215b423e 192 'description' => ts('FK to civicrm_contribution_page.id OR civicrm_event.id'),
c3fc2621 193 'required' => TRUE,
a36434b9 194 'where' => 'civicrm_pcp_block.entity_id',
522a26c9 195 'table_name' => 'civicrm_pcp_block',
196 'entity' => 'PCPBlock',
197 'bao' => 'CRM_PCP_BAO_PCPBlock',
6a7e5e5d 198 'localizable' => 0,
a9d0587b 199 'add' => '2.2',
c3fc2621
CW
200 ],
201 'target_entity_type' => [
e501603b
TO
202 'name' => 'target_entity_type',
203 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 204 'title' => ts('Target Entity'),
215b423e 205 'description' => ts('The type of entity that this pcp targets'),
c3fc2621 206 'required' => TRUE,
e501603b
TO
207 'maxlength' => 255,
208 'size' => CRM_Utils_Type::HUGE,
a36434b9 209 'where' => 'civicrm_pcp_block.target_entity_type',
e501603b 210 'default' => 'contribute',
522a26c9 211 'table_name' => 'civicrm_pcp_block',
212 'entity' => 'PCPBlock',
213 'bao' => 'CRM_PCP_BAO_PCPBlock',
6a7e5e5d 214 'localizable' => 0,
a9d0587b 215 'add' => '4.1',
c3fc2621
CW
216 ],
217 'target_entity_id' => [
e501603b
TO
218 'name' => 'target_entity_id',
219 'type' => CRM_Utils_Type::T_INT,
c3fc2621 220 'title' => ts('Target Entity ID'),
215b423e 221 'description' => ts('The entity that this pcp targets'),
c3fc2621 222 'required' => TRUE,
a36434b9 223 'where' => 'civicrm_pcp_block.target_entity_id',
522a26c9 224 'table_name' => 'civicrm_pcp_block',
225 'entity' => 'PCPBlock',
226 'bao' => 'CRM_PCP_BAO_PCPBlock',
6a7e5e5d 227 'localizable' => 0,
a9d0587b 228 'add' => '4.1',
c3fc2621
CW
229 ],
230 'supporter_profile_id' => [
e501603b
TO
231 'name' => 'supporter_profile_id',
232 'type' => CRM_Utils_Type::T_INT,
c3fc2621 233 'title' => ts('Supporter Profile'),
215b423e 234 'description' => ts('FK to civicrm_uf_group.id. Does Personal Campaign Page require manual activation by administrator? (is inactive by default after setup)?'),
a36434b9 235 'where' => 'civicrm_pcp_block.supporter_profile_id',
e501603b 236 'default' => 'NULL',
522a26c9 237 'table_name' => 'civicrm_pcp_block',
238 'entity' => 'PCPBlock',
239 'bao' => 'CRM_PCP_BAO_PCPBlock',
6a7e5e5d 240 'localizable' => 0,
e501603b 241 'FKClassName' => 'CRM_Core_DAO_UFGroup',
a9d0587b 242 'add' => '2.2',
c3fc2621
CW
243 ],
244 'owner_notify_id' => [
e501603b
TO
245 'name' => 'owner_notify_id',
246 'type' => CRM_Utils_Type::T_INT,
c3fc2621 247 'title' => ts('Owner Notification'),
215b423e 248 'description' => ts('FK to civicrm_option_group with name = PCP owner notifications'),
a36434b9 249 'where' => 'civicrm_pcp_block.owner_notify_id',
45a83e42 250 'default' => '0',
522a26c9 251 'table_name' => 'civicrm_pcp_block',
252 'entity' => 'PCPBlock',
253 'bao' => 'CRM_PCP_BAO_PCPBlock',
6a7e5e5d 254 'localizable' => 0,
c3fc2621 255 'html' => [
e501603b 256 'type' => 'Radio',
c3fc2621
CW
257 ],
258 'pseudoconstant' => [
e501603b
TO
259 'optionGroupName' => 'pcp_owner_notify',
260 'optionEditPath' => 'civicrm/admin/options/pcp_owner_notify',
e6ca0a57 261 ],
a9d0587b 262 'add' => '4.6',
c3fc2621
CW
263 ],
264 'is_approval_needed' => [
e501603b
TO
265 'name' => 'is_approval_needed',
266 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 267 'title' => ts('Approval Required?'),
215b423e 268 'description' => ts('Does Personal Campaign Page require manual activation by administrator? (is inactive by default after setup)?'),
a36434b9 269 'where' => 'civicrm_pcp_block.is_approval_needed',
e501603b 270 'default' => 'NULL',
522a26c9 271 'table_name' => 'civicrm_pcp_block',
272 'entity' => 'PCPBlock',
273 'bao' => 'CRM_PCP_BAO_PCPBlock',
6a7e5e5d 274 'localizable' => 0,
a9d0587b 275 'add' => '2.2',
c3fc2621
CW
276 ],
277 'is_tellfriend_enabled' => [
e501603b
TO
278 'name' => 'is_tellfriend_enabled',
279 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 280 'title' => ts('Tell a Friend Enabled?'),
215b423e 281 'description' => ts('Does Personal Campaign Page allow using tell a friend?'),
a36434b9 282 'where' => 'civicrm_pcp_block.is_tellfriend_enabled',
e501603b 283 'default' => 'NULL',
522a26c9 284 'table_name' => 'civicrm_pcp_block',
285 'entity' => 'PCPBlock',
286 'bao' => 'CRM_PCP_BAO_PCPBlock',
6a7e5e5d 287 'localizable' => 0,
a9d0587b 288 'add' => '2.2',
c3fc2621
CW
289 ],
290 'tellfriend_limit' => [
e501603b
TO
291 'name' => 'tellfriend_limit',
292 'type' => CRM_Utils_Type::T_INT,
c3fc2621 293 'title' => ts('Tell A Friend Limit'),
215b423e 294 'description' => ts('Maximum recipient fields allowed in tell a friend'),
a36434b9 295 'where' => 'civicrm_pcp_block.tellfriend_limit',
e501603b 296 'default' => 'NULL',
522a26c9 297 'table_name' => 'civicrm_pcp_block',
298 'entity' => 'PCPBlock',
299 'bao' => 'CRM_PCP_BAO_PCPBlock',
6a7e5e5d 300 'localizable' => 0,
a9d0587b 301 'add' => '2.2',
c3fc2621
CW
302 ],
303 'link_text' => [
e501603b
TO
304 'name' => 'link_text',
305 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 306 'title' => ts('Link Text'),
215b423e 307 'description' => ts('Link text for PCP.'),
e501603b
TO
308 'maxlength' => 255,
309 'size' => CRM_Utils_Type::HUGE,
a36434b9 310 'where' => 'civicrm_pcp_block.link_text',
e501603b 311 'default' => 'NULL',
522a26c9 312 'table_name' => 'civicrm_pcp_block',
313 'entity' => 'PCPBlock',
314 'bao' => 'CRM_PCP_BAO_PCPBlock',
6a7e5e5d 315 'localizable' => 1,
a9d0587b 316 'add' => '2.2',
c3fc2621
CW
317 ],
318 'is_active' => [
e501603b
TO
319 'name' => 'is_active',
320 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 321 'title' => ts('Enabled?'),
215b423e 322 'description' => ts('Is Personal Campaign Page Block enabled/active?'),
a36434b9 323 'where' => 'civicrm_pcp_block.is_active',
e501603b 324 'default' => '1',
522a26c9 325 'table_name' => 'civicrm_pcp_block',
326 'entity' => 'PCPBlock',
327 'bao' => 'CRM_PCP_BAO_PCPBlock',
6a7e5e5d 328 'localizable' => 0,
a9d0587b 329 'add' => '2.2',
c3fc2621
CW
330 ],
331 'notify_email' => [
e501603b
TO
332 'name' => 'notify_email',
333 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 334 'title' => ts('Notification Email'),
215b423e 335 'description' => ts('If set, notification is automatically emailed to this email-address on create/update Personal Campaign Page'),
e501603b
TO
336 'maxlength' => 255,
337 'size' => CRM_Utils_Type::HUGE,
a36434b9 338 'where' => 'civicrm_pcp_block.notify_email',
e501603b 339 'default' => 'NULL',
522a26c9 340 'table_name' => 'civicrm_pcp_block',
341 'entity' => 'PCPBlock',
342 'bao' => 'CRM_PCP_BAO_PCPBlock',
6a7e5e5d 343 'localizable' => 0,
a9d0587b 344 'add' => '2.2',
c3fc2621
CW
345 ],
346 ];
346aaaba 347 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 348 }
346aaaba 349 return Civi::$statics[__CLASS__]['fields'];
e501603b 350 }
c3fc2621 351
e501603b 352 /**
bd8e0b14 353 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
354 *
355 * @return array
bd8e0b14 356 * Array(string $name => string $uniqueName).
e501603b 357 */
c3fc2621 358 public static function &fieldKeys() {
bd8e0b14
TO
359 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
360 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 361 }
bd8e0b14 362 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 363 }
c3fc2621 364
e501603b
TO
365 /**
366 * Returns the names of this table
367 *
368 * @return string
369 */
c3fc2621 370 public static function getTableName() {
e501603b
TO
371 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
372 }
c3fc2621 373
e501603b
TO
374 /**
375 * Returns if this table needs to be logged
376 *
c3fc2621 377 * @return bool
e501603b 378 */
c3fc2621 379 public function getLog() {
e501603b
TO
380 return self::$_log;
381 }
c3fc2621 382
e501603b
TO
383 /**
384 * Returns the list of fields that can be imported
385 *
386 * @param bool $prefix
387 *
388 * @return array
389 */
c3fc2621
CW
390 public static function &import($prefix = FALSE) {
391 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'pcp_block', $prefix, []);
60808919 392 return $r;
e501603b 393 }
c3fc2621 394
e501603b
TO
395 /**
396 * Returns the list of fields that can be exported
397 *
398 * @param bool $prefix
399 *
400 * @return array
401 */
c3fc2621
CW
402 public static function &export($prefix = FALSE) {
403 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'pcp_block', $prefix, []);
60808919 404 return $r;
e501603b 405 }
c3fc2621 406
e7a6b91a
AS
407 /**
408 * Returns the list of indices
c3fc2621
CW
409 *
410 * @param bool $localize
411 *
412 * @return array
e7a6b91a
AS
413 */
414 public static function indices($localize = TRUE) {
c3fc2621 415 $indices = [];
e7a6b91a
AS
416 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
417 }
c3fc2621 418
e501603b 419}