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