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