Add function Core_Component::isEnabled
[civicrm-core.git] / CRM / Contribute / DAO / Premium.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/Contribute/Premium.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
2562d09a 9 * (GenCodeChecksum:7ea059e7d6ccfe258964ab274089ac60)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the Premium entity.
f41f0342 14 */
e501603b 15class CRM_Contribute_DAO_Premium extends CRM_Core_DAO {
929a1c14
CW
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.4';
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_premiums';
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 34 /**
e6ca0a57 35 * @var int
e501603b
TO
36 */
37 public $id;
c3fc2621 38
e501603b
TO
39 /**
40 * Joins these premium settings to another object. Always civicrm_contribution_page for now.
41 *
42 * @var string
43 */
44 public $entity_table;
c3fc2621 45
e501603b 46 /**
e6ca0a57 47 * @var int
e501603b
TO
48 */
49 public $entity_id;
c3fc2621 50
e501603b
TO
51 /**
52 * Is the Premiums feature enabled for this page?
53 *
e6ca0a57 54 * @var bool
e501603b
TO
55 */
56 public $premiums_active;
c3fc2621 57
e501603b
TO
58 /**
59 * Title for Premiums section.
60 *
61 * @var string
62 */
63 public $premiums_intro_title;
c3fc2621 64
e501603b
TO
65 /**
66 * Displayed in <div> at top of Premiums section of page. Text and HTML allowed.
67 *
68 * @var text
69 */
70 public $premiums_intro_text;
c3fc2621 71
e501603b
TO
72 /**
73 * This email address is included in receipts if it is populated and a premium has been selected.
74 *
75 * @var string
76 */
77 public $premiums_contact_email;
c3fc2621 78
e501603b
TO
79 /**
80 * This phone number is included in receipts if it is populated and a premium has been selected.
81 *
82 * @var string
83 */
84 public $premiums_contact_phone;
c3fc2621 85
e501603b
TO
86 /**
87 * Boolean. Should we automatically display minimum contribution amount text after the premium descriptions.
88 *
e6ca0a57 89 * @var bool
e501603b
TO
90 */
91 public $premiums_display_min_contribution;
c3fc2621 92
e501603b
TO
93 /**
94 * Label displayed for No Thank-you option in premiums block (e.g. No thank you)
95 *
96 * @var string
97 */
98 public $premiums_nothankyou_label;
c3fc2621 99
e501603b 100 /**
e6ca0a57 101 * @var int
e501603b
TO
102 */
103 public $premiums_nothankyou_position;
c3fc2621 104
e501603b 105 /**
f41f0342 106 * Class constructor.
e501603b 107 */
c3fc2621 108 public function __construct() {
e501603b
TO
109 $this->__table = 'civicrm_premiums';
110 parent::__construct();
111 }
c3fc2621 112
449c4e6b
CW
113 /**
114 * Returns localized title of this entity.
7b66c3b5
AH
115 *
116 * @param bool $plural
117 * Whether to return the plural version of the title.
449c4e6b 118 */
7b66c3b5
AH
119 public static function getEntityTitle($plural = FALSE) {
120 return $plural ? ts('Premiums') : ts('Premium');
449c4e6b
CW
121 }
122
e501603b 123 /**
f41f0342 124 * Returns foreign keys and entity references.
e501603b
TO
125 *
126 * @return array
127 * [CRM_Core_Reference_Interface]
128 */
c3fc2621 129 public static function getReferenceColumns() {
346aaaba 130 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 131 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621 132 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
346aaaba 133 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 134 }
346aaaba 135 return Civi::$statics[__CLASS__]['links'];
e501603b 136 }
c3fc2621 137
e501603b
TO
138 /**
139 * Returns all the column names of this table
140 *
141 * @return array
142 */
c3fc2621 143 public static function &fields() {
346aaaba 144 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
145 Civi::$statics[__CLASS__]['fields'] = [
146 'id' => [
e501603b
TO
147 'name' => 'id',
148 'type' => CRM_Utils_Type::T_INT,
c3fc2621
CW
149 'title' => ts('Premium ID'),
150 'required' => TRUE,
a36434b9 151 'where' => 'civicrm_premiums.id',
522a26c9 152 'table_name' => 'civicrm_premiums',
153 'entity' => 'Premium',
154 'bao' => 'CRM_Contribute_BAO_Premium',
6a7e5e5d 155 'localizable' => 0,
2cbbebe8
A
156 'html' => [
157 'type' => 'Number',
158 ],
1fe423d6 159 'readonly' => TRUE,
a9d0587b 160 'add' => '1.4',
c3fc2621
CW
161 ],
162 'entity_table' => [
e501603b
TO
163 'name' => 'entity_table',
164 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 165 'title' => ts('Premium Entity'),
215b423e 166 'description' => ts('Joins these premium settings to another object. Always civicrm_contribution_page for now.'),
c3fc2621 167 'required' => TRUE,
e501603b
TO
168 'maxlength' => 64,
169 'size' => CRM_Utils_Type::BIG,
a36434b9 170 'where' => 'civicrm_premiums.entity_table',
522a26c9 171 'table_name' => 'civicrm_premiums',
172 'entity' => 'Premium',
173 'bao' => 'CRM_Contribute_BAO_Premium',
6a7e5e5d 174 'localizable' => 0,
a9d0587b 175 'add' => '1.4',
c3fc2621
CW
176 ],
177 'entity_id' => [
e501603b
TO
178 'name' => 'entity_id',
179 'type' => CRM_Utils_Type::T_INT,
c3fc2621
CW
180 'title' => ts('Premium entity ID'),
181 'required' => TRUE,
a36434b9 182 'where' => 'civicrm_premiums.entity_id',
522a26c9 183 'table_name' => 'civicrm_premiums',
184 'entity' => 'Premium',
185 'bao' => 'CRM_Contribute_BAO_Premium',
6a7e5e5d 186 'localizable' => 0,
a9d0587b 187 'add' => '1.4',
c3fc2621
CW
188 ],
189 'premiums_active' => [
e501603b
TO
190 'name' => 'premiums_active',
191 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 192 'title' => ts('Is Premium Active?'),
215b423e 193 'description' => ts('Is the Premiums feature enabled for this page?'),
c3fc2621 194 'required' => TRUE,
a36434b9 195 'where' => 'civicrm_premiums.premiums_active',
45a83e42 196 'default' => '0',
522a26c9 197 'table_name' => 'civicrm_premiums',
198 'entity' => 'Premium',
199 'bao' => 'CRM_Contribute_BAO_Premium',
6a7e5e5d 200 'localizable' => 0,
a9d0587b 201 'add' => '1.4',
c3fc2621
CW
202 ],
203 'premiums_intro_title' => [
e501603b
TO
204 'name' => 'premiums_intro_title',
205 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 206 'title' => ts('Title for Premiums section'),
215b423e 207 'description' => ts('Title for Premiums section.'),
e501603b
TO
208 'maxlength' => 255,
209 'size' => CRM_Utils_Type::HUGE,
a36434b9 210 'where' => 'civicrm_premiums.premiums_intro_title',
522a26c9 211 'table_name' => 'civicrm_premiums',
212 'entity' => 'Premium',
213 'bao' => 'CRM_Contribute_BAO_Premium',
6a7e5e5d 214 'localizable' => 1,
a9d0587b 215 'add' => '1.4',
c3fc2621
CW
216 ],
217 'premiums_intro_text' => [
e501603b
TO
218 'name' => 'premiums_intro_text',
219 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 220 'title' => ts('Premium Introductory Text'),
215b423e 221 'description' => ts('Displayed in <div> at top of Premiums section of page. Text and HTML allowed.'),
a36434b9 222 'where' => 'civicrm_premiums.premiums_intro_text',
522a26c9 223 'table_name' => 'civicrm_premiums',
224 'entity' => 'Premium',
225 'bao' => 'CRM_Contribute_BAO_Premium',
6a7e5e5d 226 'localizable' => 1,
a9d0587b 227 'add' => '1.4',
c3fc2621
CW
228 ],
229 'premiums_contact_email' => [
e501603b
TO
230 'name' => 'premiums_contact_email',
231 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 232 'title' => ts('Premium Contact Email'),
215b423e 233 'description' => ts('This email address is included in receipts if it is populated and a premium has been selected.'),
e501603b
TO
234 'maxlength' => 100,
235 'size' => CRM_Utils_Type::HUGE,
a36434b9 236 'where' => 'civicrm_premiums.premiums_contact_email',
522a26c9 237 'table_name' => 'civicrm_premiums',
238 'entity' => 'Premium',
239 'bao' => 'CRM_Contribute_BAO_Premium',
6a7e5e5d 240 'localizable' => 0,
a9d0587b 241 'add' => '1.4',
c3fc2621
CW
242 ],
243 'premiums_contact_phone' => [
e501603b
TO
244 'name' => 'premiums_contact_phone',
245 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 246 'title' => ts('Premiums Contact Phone'),
215b423e 247 'description' => ts('This phone number is included in receipts if it is populated and a premium has been selected.'),
e501603b
TO
248 'maxlength' => 50,
249 'size' => CRM_Utils_Type::BIG,
a36434b9 250 'where' => 'civicrm_premiums.premiums_contact_phone',
522a26c9 251 'table_name' => 'civicrm_premiums',
252 'entity' => 'Premium',
253 'bao' => 'CRM_Contribute_BAO_Premium',
6a7e5e5d 254 'localizable' => 0,
a9d0587b 255 'add' => '1.4',
c3fc2621
CW
256 ],
257 'premiums_display_min_contribution' => [
e501603b
TO
258 'name' => 'premiums_display_min_contribution',
259 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 260 'title' => ts('Display Minimum Contribution?'),
215b423e 261 'description' => ts('Boolean. Should we automatically display minimum contribution amount text after the premium descriptions.'),
c3fc2621 262 'required' => TRUE,
a36434b9 263 'where' => 'civicrm_premiums.premiums_display_min_contribution',
522a26c9 264 'table_name' => 'civicrm_premiums',
265 'entity' => 'Premium',
266 'bao' => 'CRM_Contribute_BAO_Premium',
6a7e5e5d 267 'localizable' => 0,
a9d0587b 268 'add' => '1.4',
c3fc2621
CW
269 ],
270 'premiums_nothankyou_label' => [
e501603b
TO
271 'name' => 'premiums_nothankyou_label',
272 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 273 'title' => ts('No Thank-you Text'),
215b423e 274 'description' => ts('Label displayed for No Thank-you option in premiums block (e.g. No thank you)'),
e501603b
TO
275 'maxlength' => 255,
276 'size' => CRM_Utils_Type::HUGE,
a36434b9 277 'where' => 'civicrm_premiums.premiums_nothankyou_label',
522a26c9 278 'table_name' => 'civicrm_premiums',
279 'entity' => 'Premium',
280 'bao' => 'CRM_Contribute_BAO_Premium',
6a7e5e5d 281 'localizable' => 1,
a9d0587b 282 'add' => '4.3',
c3fc2621
CW
283 ],
284 'premiums_nothankyou_position' => [
e501603b
TO
285 'name' => 'premiums_nothankyou_position',
286 'type' => CRM_Utils_Type::T_INT,
c3fc2621 287 'title' => ts('No Thank-you Position'),
a36434b9 288 'where' => 'civicrm_premiums.premiums_nothankyou_position',
e501603b 289 'default' => '1',
522a26c9 290 'table_name' => 'civicrm_premiums',
291 'entity' => 'Premium',
292 'bao' => 'CRM_Contribute_BAO_Premium',
6a7e5e5d 293 'localizable' => 0,
a9d0587b 294 'add' => '4.3',
c3fc2621
CW
295 ],
296 ];
346aaaba 297 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 298 }
346aaaba 299 return Civi::$statics[__CLASS__]['fields'];
e501603b 300 }
c3fc2621 301
e501603b 302 /**
bd8e0b14 303 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
304 *
305 * @return array
bd8e0b14 306 * Array(string $name => string $uniqueName).
e501603b 307 */
c3fc2621 308 public static function &fieldKeys() {
bd8e0b14
TO
309 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
310 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 311 }
bd8e0b14 312 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 313 }
c3fc2621 314
e501603b
TO
315 /**
316 * Returns the names of this table
317 *
318 * @return string
319 */
c3fc2621 320 public static function getTableName() {
e501603b
TO
321 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
322 }
c3fc2621 323
e501603b
TO
324 /**
325 * Returns if this table needs to be logged
326 *
c3fc2621 327 * @return bool
e501603b 328 */
c3fc2621 329 public function getLog() {
e501603b
TO
330 return self::$_log;
331 }
c3fc2621 332
e501603b
TO
333 /**
334 * Returns the list of fields that can be imported
335 *
336 * @param bool $prefix
337 *
338 * @return array
339 */
c3fc2621
CW
340 public static function &import($prefix = FALSE) {
341 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'premiums', $prefix, []);
60808919 342 return $r;
e501603b 343 }
c3fc2621 344
e501603b
TO
345 /**
346 * Returns the list of fields that can be exported
347 *
348 * @param bool $prefix
349 *
350 * @return array
351 */
c3fc2621
CW
352 public static function &export($prefix = FALSE) {
353 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'premiums', $prefix, []);
60808919 354 return $r;
e501603b 355 }
c3fc2621 356
e7a6b91a
AS
357 /**
358 * Returns the list of indices
c3fc2621
CW
359 *
360 * @param bool $localize
361 *
362 * @return array
e7a6b91a
AS
363 */
364 public static function indices($localize = TRUE) {
c3fc2621 365 $indices = [];
e7a6b91a
AS
366 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
367 }
c3fc2621 368
e501603b 369}