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