DAOs with singular/plural options for entity titles
[civicrm-core.git] / CRM / Mailing / DAO / MailingJob.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/MailingJob.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
7b66c3b5 9 * (GenCodeChecksum:eb066e39ba2501608759e6ac3dfbcaaf)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the MailingJob entity.
f41f0342 14 */
e501603b 15class CRM_Mailing_DAO_MailingJob extends CRM_Core_DAO {
929a1c14
CW
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '';
c3fc2621 18
e501603b 19 /**
f41f0342 20 * Static instance to hold the table name.
e501603b
TO
21 *
22 * @var string
23 */
fa45b5b9 24 public static $_tableName = 'civicrm_mailing_job';
c3fc2621 25
e501603b 26 /**
f41f0342 27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b 28 *
c3fc2621 29 * @var bool
e501603b 30 */
fa45b5b9 31 public static $_log = FALSE;
c3fc2621 32
e501603b 33 /**
e6ca0a57 34 * @var int
e501603b
TO
35 */
36 public $id;
c3fc2621 37
e501603b
TO
38 /**
39 * The ID of the mailing this Job will send.
40 *
e6ca0a57 41 * @var int
e501603b
TO
42 */
43 public $mailing_id;
c3fc2621 44
e501603b
TO
45 /**
46 * date on which this job was scheduled.
47 *
6c2b97b7 48 * @var timestamp
e501603b
TO
49 */
50 public $scheduled_date;
c3fc2621 51
e501603b
TO
52 /**
53 * date on which this job was started.
54 *
6c2b97b7 55 * @var timestamp
e501603b
TO
56 */
57 public $start_date;
c3fc2621 58
e501603b
TO
59 /**
60 * date on which this job ended.
61 *
6c2b97b7 62 * @var timestamp
e501603b
TO
63 */
64 public $end_date;
c3fc2621 65
e501603b
TO
66 /**
67 * The state of this job
68 *
69 * @var string
70 */
71 public $status;
c3fc2621 72
e501603b
TO
73 /**
74 * Is this job for a test mail?
75 *
e6ca0a57 76 * @var bool
e501603b
TO
77 */
78 public $is_test;
c3fc2621 79
e501603b
TO
80 /**
81 * Type of mailling job: null | child
82 *
83 * @var string
84 */
85 public $job_type;
c3fc2621 86
e501603b
TO
87 /**
88 * Parent job id
89 *
e6ca0a57 90 * @var int
e501603b
TO
91 */
92 public $parent_id;
c3fc2621 93
e501603b
TO
94 /**
95 * Offset of the child job
96 *
97 * @var int
98 */
99 public $job_offset;
c3fc2621 100
e501603b
TO
101 /**
102 * Queue size limit for each child job
103 *
104 * @var int
105 */
106 public $job_limit;
c3fc2621 107
e501603b 108 /**
f41f0342 109 * Class constructor.
e501603b 110 */
c3fc2621 111 public function __construct() {
e501603b
TO
112 $this->__table = 'civicrm_mailing_job';
113 parent::__construct();
114 }
c3fc2621 115
449c4e6b
CW
116 /**
117 * Returns localized title of this entity.
7b66c3b5
AH
118 *
119 * @param bool $plural
120 * Whether to return the plural version of the title.
449c4e6b 121 */
7b66c3b5
AH
122 public static function getEntityTitle($plural = FALSE) {
123 return $plural ? ts('Mailing Jobs') : ts('Mailing Job');
449c4e6b
CW
124 }
125
e501603b 126 /**
f41f0342 127 * Returns foreign keys and entity references.
e501603b
TO
128 *
129 * @return array
130 * [CRM_Core_Reference_Interface]
131 */
c3fc2621 132 public static function getReferenceColumns() {
346aaaba 133 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 134 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621
CW
135 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'mailing_id', 'civicrm_mailing', 'id');
136 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'parent_id', 'civicrm_mailing_job', 'id');
346aaaba 137 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 138 }
346aaaba 139 return Civi::$statics[__CLASS__]['links'];
e501603b 140 }
c3fc2621 141
e501603b
TO
142 /**
143 * Returns all the column names of this table
144 *
145 * @return array
146 */
c3fc2621 147 public static function &fields() {
346aaaba 148 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
149 Civi::$statics[__CLASS__]['fields'] = [
150 'id' => [
e501603b
TO
151 'name' => 'id',
152 'type' => CRM_Utils_Type::T_INT,
c3fc2621
CW
153 'title' => ts('Mailing Job ID'),
154 'required' => TRUE,
a36434b9 155 'where' => 'civicrm_mailing_job.id',
522a26c9 156 'table_name' => 'civicrm_mailing_job',
157 'entity' => 'MailingJob',
158 'bao' => 'CRM_Mailing_BAO_MailingJob',
6a7e5e5d 159 'localizable' => 0,
a9d0587b 160 'add' => NULL,
c3fc2621
CW
161 ],
162 'mailing_id' => [
e501603b
TO
163 'name' => 'mailing_id',
164 'type' => CRM_Utils_Type::T_INT,
c3fc2621 165 'title' => ts('Mailing'),
215b423e 166 'description' => ts('The ID of the mailing this Job will send.'),
c3fc2621 167 'required' => TRUE,
a36434b9 168 'where' => 'civicrm_mailing_job.mailing_id',
522a26c9 169 'table_name' => 'civicrm_mailing_job',
170 'entity' => 'MailingJob',
171 'bao' => 'CRM_Mailing_BAO_MailingJob',
6a7e5e5d 172 'localizable' => 0,
e501603b 173 'FKClassName' => 'CRM_Mailing_DAO_Mailing',
a9d0587b 174 'add' => NULL,
c3fc2621
CW
175 ],
176 'scheduled_date' => [
e501603b 177 'name' => 'scheduled_date',
6c2b97b7 178 'type' => CRM_Utils_Type::T_TIMESTAMP,
c3fc2621 179 'title' => ts('Mailing Scheduled Date'),
215b423e 180 'description' => ts('date on which this job was scheduled.'),
c3fc2621 181 'required' => FALSE,
a36434b9 182 'where' => 'civicrm_mailing_job.scheduled_date',
6c2b97b7 183 'default' => 'NULL',
522a26c9 184 'table_name' => 'civicrm_mailing_job',
185 'entity' => 'MailingJob',
186 'bao' => 'CRM_Mailing_BAO_MailingJob',
6a7e5e5d 187 'localizable' => 0,
2c2c4aa4 188 'html' => [
189 'type' => 'Select Date',
190 'formatType' => 'activityDateTime',
191 ],
a9d0587b 192 'add' => NULL,
c3fc2621 193 ],
de866a86 194 'mailing_job_start_date' => [
e501603b 195 'name' => 'start_date',
6c2b97b7 196 'type' => CRM_Utils_Type::T_TIMESTAMP,
c3fc2621 197 'title' => ts('Mailing Job Start Date'),
215b423e 198 'description' => ts('date on which this job was started.'),
c3fc2621 199 'required' => FALSE,
a36434b9 200 'where' => 'civicrm_mailing_job.start_date',
6c2b97b7 201 'default' => 'NULL',
522a26c9 202 'table_name' => 'civicrm_mailing_job',
203 'entity' => 'MailingJob',
204 'bao' => 'CRM_Mailing_BAO_MailingJob',
6a7e5e5d 205 'localizable' => 0,
de866a86 206 'unique_title' => ts('Mailing Start Date'),
2c2c4aa4 207 'html' => [
208 'type' => 'Select Date',
209 'formatType' => 'activityDateTime',
210 ],
a9d0587b 211 'add' => NULL,
c3fc2621
CW
212 ],
213 'end_date' => [
e501603b 214 'name' => 'end_date',
6c2b97b7 215 'type' => CRM_Utils_Type::T_TIMESTAMP,
c3fc2621 216 'title' => ts('Mailing Job End Date'),
215b423e 217 'description' => ts('date on which this job ended.'),
c3fc2621 218 'required' => FALSE,
a36434b9 219 'where' => 'civicrm_mailing_job.end_date',
6c2b97b7 220 'default' => 'NULL',
522a26c9 221 'table_name' => 'civicrm_mailing_job',
222 'entity' => 'MailingJob',
223 'bao' => 'CRM_Mailing_BAO_MailingJob',
6a7e5e5d 224 'localizable' => 0,
2c2c4aa4 225 'html' => [
226 'type' => 'Select Date',
227 'formatType' => 'activityDateTime',
228 ],
a9d0587b 229 'add' => NULL,
c3fc2621 230 ],
08d08c03 231 'mailing_job_status' => [
e501603b
TO
232 'name' => 'status',
233 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 234 'title' => ts('Mailing Job Status'),
215b423e 235 'description' => ts('The state of this job'),
e501603b
TO
236 'maxlength' => 12,
237 'size' => CRM_Utils_Type::TWELVE,
a36434b9 238 'where' => 'civicrm_mailing_job.status',
522a26c9 239 'table_name' => 'civicrm_mailing_job',
240 'entity' => 'MailingJob',
241 'bao' => 'CRM_Mailing_BAO_MailingJob',
6a7e5e5d 242 'localizable' => 0,
c3fc2621 243 'html' => [
e501603b 244 'type' => 'Select',
c3fc2621
CW
245 ],
246 'pseudoconstant' => [
e501603b 247 'callback' => 'CRM_Core_SelectValues::getMailingJobStatus',
e6ca0a57 248 ],
a9d0587b 249 'add' => NULL,
c3fc2621
CW
250 ],
251 'is_test' => [
e501603b
TO
252 'name' => 'is_test',
253 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 254 'title' => ts('Mailing Job Is Test?'),
215b423e 255 'description' => ts('Is this job for a test mail?'),
a36434b9 256 'where' => 'civicrm_mailing_job.is_test',
45a83e42 257 'default' => '0',
522a26c9 258 'table_name' => 'civicrm_mailing_job',
259 'entity' => 'MailingJob',
260 'bao' => 'CRM_Mailing_BAO_MailingJob',
6a7e5e5d 261 'localizable' => 0,
a9d0587b 262 'add' => '1.9',
c3fc2621
CW
263 ],
264 'job_type' => [
e501603b
TO
265 'name' => 'job_type',
266 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 267 'title' => ts('Mailing Job Type'),
215b423e 268 'description' => ts('Type of mailling job: null | child '),
e501603b
TO
269 'maxlength' => 255,
270 'size' => CRM_Utils_Type::HUGE,
a36434b9 271 'where' => 'civicrm_mailing_job.job_type',
522a26c9 272 'table_name' => 'civicrm_mailing_job',
273 'entity' => 'MailingJob',
274 'bao' => 'CRM_Mailing_BAO_MailingJob',
6a7e5e5d 275 'localizable' => 0,
a9d0587b 276 'add' => '3.3',
c3fc2621
CW
277 ],
278 'parent_id' => [
e501603b
TO
279 'name' => 'parent_id',
280 'type' => CRM_Utils_Type::T_INT,
c3fc2621 281 'title' => ts('Mailing Job Parent'),
215b423e 282 'description' => ts('Parent job id'),
a36434b9 283 'where' => 'civicrm_mailing_job.parent_id',
e501603b 284 'default' => 'NULL',
522a26c9 285 'table_name' => 'civicrm_mailing_job',
286 'entity' => 'MailingJob',
287 'bao' => 'CRM_Mailing_BAO_MailingJob',
6a7e5e5d 288 'localizable' => 0,
e501603b 289 'FKClassName' => 'CRM_Mailing_DAO_MailingJob',
a9d0587b 290 'add' => '3.3',
c3fc2621
CW
291 ],
292 'job_offset' => [
e501603b
TO
293 'name' => 'job_offset',
294 'type' => CRM_Utils_Type::T_INT,
c3fc2621 295 'title' => ts('Mailing Job Offset'),
215b423e 296 'description' => ts('Offset of the child job'),
a36434b9 297 'where' => 'civicrm_mailing_job.job_offset',
45a83e42 298 'default' => '0',
522a26c9 299 'table_name' => 'civicrm_mailing_job',
300 'entity' => 'MailingJob',
301 'bao' => 'CRM_Mailing_BAO_MailingJob',
6a7e5e5d 302 'localizable' => 0,
a9d0587b 303 'add' => '3.3',
c3fc2621
CW
304 ],
305 'job_limit' => [
e501603b
TO
306 'name' => 'job_limit',
307 'type' => CRM_Utils_Type::T_INT,
c3fc2621 308 'title' => ts('Mailing Job Limit'),
215b423e 309 'description' => ts('Queue size limit for each child job'),
a36434b9 310 'where' => 'civicrm_mailing_job.job_limit',
45a83e42 311 'default' => '0',
522a26c9 312 'table_name' => 'civicrm_mailing_job',
313 'entity' => 'MailingJob',
314 'bao' => 'CRM_Mailing_BAO_MailingJob',
6a7e5e5d 315 'localizable' => 0,
a9d0587b 316 'add' => '3.3',
c3fc2621
CW
317 ],
318 ];
346aaaba 319 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 320 }
346aaaba 321 return Civi::$statics[__CLASS__]['fields'];
e501603b 322 }
c3fc2621 323
e501603b 324 /**
bd8e0b14 325 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
326 *
327 * @return array
bd8e0b14 328 * Array(string $name => string $uniqueName).
e501603b 329 */
c3fc2621 330 public static function &fieldKeys() {
bd8e0b14
TO
331 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
332 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 333 }
bd8e0b14 334 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 335 }
c3fc2621 336
e501603b
TO
337 /**
338 * Returns the names of this table
339 *
340 * @return string
341 */
c3fc2621 342 public static function getTableName() {
e501603b
TO
343 return self::$_tableName;
344 }
c3fc2621 345
e501603b
TO
346 /**
347 * Returns if this table needs to be logged
348 *
c3fc2621 349 * @return bool
e501603b 350 */
c3fc2621 351 public function getLog() {
e501603b
TO
352 return self::$_log;
353 }
c3fc2621 354
e501603b
TO
355 /**
356 * Returns the list of fields that can be imported
357 *
358 * @param bool $prefix
359 *
360 * @return array
361 */
c3fc2621
CW
362 public static function &import($prefix = FALSE) {
363 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'mailing_job', $prefix, []);
60808919 364 return $r;
e501603b 365 }
c3fc2621 366
e501603b
TO
367 /**
368 * Returns the list of fields that can be exported
369 *
370 * @param bool $prefix
371 *
372 * @return array
373 */
c3fc2621
CW
374 public static function &export($prefix = FALSE) {
375 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'mailing_job', $prefix, []);
60808919 376 return $r;
e501603b 377 }
c3fc2621 378
e7a6b91a
AS
379 /**
380 * Returns the list of indices
c3fc2621
CW
381 *
382 * @param bool $localize
383 *
384 * @return array
e7a6b91a
AS
385 */
386 public static function indices($localize = TRUE) {
c3fc2621 387 $indices = [];
e7a6b91a
AS
388 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
389 }
c3fc2621 390
e501603b 391}