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