ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilCronJob Class Reference

Cron job application base class. More...

+ Inheritance diagram for ilCronJob:
+ Collaboration diagram for ilCronJob:

Public Member Functions

 isActive ($a_ts_last_run, $a_schedule_type, $a_schedule_value, $a_manual=false)
 Is job currently active? More...
 
 getScheduleType ()
 Get current schedule type (if flexible) More...
 
 getScheduleValue ()
 Get current schedule value (if flexible) More...
 
 setSchedule ($a_type, $a_value)
 Update current schedule (if flexible) More...
 
 getValidScheduleTypes ()
 Get all available schedule types. More...
 
 getTitle ()
 Get title. More...
 
 getDescription ()
 Get description. More...
 
 isManuallyExecutable ()
 Defines whether or not a cron job can be started manually. More...
 
 hasCustomSettings ()
 Has cron job any custom setting which can be edited? More...
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 Add custom settings to form. More...
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 Save custom settings. More...
 
 addToExternalSettingsForm ($a_form_id, array &$a_fields, $a_is_active)
 Add external settings to form. More...
 
 activationWasToggled ($a_currently_active)
 Cron job status was changed. More...
 
 getId ()
 Get id. More...
 
 hasAutoActivation ()
 Is to be activated on "installation". More...
 
 hasFlexibleSchedule ()
 Can the schedule be configured? More...
 
 getDefaultScheduleType ()
 Get schedule type. More...
 
 getDefaultScheduleValue ()
 Get schedule value. More...
 
 run ()
 Run job. More...
 

Data Fields

const SCHEDULE_TYPE_DAILY = 1
 
const SCHEDULE_TYPE_IN_MINUTES = 2
 
const SCHEDULE_TYPE_IN_HOURS = 3
 
const SCHEDULE_TYPE_IN_DAYS = 4
 
const SCHEDULE_TYPE_WEEKLY = 5
 
const SCHEDULE_TYPE_MONTHLY = 6
 
const SCHEDULE_TYPE_QUARTERLY = 7
 
const SCHEDULE_TYPE_YEARLY = 8
 

Protected Member Functions

 checkSchedule ($a_ts_last_run, $a_schedule_type, $a_schedule_value)
 

Detailed Description

Cron job application base class.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 11 of file class.ilCronJob.php.

Member Function Documentation

◆ activationWasToggled()

ilCronJob::activationWasToggled (   $a_currently_active)

Cron job status was changed.

Parameters
bool$a_currently_active

Definition at line 247 of file class.ilCronJob.php.

References getDefaultScheduleType(), getDefaultScheduleValue(), getId(), hasAutoActivation(), hasFlexibleSchedule(), and run().

Referenced by ilCronManager\activateJob(), ilCronManager\createDefaultEntry(), and ilCronManager\deactivateJob().

248  {
249  // we cannot use ilObject or any higher level construct here
250  // this may be called from setup, so it is limited to handling ilSetting/ilDB mostly
251  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addCustomSettingsToForm()

ilCronJob::addCustomSettingsToForm ( ilPropertyFormGUI  $a_form)

Add custom settings to form.

Parameters
ilPropertyFormGUI$a_form

Definition at line 211 of file class.ilCronJob.php.

212  {
213  }

◆ addToExternalSettingsForm()

ilCronJob::addToExternalSettingsForm (   $a_form_id,
array $a_fields,
  $a_is_active 
)

Add external settings to form.

Parameters
int$a_form_id
array$a_fields
bool$a_is_active

Definition at line 233 of file class.ilCronJob.php.

234  {
235  }

◆ checkSchedule()

ilCronJob::checkSchedule (   $a_ts_last_run,
  $a_schedule_type,
  $a_schedule_value 
)
protected

Definition at line 109 of file class.ilCronJob.php.

References date, and time.

Referenced by isActive().

110  {
111  if (!$a_schedule_type) {
112  return false;
113  }
114  if (!$a_ts_last_run) {
115  return true;
116  }
117 
118  $now = time();
119 
120  switch ($a_schedule_type) {
121  case self::SCHEDULE_TYPE_DAILY:
122  $last = date("Y-m-d", $a_ts_last_run);
123  $ref = date("Y-m-d", $now);
124  return ($last != $ref);
125 
126  case self::SCHEDULE_TYPE_WEEKLY:
127  $last = date("Y-W", $a_ts_last_run);
128  $ref = date("Y-W", $now);
129  return ($last != $ref);
130 
131  case self::SCHEDULE_TYPE_MONTHLY:
132  $last = date("Y-n", $a_ts_last_run);
133  $ref = date("Y-n", $now);
134  return ($last != $ref);
135 
136  case self::SCHEDULE_TYPE_QUARTERLY:
137  $last = date("Y", $a_ts_last_run) . "-" . ceil(date("n", $a_ts_last_run)/3);
138  $ref = date("Y", $now) . "-" . ceil(date("n", $now)/3);
139  return ($last != $ref);
140 
141  case self::SCHEDULE_TYPE_YEARLY:
142  $last = date("Y", $a_ts_last_run);
143  $ref = date("Y", $now);
144  return ($last != $ref);
145 
146  case self::SCHEDULE_TYPE_IN_MINUTES:
147  $diff = floor(($now-$a_ts_last_run)/60);
148  return ($diff >= $a_schedule_value);
149 
150  case self::SCHEDULE_TYPE_IN_HOURS:
151  $diff = floor(($now-$a_ts_last_run)/(60*60));
152  return ($diff >= $a_schedule_value);
153 
154  case self::SCHEDULE_TYPE_IN_DAYS:
155  $diff = floor(($now-$a_ts_last_run)/(60*60*24));
156  return ($diff >= $a_schedule_value);
157  }
158  }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the caller graph for this function:

◆ getDefaultScheduleType()

ilCronJob::getDefaultScheduleType ( )
abstract

Get schedule type.

Returns
int

Referenced by activationWasToggled(), ilCronManager\createDefaultEntry(), isActive(), and ilCronManagerTableGUI\parseJobToData().

+ Here is the caller graph for this function:

◆ getDefaultScheduleValue()

ilCronJob::getDefaultScheduleValue ( )
abstract

Get schedule value.

Returns
int|array

Referenced by activationWasToggled(), ilCronManager\createDefaultEntry(), isActive(), and ilCronManagerTableGUI\parseJobToData().

+ Here is the caller graph for this function:

◆ getDescription()

ilCronJob::getDescription ( )

Get description.

Returns
string

Definition at line 179 of file class.ilCronJob.php.

Referenced by ilCronManagerTableGUI\parseJobToData().

180  {
181  }
+ Here is the caller graph for this function:

◆ getId()

◆ getScheduleType()

ilCronJob::getScheduleType ( )

Get current schedule type (if flexible)

Returns
int

Definition at line 52 of file class.ilCronJob.php.

References hasFlexibleSchedule().

Referenced by ilWebResourceCronLinkCheck\__getCheckPeriod().

53  {
54  if ($this->hasFlexibleSchedule() && $this->schedule_type) {
55  return $this->schedule_type;
56  }
57  }
hasFlexibleSchedule()
Can the schedule be configured?
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getScheduleValue()

ilCronJob::getScheduleValue ( )

Get current schedule value (if flexible)

Returns
int

Definition at line 64 of file class.ilCronJob.php.

References hasFlexibleSchedule().

65  {
66  if ($this->hasFlexibleSchedule() && $this->schedule_value) {
67  return $this->schedule_value;
68  }
69  }
hasFlexibleSchedule()
Can the schedule be configured?
+ Here is the call graph for this function:

◆ getTitle()

ilCronJob::getTitle ( )

Get title.

Returns
string

Definition at line 170 of file class.ilCronJob.php.

Referenced by ilCronManagerTableGUI\parseJobToData().

171  {
172  }
+ Here is the caller graph for this function:

◆ getValidScheduleTypes()

ilCronJob::getValidScheduleTypes ( )

Get all available schedule types.

Returns
int

Definition at line 93 of file class.ilCronJob.php.

References array.

Referenced by setSchedule(), and ilCronManager\updateJobSchedule().

94  {
95  return array(self::SCHEDULE_TYPE_DAILY, self::SCHEDULE_TYPE_IN_MINUTES,
96  self::SCHEDULE_TYPE_IN_HOURS, self::SCHEDULE_TYPE_IN_DAYS,
97  self::SCHEDULE_TYPE_WEEKLY, self::SCHEDULE_TYPE_MONTHLY,
98  self::SCHEDULE_TYPE_QUARTERLY, self::SCHEDULE_TYPE_YEARLY);
99  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ hasAutoActivation()

ilCronJob::hasAutoActivation ( )
abstract

Is to be activated on "installation".

Returns
boolean

Referenced by activationWasToggled(), and ilCronManager\createDefaultEntry().

+ Here is the caller graph for this function:

◆ hasCustomSettings()

ilCronJob::hasCustomSettings ( )

Has cron job any custom setting which can be edited?

Returns
boolean

Definition at line 201 of file class.ilCronJob.php.

Referenced by ilCronManagerTableGUI\parseJobToData().

202  {
203  return false;
204  }
+ Here is the caller graph for this function:

◆ hasFlexibleSchedule()

ilCronJob::hasFlexibleSchedule ( )
abstract

Can the schedule be configured?

Returns
boolean

Referenced by activationWasToggled(), ilCronManager\createDefaultEntry(), getScheduleType(), getScheduleValue(), isActive(), ilCronManagerTableGUI\parseJobToData(), setSchedule(), and ilCronManager\updateJobSchedule().

+ Here is the caller graph for this function:

◆ isActive()

ilCronJob::isActive (   $a_ts_last_run,
  $a_schedule_type,
  $a_schedule_value,
  $a_manual = false 
)

Is job currently active?

Parameters
timestamp$a_ts_last_run
integer$a_ts_last_run
integer$a_ts_last_run
bool$a_ts_last_run
Returns
boolean

Definition at line 35 of file class.ilCronJob.php.

References checkSchedule(), getDefaultScheduleType(), getDefaultScheduleValue(), and hasFlexibleSchedule().

Referenced by ilCronManager\runJob().

36  {
37  if ($a_manual) {
38  return true;
39  }
40  if (!$this->hasFlexibleSchedule()) {
41  $a_schedule_type = $this->getDefaultScheduleType();
42  $a_schedule_value = $this->getDefaultScheduleValue();
43  }
44  return $this->checkSchedule($a_ts_last_run, $a_schedule_type, $a_schedule_value);
45  }
checkSchedule($a_ts_last_run, $a_schedule_type, $a_schedule_value)
hasFlexibleSchedule()
Can the schedule be configured?
getDefaultScheduleType()
Get schedule type.
getDefaultScheduleValue()
Get schedule value.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isManuallyExecutable()

ilCronJob::isManuallyExecutable ( )

Defines whether or not a cron job can be started manually.

Returns
bool

Definition at line 187 of file class.ilCronJob.php.

Referenced by ilCronManagerTableGUI\parseJobToData().

188  {
189  return true;
190  }
+ Here is the caller graph for this function:

◆ run()

ilCronJob::run ( )
abstract

◆ saveCustomSettings()

ilCronJob::saveCustomSettings ( ilPropertyFormGUI  $a_form)

Save custom settings.

Parameters
ilPropertyFormGUI$a_form
Returns
boolean

Definition at line 221 of file class.ilCronJob.php.

222  {
223  return true;
224  }

◆ setSchedule()

ilCronJob::setSchedule (   $a_type,
  $a_value 
)

Update current schedule (if flexible)

Parameters
integer$a_type
integer$a_value
Returns
int

Definition at line 78 of file class.ilCronJob.php.

References $a_type, getValidScheduleTypes(), and hasFlexibleSchedule().

79  {
80  if ($this->hasFlexibleSchedule() &&
81  in_array($a_type, $this->getValidScheduleTypes()) &&
82  $a_value) {
83  $this->schedule_type = $a_type;
84  $this->schedule_value = $a_value;
85  }
86  }
getValidScheduleTypes()
Get all available schedule types.
$a_type
Definition: workflow.php:92
hasFlexibleSchedule()
Can the schedule be configured?
+ Here is the call graph for this function:

Field Documentation

◆ SCHEDULE_TYPE_DAILY

◆ SCHEDULE_TYPE_IN_DAYS

◆ SCHEDULE_TYPE_IN_HOURS

◆ SCHEDULE_TYPE_IN_MINUTES

◆ SCHEDULE_TYPE_MONTHLY

◆ SCHEDULE_TYPE_QUARTERLY

◆ SCHEDULE_TYPE_WEEKLY

◆ SCHEDULE_TYPE_YEARLY


The documentation for this class was generated from the following file: