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