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