DAOs with singular/plural options for entity titles
[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
7b66c3b5 9 * (GenCodeChecksum:2039aecf7902bf0fda7f91081778b1c8)
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.
7b66c3b5
AH
132 *
133 * @param bool $plural
134 * Whether to return the plural version of the title.
449c4e6b 135 */
7b66c3b5
AH
136 public static function getEntityTitle($plural = FALSE) {
137 return $plural ? ts('PCPBlocks') : ts('PCPBlock');
449c4e6b
CW
138 }
139
e501603b 140 /**
f41f0342 141 * Returns foreign keys and entity references.
e501603b
TO
142 *
143 * @return array
144 * [CRM_Core_Reference_Interface]
145 */
c3fc2621 146 public static function getReferenceColumns() {
346aaaba 147 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 148 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621
CW
149 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'supporter_profile_id', 'civicrm_uf_group', 'id');
150 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
151 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'target_entity_id', NULL, 'id', 'target_entity_type');
346aaaba 152 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 153 }
346aaaba 154 return Civi::$statics[__CLASS__]['links'];
e501603b 155 }
c3fc2621 156
e501603b
TO
157 /**
158 * Returns all the column names of this table
159 *
160 * @return array
161 */
c3fc2621 162 public static function &fields() {
346aaaba 163 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
164 Civi::$statics[__CLASS__]['fields'] = [
165 'id' => [
e501603b
TO
166 'name' => 'id',
167 'type' => CRM_Utils_Type::T_INT,
c3fc2621 168 'title' => ts('PCP Block ID'),
215b423e 169 'description' => ts('PCP block Id'),
c3fc2621 170 'required' => TRUE,
a36434b9 171 'where' => 'civicrm_pcp_block.id',
522a26c9 172 'table_name' => 'civicrm_pcp_block',
173 'entity' => 'PCPBlock',
174 'bao' => 'CRM_PCP_BAO_PCPBlock',
6a7e5e5d 175 'localizable' => 0,
a9d0587b 176 'add' => '2.2',
c3fc2621
CW
177 ],
178 'entity_table' => [
e501603b
TO
179 'name' => 'entity_table',
180 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 181 'title' => ts('Entity Table'),
e501603b
TO
182 'maxlength' => 64,
183 'size' => CRM_Utils_Type::BIG,
a36434b9 184 'where' => 'civicrm_pcp_block.entity_table',
522a26c9 185 'table_name' => 'civicrm_pcp_block',
186 'entity' => 'PCPBlock',
187 'bao' => 'CRM_PCP_BAO_PCPBlock',
6a7e5e5d 188 'localizable' => 0,
a9d0587b 189 'add' => '2.2',
c3fc2621
CW
190 ],
191 'entity_id' => [
e501603b
TO
192 'name' => 'entity_id',
193 'type' => CRM_Utils_Type::T_INT,
c3fc2621 194 'title' => ts('Entity'),
215b423e 195 'description' => ts('FK to civicrm_contribution_page.id OR civicrm_event.id'),
c3fc2621 196 'required' => TRUE,
a36434b9 197 'where' => 'civicrm_pcp_block.entity_id',
522a26c9 198 'table_name' => 'civicrm_pcp_block',
199 'entity' => 'PCPBlock',
200 'bao' => 'CRM_PCP_BAO_PCPBlock',
6a7e5e5d 201 'localizable' => 0,
a9d0587b 202 'add' => '2.2',
c3fc2621
CW
203 ],
204 'target_entity_type' => [
e501603b
TO
205 'name' => 'target_entity_type',
206 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 207 'title' => ts('Target Entity'),
215b423e 208 'description' => ts('The type of entity that this pcp targets'),
c3fc2621 209 'required' => TRUE,
e501603b
TO
210 'maxlength' => 255,
211 'size' => CRM_Utils_Type::HUGE,
a36434b9 212 'where' => 'civicrm_pcp_block.target_entity_type',
e501603b 213 'default' => 'contribute',
522a26c9 214 'table_name' => 'civicrm_pcp_block',
215 'entity' => 'PCPBlock',
216 'bao' => 'CRM_PCP_BAO_PCPBlock',
6a7e5e5d 217 'localizable' => 0,
a9d0587b 218 'add' => '4.1',
c3fc2621
CW
219 ],
220 'target_entity_id' => [
e501603b
TO
221 'name' => 'target_entity_id',
222 'type' => CRM_Utils_Type::T_INT,
c3fc2621 223 'title' => ts('Target Entity ID'),
215b423e 224 'description' => ts('The entity that this pcp targets'),
c3fc2621 225 'required' => TRUE,
a36434b9 226 'where' => 'civicrm_pcp_block.target_entity_id',
522a26c9 227 'table_name' => 'civicrm_pcp_block',
228 'entity' => 'PCPBlock',
229 'bao' => 'CRM_PCP_BAO_PCPBlock',
6a7e5e5d 230 'localizable' => 0,
a9d0587b 231 'add' => '4.1',
c3fc2621
CW
232 ],
233 'supporter_profile_id' => [
e501603b
TO
234 'name' => 'supporter_profile_id',
235 'type' => CRM_Utils_Type::T_INT,
c3fc2621 236 'title' => ts('Supporter Profile'),
215b423e 237 'description' => ts('FK to civicrm_uf_group.id. Does Personal Campaign Page require manual activation by administrator? (is inactive by default after setup)?'),
a36434b9 238 'where' => 'civicrm_pcp_block.supporter_profile_id',
e501603b 239 'default' => 'NULL',
522a26c9 240 'table_name' => 'civicrm_pcp_block',
241 'entity' => 'PCPBlock',
242 'bao' => 'CRM_PCP_BAO_PCPBlock',
6a7e5e5d 243 'localizable' => 0,
e501603b 244 'FKClassName' => 'CRM_Core_DAO_UFGroup',
a9d0587b 245 'add' => '2.2',
c3fc2621
CW
246 ],
247 'owner_notify_id' => [
e501603b
TO
248 'name' => 'owner_notify_id',
249 'type' => CRM_Utils_Type::T_INT,
c3fc2621 250 'title' => ts('Owner Notification'),
215b423e 251 'description' => ts('FK to civicrm_option_group with name = PCP owner notifications'),
a36434b9 252 'where' => 'civicrm_pcp_block.owner_notify_id',
45a83e42 253 'default' => '0',
522a26c9 254 'table_name' => 'civicrm_pcp_block',
255 'entity' => 'PCPBlock',
256 'bao' => 'CRM_PCP_BAO_PCPBlock',
6a7e5e5d 257 'localizable' => 0,
c3fc2621 258 'html' => [
e501603b 259 'type' => 'Radio',
c3fc2621
CW
260 ],
261 'pseudoconstant' => [
e501603b
TO
262 'optionGroupName' => 'pcp_owner_notify',
263 'optionEditPath' => 'civicrm/admin/options/pcp_owner_notify',
e6ca0a57 264 ],
a9d0587b 265 'add' => '4.6',
c3fc2621
CW
266 ],
267 'is_approval_needed' => [
e501603b
TO
268 'name' => 'is_approval_needed',
269 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 270 'title' => ts('Approval Required?'),
215b423e 271 'description' => ts('Does Personal Campaign Page require manual activation by administrator? (is inactive by default after setup)?'),
a36434b9 272 'where' => 'civicrm_pcp_block.is_approval_needed',
e501603b 273 'default' => 'NULL',
522a26c9 274 'table_name' => 'civicrm_pcp_block',
275 'entity' => 'PCPBlock',
276 'bao' => 'CRM_PCP_BAO_PCPBlock',
6a7e5e5d 277 'localizable' => 0,
a9d0587b 278 'add' => '2.2',
c3fc2621
CW
279 ],
280 'is_tellfriend_enabled' => [
e501603b
TO
281 'name' => 'is_tellfriend_enabled',
282 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 283 'title' => ts('Tell a Friend Enabled?'),
215b423e 284 'description' => ts('Does Personal Campaign Page allow using tell a friend?'),
a36434b9 285 'where' => 'civicrm_pcp_block.is_tellfriend_enabled',
e501603b 286 'default' => 'NULL',
522a26c9 287 'table_name' => 'civicrm_pcp_block',
288 'entity' => 'PCPBlock',
289 'bao' => 'CRM_PCP_BAO_PCPBlock',
6a7e5e5d 290 'localizable' => 0,
a9d0587b 291 'add' => '2.2',
c3fc2621
CW
292 ],
293 'tellfriend_limit' => [
e501603b
TO
294 'name' => 'tellfriend_limit',
295 'type' => CRM_Utils_Type::T_INT,
c3fc2621 296 'title' => ts('Tell A Friend Limit'),
215b423e 297 'description' => ts('Maximum recipient fields allowed in tell a friend'),
a36434b9 298 'where' => 'civicrm_pcp_block.tellfriend_limit',
e501603b 299 'default' => 'NULL',
522a26c9 300 'table_name' => 'civicrm_pcp_block',
301 'entity' => 'PCPBlock',
302 'bao' => 'CRM_PCP_BAO_PCPBlock',
6a7e5e5d 303 'localizable' => 0,
a9d0587b 304 'add' => '2.2',
c3fc2621
CW
305 ],
306 'link_text' => [
e501603b
TO
307 'name' => 'link_text',
308 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 309 'title' => ts('Link Text'),
215b423e 310 'description' => ts('Link text for PCP.'),
e501603b
TO
311 'maxlength' => 255,
312 'size' => CRM_Utils_Type::HUGE,
a36434b9 313 'where' => 'civicrm_pcp_block.link_text',
e501603b 314 'default' => 'NULL',
522a26c9 315 'table_name' => 'civicrm_pcp_block',
316 'entity' => 'PCPBlock',
317 'bao' => 'CRM_PCP_BAO_PCPBlock',
6a7e5e5d 318 'localizable' => 1,
a9d0587b 319 'add' => '2.2',
c3fc2621
CW
320 ],
321 'is_active' => [
e501603b
TO
322 'name' => 'is_active',
323 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 324 'title' => ts('Enabled?'),
215b423e 325 'description' => ts('Is Personal Campaign Page Block enabled/active?'),
a36434b9 326 'where' => 'civicrm_pcp_block.is_active',
e501603b 327 'default' => '1',
522a26c9 328 'table_name' => 'civicrm_pcp_block',
329 'entity' => 'PCPBlock',
330 'bao' => 'CRM_PCP_BAO_PCPBlock',
6a7e5e5d 331 'localizable' => 0,
a9d0587b 332 'add' => '2.2',
c3fc2621
CW
333 ],
334 'notify_email' => [
e501603b
TO
335 'name' => 'notify_email',
336 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 337 'title' => ts('Notification Email'),
215b423e 338 'description' => ts('If set, notification is automatically emailed to this email-address on create/update Personal Campaign Page'),
e501603b
TO
339 'maxlength' => 255,
340 'size' => CRM_Utils_Type::HUGE,
a36434b9 341 'where' => 'civicrm_pcp_block.notify_email',
e501603b 342 'default' => 'NULL',
522a26c9 343 'table_name' => 'civicrm_pcp_block',
344 'entity' => 'PCPBlock',
345 'bao' => 'CRM_PCP_BAO_PCPBlock',
6a7e5e5d 346 'localizable' => 0,
a9d0587b 347 'add' => '2.2',
c3fc2621
CW
348 ],
349 ];
346aaaba 350 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 351 }
346aaaba 352 return Civi::$statics[__CLASS__]['fields'];
e501603b 353 }
c3fc2621 354
e501603b 355 /**
bd8e0b14 356 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
357 *
358 * @return array
bd8e0b14 359 * Array(string $name => string $uniqueName).
e501603b 360 */
c3fc2621 361 public static function &fieldKeys() {
bd8e0b14
TO
362 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
363 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 364 }
bd8e0b14 365 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 366 }
c3fc2621 367
e501603b
TO
368 /**
369 * Returns the names of this table
370 *
371 * @return string
372 */
c3fc2621 373 public static function getTableName() {
e501603b
TO
374 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
375 }
c3fc2621 376
e501603b
TO
377 /**
378 * Returns if this table needs to be logged
379 *
c3fc2621 380 * @return bool
e501603b 381 */
c3fc2621 382 public function getLog() {
e501603b
TO
383 return self::$_log;
384 }
c3fc2621 385
e501603b
TO
386 /**
387 * Returns the list of fields that can be imported
388 *
389 * @param bool $prefix
390 *
391 * @return array
392 */
c3fc2621
CW
393 public static function &import($prefix = FALSE) {
394 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'pcp_block', $prefix, []);
60808919 395 return $r;
e501603b 396 }
c3fc2621 397
e501603b
TO
398 /**
399 * Returns the list of fields that can be exported
400 *
401 * @param bool $prefix
402 *
403 * @return array
404 */
c3fc2621
CW
405 public static function &export($prefix = FALSE) {
406 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'pcp_block', $prefix, []);
60808919 407 return $r;
e501603b 408 }
c3fc2621 409
e7a6b91a
AS
410 /**
411 * Returns the list of indices
c3fc2621
CW
412 *
413 * @param bool $localize
414 *
415 * @return array
e7a6b91a
AS
416 */
417 public static function indices($localize = TRUE) {
c3fc2621 418 $indices = [];
e7a6b91a
AS
419 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
420 }
c3fc2621 421
e501603b 422}