Merge pull request #19329 from civicrm/5.33
[civicrm-core.git] / CRM / Core / DAO / Job.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Core/Job.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:434388c3fa5b5f67932dd71f5d64a031)
10 */
11
12 /**
13 * Database access object for the Job entity.
14 */
15 class CRM_Core_DAO_Job extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '4.1';
18
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
24 public static $_tableName = 'civicrm_job';
25
26 /**
27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
28 *
29 * @var bool
30 */
31 public static $_log = FALSE;
32
33 /**
34 * Job Id
35 *
36 * @var int
37 */
38 public $id;
39
40 /**
41 * Which Domain is this scheduled job for
42 *
43 * @var int
44 */
45 public $domain_id;
46
47 /**
48 * Scheduled job run frequency.
49 *
50 * @var string
51 */
52 public $run_frequency;
53
54 /**
55 * When was this cron entry last run
56 *
57 * @var timestamp
58 */
59 public $last_run;
60
61 /**
62 * When is this cron entry scheduled to run
63 *
64 * @var timestamp
65 */
66 public $scheduled_run_date;
67
68 /**
69 * Title of the job
70 *
71 * @var string
72 */
73 public $name;
74
75 /**
76 * Description of the job
77 *
78 * @var string
79 */
80 public $description;
81
82 /**
83 * Entity of the job api call
84 *
85 * @var string
86 */
87 public $api_entity;
88
89 /**
90 * Action of the job api call
91 *
92 * @var string
93 */
94 public $api_action;
95
96 /**
97 * List of parameters to the command.
98 *
99 * @var text
100 */
101 public $parameters;
102
103 /**
104 * Is this job active?
105 *
106 * @var bool
107 */
108 public $is_active;
109
110 /**
111 * Class constructor.
112 */
113 public function __construct() {
114 $this->__table = 'civicrm_job';
115 parent::__construct();
116 }
117
118 /**
119 * Returns localized title of this entity.
120 *
121 * @param bool $plural
122 * Whether to return the plural version of the title.
123 */
124 public static function getEntityTitle($plural = FALSE) {
125 return $plural ? ts('Jobs') : ts('Job');
126 }
127
128 /**
129 * Returns foreign keys and entity references.
130 *
131 * @return array
132 * [CRM_Core_Reference_Interface]
133 */
134 public static function getReferenceColumns() {
135 if (!isset(Civi::$statics[__CLASS__]['links'])) {
136 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
137 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'domain_id', 'civicrm_domain', '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('Job ID'),
155 'description' => ts('Job Id'),
156 'required' => TRUE,
157 'where' => 'civicrm_job.id',
158 'table_name' => 'civicrm_job',
159 'entity' => 'Job',
160 'bao' => 'CRM_Core_BAO_Job',
161 'localizable' => 0,
162 'add' => '4.1',
163 ],
164 'domain_id' => [
165 'name' => 'domain_id',
166 'type' => CRM_Utils_Type::T_INT,
167 'title' => ts('Job Domain'),
168 'description' => ts('Which Domain is this scheduled job for'),
169 'required' => TRUE,
170 'where' => 'civicrm_job.domain_id',
171 'table_name' => 'civicrm_job',
172 'entity' => 'Job',
173 'bao' => 'CRM_Core_BAO_Job',
174 'localizable' => 0,
175 'FKClassName' => 'CRM_Core_DAO_Domain',
176 'pseudoconstant' => [
177 'table' => 'civicrm_domain',
178 'keyColumn' => 'id',
179 'labelColumn' => 'name',
180 ],
181 'add' => '4.1',
182 ],
183 'run_frequency' => [
184 'name' => 'run_frequency',
185 'type' => CRM_Utils_Type::T_STRING,
186 'title' => ts('Job Frequency'),
187 'description' => ts('Scheduled job run frequency.'),
188 'maxlength' => 8,
189 'size' => CRM_Utils_Type::EIGHT,
190 'where' => 'civicrm_job.run_frequency',
191 'default' => 'Daily',
192 'table_name' => 'civicrm_job',
193 'entity' => 'Job',
194 'bao' => 'CRM_Core_BAO_Job',
195 'localizable' => 0,
196 'html' => [
197 'type' => 'Select',
198 ],
199 'pseudoconstant' => [
200 'callback' => 'CRM_Core_SelectValues::getJobFrequency',
201 ],
202 'add' => '4.1',
203 ],
204 'last_run' => [
205 'name' => 'last_run',
206 'type' => CRM_Utils_Type::T_TIMESTAMP,
207 'title' => ts('Last Run'),
208 'description' => ts('When was this cron entry last run'),
209 'required' => FALSE,
210 'where' => 'civicrm_job.last_run',
211 'default' => 'NULL',
212 'table_name' => 'civicrm_job',
213 'entity' => 'Job',
214 'bao' => 'CRM_Core_BAO_Job',
215 'localizable' => 0,
216 'add' => '4.1',
217 ],
218 'scheduled_run_date' => [
219 'name' => 'scheduled_run_date',
220 'type' => CRM_Utils_Type::T_TIMESTAMP,
221 'title' => ts('Scheduled Run Date'),
222 'description' => ts('When is this cron entry scheduled to run'),
223 'required' => FALSE,
224 'where' => 'civicrm_job.scheduled_run_date',
225 'default' => 'NULL',
226 'table_name' => 'civicrm_job',
227 'entity' => 'Job',
228 'bao' => 'CRM_Core_BAO_Job',
229 'localizable' => 0,
230 'add' => '4.7',
231 ],
232 'name' => [
233 'name' => 'name',
234 'type' => CRM_Utils_Type::T_STRING,
235 'title' => ts('Job Name'),
236 'description' => ts('Title of the job'),
237 'maxlength' => 255,
238 'size' => CRM_Utils_Type::HUGE,
239 'where' => 'civicrm_job.name',
240 'table_name' => 'civicrm_job',
241 'entity' => 'Job',
242 'bao' => 'CRM_Core_BAO_Job',
243 'localizable' => 0,
244 'add' => '4.1',
245 ],
246 'description' => [
247 'name' => 'description',
248 'type' => CRM_Utils_Type::T_STRING,
249 'title' => ts('Job Description'),
250 'description' => ts('Description of the job'),
251 'maxlength' => 255,
252 'size' => CRM_Utils_Type::HUGE,
253 'where' => 'civicrm_job.description',
254 'table_name' => 'civicrm_job',
255 'entity' => 'Job',
256 'bao' => 'CRM_Core_BAO_Job',
257 'localizable' => 0,
258 'add' => '4.1',
259 ],
260 'api_entity' => [
261 'name' => 'api_entity',
262 'type' => CRM_Utils_Type::T_STRING,
263 'title' => ts('API Entity'),
264 'description' => ts('Entity of the job api call'),
265 'maxlength' => 255,
266 'size' => CRM_Utils_Type::HUGE,
267 'where' => 'civicrm_job.api_entity',
268 'table_name' => 'civicrm_job',
269 'entity' => 'Job',
270 'bao' => 'CRM_Core_BAO_Job',
271 'localizable' => 0,
272 'add' => '4.1',
273 ],
274 'api_action' => [
275 'name' => 'api_action',
276 'type' => CRM_Utils_Type::T_STRING,
277 'title' => ts('API Action'),
278 'description' => ts('Action of the job api call'),
279 'maxlength' => 255,
280 'size' => CRM_Utils_Type::HUGE,
281 'where' => 'civicrm_job.api_action',
282 'table_name' => 'civicrm_job',
283 'entity' => 'Job',
284 'bao' => 'CRM_Core_BAO_Job',
285 'localizable' => 0,
286 'add' => '4.1',
287 ],
288 'parameters' => [
289 'name' => 'parameters',
290 'type' => CRM_Utils_Type::T_TEXT,
291 'title' => ts('API Parameters'),
292 'description' => ts('List of parameters to the command.'),
293 'rows' => 4,
294 'cols' => 60,
295 'where' => 'civicrm_job.parameters',
296 'table_name' => 'civicrm_job',
297 'entity' => 'Job',
298 'bao' => 'CRM_Core_BAO_Job',
299 'localizable' => 0,
300 'html' => [
301 'type' => 'TextArea',
302 ],
303 'add' => '4.1',
304 ],
305 'is_active' => [
306 'name' => 'is_active',
307 'type' => CRM_Utils_Type::T_BOOLEAN,
308 'title' => ts('Job Is Active?'),
309 'description' => ts('Is this job active?'),
310 'where' => 'civicrm_job.is_active',
311 'table_name' => 'civicrm_job',
312 'entity' => 'Job',
313 'bao' => 'CRM_Core_BAO_Job',
314 'localizable' => 0,
315 'add' => '4.1',
316 ],
317 ];
318 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
319 }
320 return Civi::$statics[__CLASS__]['fields'];
321 }
322
323 /**
324 * Return a mapping from field-name to the corresponding key (as used in fields()).
325 *
326 * @return array
327 * Array(string $name => string $uniqueName).
328 */
329 public static function &fieldKeys() {
330 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
331 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
332 }
333 return Civi::$statics[__CLASS__]['fieldKeys'];
334 }
335
336 /**
337 * Returns the names of this table
338 *
339 * @return string
340 */
341 public static function getTableName() {
342 return self::$_tableName;
343 }
344
345 /**
346 * Returns if this table needs to be logged
347 *
348 * @return bool
349 */
350 public function getLog() {
351 return self::$_log;
352 }
353
354 /**
355 * Returns the list of fields that can be imported
356 *
357 * @param bool $prefix
358 *
359 * @return array
360 */
361 public static function &import($prefix = FALSE) {
362 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'job', $prefix, []);
363 return $r;
364 }
365
366 /**
367 * Returns the list of fields that can be exported
368 *
369 * @param bool $prefix
370 *
371 * @return array
372 */
373 public static function &export($prefix = FALSE) {
374 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'job', $prefix, []);
375 return $r;
376 }
377
378 /**
379 * Returns the list of indices
380 *
381 * @param bool $localize
382 *
383 * @return array
384 */
385 public static function indices($localize = TRUE) {
386 $indices = [];
387 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
388 }
389
390 }