Merge pull request #17513 from JMAConsulting/core-1795
[civicrm-core.git] / CRM / Mailing / DAO / MailingAB.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Mailing/MailingAB.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:81b75b4631b20b4bf2b7ab0bf1a0f286)
10 */
11
12 /**
13 * Database access object for the MailingAB entity.
14 */
15 class CRM_Mailing_DAO_MailingAB extends CRM_Core_DAO {
16
17 /**
18 * Static instance to hold the table name.
19 *
20 * @var string
21 */
22 public static $_tableName = 'civicrm_mailing_abtest';
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 = FALSE;
30
31 /**
32 * @var int
33 */
34 public $id;
35
36 /**
37 * Name of the A/B test
38 *
39 * @var string
40 */
41 public $name;
42
43 /**
44 * Status
45 *
46 * @var string
47 */
48 public $status;
49
50 /**
51 * The first experimental mailing ("A" condition)
52 *
53 * @var int
54 */
55 public $mailing_id_a;
56
57 /**
58 * The second experimental mailing ("B" condition)
59 *
60 * @var int
61 */
62 public $mailing_id_b;
63
64 /**
65 * The final, general mailing (derived from A or B)
66 *
67 * @var int
68 */
69 public $mailing_id_c;
70
71 /**
72 * Which site is this mailing for
73 *
74 * @var int
75 */
76 public $domain_id;
77
78 /**
79 * @var string
80 */
81 public $testing_criteria;
82
83 /**
84 * @var string
85 */
86 public $winner_criteria;
87
88 /**
89 * What specific url to track
90 *
91 * @var string
92 */
93 public $specific_url;
94
95 /**
96 * In how much time to declare winner
97 *
98 * @var datetime
99 */
100 public $declare_winning_time;
101
102 /**
103 * @var int
104 */
105 public $group_percentage;
106
107 /**
108 * FK to Contact ID
109 *
110 * @var int
111 */
112 public $created_id;
113
114 /**
115 * When was this item created
116 *
117 * @var timestamp
118 */
119 public $created_date;
120
121 /**
122 * Class constructor.
123 */
124 public function __construct() {
125 $this->__table = 'civicrm_mailing_abtest';
126 parent::__construct();
127 }
128
129 /**
130 * Returns localized title of this entity.
131 */
132 public static function getEntityTitle() {
133 return ts('Mailing ABs');
134 }
135
136 /**
137 * Returns foreign keys and entity references.
138 *
139 * @return array
140 * [CRM_Core_Reference_Interface]
141 */
142 public static function getReferenceColumns() {
143 if (!isset(Civi::$statics[__CLASS__]['links'])) {
144 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
145 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id');
146 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
147 }
148 return Civi::$statics[__CLASS__]['links'];
149 }
150
151 /**
152 * Returns all the column names of this table
153 *
154 * @return array
155 */
156 public static function &fields() {
157 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
158 Civi::$statics[__CLASS__]['fields'] = [
159 'id' => [
160 'name' => 'id',
161 'type' => CRM_Utils_Type::T_INT,
162 'title' => ts('MailingAB ID'),
163 'required' => TRUE,
164 'where' => 'civicrm_mailing_abtest.id',
165 'table_name' => 'civicrm_mailing_abtest',
166 'entity' => 'MailingAB',
167 'bao' => 'CRM_Mailing_BAO_MailingAB',
168 'localizable' => 0,
169 'add' => NULL,
170 ],
171 'name' => [
172 'name' => 'name',
173 'type' => CRM_Utils_Type::T_STRING,
174 'title' => ts('Name'),
175 'description' => ts('Name of the A/B test'),
176 'maxlength' => 128,
177 'size' => CRM_Utils_Type::HUGE,
178 'where' => 'civicrm_mailing_abtest.name',
179 'table_name' => 'civicrm_mailing_abtest',
180 'entity' => 'MailingAB',
181 'bao' => 'CRM_Mailing_BAO_MailingAB',
182 'localizable' => 0,
183 'add' => '4.6',
184 ],
185 'status' => [
186 'name' => 'status',
187 'type' => CRM_Utils_Type::T_STRING,
188 'title' => ts('Status'),
189 'description' => ts('Status'),
190 'maxlength' => 32,
191 'size' => CRM_Utils_Type::MEDIUM,
192 'where' => 'civicrm_mailing_abtest.status',
193 'table_name' => 'civicrm_mailing_abtest',
194 'entity' => 'MailingAB',
195 'bao' => 'CRM_Mailing_BAO_MailingAB',
196 'localizable' => 0,
197 'pseudoconstant' => [
198 'callback' => 'CRM_Mailing_PseudoConstant::abStatus',
199 ],
200 'add' => '4.6',
201 ],
202 'mailing_id_a' => [
203 'name' => 'mailing_id_a',
204 'type' => CRM_Utils_Type::T_INT,
205 'title' => ts('Mailing ID (A)'),
206 'description' => ts('The first experimental mailing ("A" condition)'),
207 'where' => 'civicrm_mailing_abtest.mailing_id_a',
208 'table_name' => 'civicrm_mailing_abtest',
209 'entity' => 'MailingAB',
210 'bao' => 'CRM_Mailing_BAO_MailingAB',
211 'localizable' => 0,
212 'add' => '4.6',
213 ],
214 'mailing_id_b' => [
215 'name' => 'mailing_id_b',
216 'type' => CRM_Utils_Type::T_INT,
217 'title' => ts('Mailing ID (B)'),
218 'description' => ts('The second experimental mailing ("B" condition)'),
219 'where' => 'civicrm_mailing_abtest.mailing_id_b',
220 'table_name' => 'civicrm_mailing_abtest',
221 'entity' => 'MailingAB',
222 'bao' => 'CRM_Mailing_BAO_MailingAB',
223 'localizable' => 0,
224 'add' => '4.6',
225 ],
226 'mailing_id_c' => [
227 'name' => 'mailing_id_c',
228 'type' => CRM_Utils_Type::T_INT,
229 'title' => ts('Mailing ID (C)'),
230 'description' => ts('The final, general mailing (derived from A or B)'),
231 'where' => 'civicrm_mailing_abtest.mailing_id_c',
232 'table_name' => 'civicrm_mailing_abtest',
233 'entity' => 'MailingAB',
234 'bao' => 'CRM_Mailing_BAO_MailingAB',
235 'localizable' => 0,
236 'add' => '4.6',
237 ],
238 'domain_id' => [
239 'name' => 'domain_id',
240 'type' => CRM_Utils_Type::T_INT,
241 'title' => ts('Domain ID'),
242 'description' => ts('Which site is this mailing for'),
243 'required' => TRUE,
244 'where' => 'civicrm_mailing_abtest.domain_id',
245 'table_name' => 'civicrm_mailing_abtest',
246 'entity' => 'MailingAB',
247 'bao' => 'CRM_Mailing_BAO_MailingAB',
248 'localizable' => 0,
249 'add' => '4.6',
250 ],
251 'testing_criteria' => [
252 'name' => 'testing_criteria',
253 'type' => CRM_Utils_Type::T_STRING,
254 'title' => ts('Testing Criteria'),
255 'maxlength' => 32,
256 'size' => CRM_Utils_Type::MEDIUM,
257 'where' => 'civicrm_mailing_abtest.testing_criteria',
258 'table_name' => 'civicrm_mailing_abtest',
259 'entity' => 'MailingAB',
260 'bao' => 'CRM_Mailing_BAO_MailingAB',
261 'localizable' => 0,
262 'pseudoconstant' => [
263 'callback' => 'CRM_Mailing_PseudoConstant::abTestCriteria',
264 ],
265 'add' => '4.6',
266 ],
267 'winner_criteria' => [
268 'name' => 'winner_criteria',
269 'type' => CRM_Utils_Type::T_STRING,
270 'title' => ts('Winner Criteria'),
271 'maxlength' => 32,
272 'size' => CRM_Utils_Type::MEDIUM,
273 'where' => 'civicrm_mailing_abtest.winner_criteria',
274 'table_name' => 'civicrm_mailing_abtest',
275 'entity' => 'MailingAB',
276 'bao' => 'CRM_Mailing_BAO_MailingAB',
277 'localizable' => 0,
278 'pseudoconstant' => [
279 'callback' => 'CRM_Mailing_PseudoConstant::abWinnerCriteria',
280 ],
281 'add' => '4.6',
282 ],
283 'specific_url' => [
284 'name' => 'specific_url',
285 'type' => CRM_Utils_Type::T_STRING,
286 'title' => ts('URL for Winner Criteria'),
287 'description' => ts('What specific url to track'),
288 'maxlength' => 255,
289 'size' => CRM_Utils_Type::HUGE,
290 'where' => 'civicrm_mailing_abtest.specific_url',
291 'table_name' => 'civicrm_mailing_abtest',
292 'entity' => 'MailingAB',
293 'bao' => 'CRM_Mailing_BAO_MailingAB',
294 'localizable' => 0,
295 'add' => '4.6',
296 ],
297 'declare_winning_time' => [
298 'name' => 'declare_winning_time',
299 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
300 'title' => ts('Declaration Time'),
301 'description' => ts('In how much time to declare winner'),
302 'where' => 'civicrm_mailing_abtest.declare_winning_time',
303 'table_name' => 'civicrm_mailing_abtest',
304 'entity' => 'MailingAB',
305 'bao' => 'CRM_Mailing_BAO_MailingAB',
306 'localizable' => 0,
307 'add' => '4.6',
308 ],
309 'group_percentage' => [
310 'name' => 'group_percentage',
311 'type' => CRM_Utils_Type::T_INT,
312 'title' => ts('Group Percentage'),
313 'where' => 'civicrm_mailing_abtest.group_percentage',
314 'table_name' => 'civicrm_mailing_abtest',
315 'entity' => 'MailingAB',
316 'bao' => 'CRM_Mailing_BAO_MailingAB',
317 'localizable' => 0,
318 'add' => '4.6',
319 ],
320 'created_id' => [
321 'name' => 'created_id',
322 'type' => CRM_Utils_Type::T_INT,
323 'title' => ts('AB Test Created By'),
324 'description' => ts('FK to Contact ID'),
325 'where' => 'civicrm_mailing_abtest.created_id',
326 'table_name' => 'civicrm_mailing_abtest',
327 'entity' => 'MailingAB',
328 'bao' => 'CRM_Mailing_BAO_MailingAB',
329 'localizable' => 0,
330 'FKClassName' => 'CRM_Contact_DAO_Contact',
331 'add' => '4.6',
332 ],
333 'created_date' => [
334 'name' => 'created_date',
335 'type' => CRM_Utils_Type::T_TIMESTAMP,
336 'title' => ts('AB Test Created Date'),
337 'description' => ts('When was this item created'),
338 'required' => FALSE,
339 'where' => 'civicrm_mailing_abtest.created_date',
340 'default' => 'CURRENT_TIMESTAMP',
341 'table_name' => 'civicrm_mailing_abtest',
342 'entity' => 'MailingAB',
343 'bao' => 'CRM_Mailing_BAO_MailingAB',
344 'localizable' => 0,
345 'html' => [
346 'type' => 'Select Date',
347 ],
348 'add' => '4.6',
349 ],
350 ];
351 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
352 }
353 return Civi::$statics[__CLASS__]['fields'];
354 }
355
356 /**
357 * Return a mapping from field-name to the corresponding key (as used in fields()).
358 *
359 * @return array
360 * Array(string $name => string $uniqueName).
361 */
362 public static function &fieldKeys() {
363 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
364 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
365 }
366 return Civi::$statics[__CLASS__]['fieldKeys'];
367 }
368
369 /**
370 * Returns the names of this table
371 *
372 * @return string
373 */
374 public static function getTableName() {
375 return self::$_tableName;
376 }
377
378 /**
379 * Returns if this table needs to be logged
380 *
381 * @return bool
382 */
383 public function getLog() {
384 return self::$_log;
385 }
386
387 /**
388 * Returns the list of fields that can be imported
389 *
390 * @param bool $prefix
391 *
392 * @return array
393 */
394 public static function &import($prefix = FALSE) {
395 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'mailing_abtest', $prefix, []);
396 return $r;
397 }
398
399 /**
400 * Returns the list of fields that can be exported
401 *
402 * @param bool $prefix
403 *
404 * @return array
405 */
406 public static function &export($prefix = FALSE) {
407 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'mailing_abtest', $prefix, []);
408 return $r;
409 }
410
411 /**
412 * Returns the list of indices
413 *
414 * @param bool $localize
415 *
416 * @return array
417 */
418 public static function indices($localize = TRUE) {
419 $indices = [];
420 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
421 }
422
423 }