ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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...
 
 getAllScheduleTypes ()
 Get all available schedule types. More...
 
 getScheduleTypesWithValues ()
 
 getValidScheduleTypes ()
 Returns a collection of all valid schedule types for a specific job. 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

Reimplemented in ilForumCronNotification, ilWebResourceCronLinkCheck, ilDAVCronDiskQuota, ilMailCronNotification, and ilMembershipCronNotifications.

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

273 {
274 // we cannot use ilObject or any higher level construct here
275 // this may be called from setup, so it is limited to handling ilSetting/ilDB mostly
276 }

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

+ Here is the caller graph for this function:

◆ addCustomSettingsToForm()

◆ 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

Reimplemented in ilForumCronNotification, ilDAVCronDiskQuota, ilLDAPCronSynchronization, ilMembershipCronNotifications, and ilCronOerHarvester.

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

259 {
260 }

◆ checkSchedule()

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

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

135 {
136 if (!$a_schedule_type) {
137 return false;
138 }
139 if (!$a_ts_last_run) {
140 return true;
141 }
142
143 $now = time();
144
145 switch ($a_schedule_type) {
147 $last = date("Y-m-d", $a_ts_last_run);
148 $ref = date("Y-m-d", $now);
149 return ($last != $ref);
150
152 $last = date("Y-W", $a_ts_last_run);
153 $ref = date("Y-W", $now);
154 return ($last != $ref);
155
157 $last = date("Y-n", $a_ts_last_run);
158 $ref = date("Y-n", $now);
159 return ($last != $ref);
160
162 $last = date("Y", $a_ts_last_run) . "-" . ceil(date("n", $a_ts_last_run) / 3);
163 $ref = date("Y", $now) . "-" . ceil(date("n", $now) / 3);
164 return ($last != $ref);
165
167 $last = date("Y", $a_ts_last_run);
168 $ref = date("Y", $now);
169 return ($last != $ref);
170
172 $diff = floor(($now - $a_ts_last_run) / 60);
173 return ($diff >= $a_schedule_value);
174
176 $diff = floor(($now - $a_ts_last_run) / (60 * 60));
177 return ($diff >= $a_schedule_value);
178
180 $diff = floor(($now - $a_ts_last_run) / (60 * 60 * 24));
181 return ($diff >= $a_schedule_value);
182 }
183 }
const SCHEDULE_TYPE_IN_DAYS
const SCHEDULE_TYPE_IN_HOURS
const SCHEDULE_TYPE_IN_MINUTES
const SCHEDULE_TYPE_WEEKLY
const SCHEDULE_TYPE_YEARLY
const SCHEDULE_TYPE_DAILY
const SCHEDULE_TYPE_QUARTERLY
const SCHEDULE_TYPE_MONTHLY

References SCHEDULE_TYPE_DAILY, SCHEDULE_TYPE_IN_DAYS, SCHEDULE_TYPE_IN_HOURS, SCHEDULE_TYPE_IN_MINUTES, SCHEDULE_TYPE_MONTHLY, SCHEDULE_TYPE_QUARTERLY, SCHEDULE_TYPE_WEEKLY, and SCHEDULE_TYPE_YEARLY.

Referenced by isActive().

+ Here is the caller graph for this function:

◆ getAllScheduleTypes()

ilCronJob::getAllScheduleTypes ( )

Get all available schedule types.

Returns
int[]

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

92 {
93 return array(
94 self::SCHEDULE_TYPE_DAILY,
95 self::SCHEDULE_TYPE_WEEKLY,
96 self::SCHEDULE_TYPE_MONTHLY,
97 self::SCHEDULE_TYPE_QUARTERLY,
98 self::SCHEDULE_TYPE_YEARLY,
99 self::SCHEDULE_TYPE_IN_MINUTES,
100 self::SCHEDULE_TYPE_IN_HOURS,
101 self::SCHEDULE_TYPE_IN_DAYS
102 );
103 }

Referenced by getValidScheduleTypes().

+ Here is the caller graph for this function:

◆ getDefaultScheduleType()

◆ getDefaultScheduleValue()

◆ getDescription()

◆ getId()

◆ getScheduleType()

ilCronJob::getScheduleType ( )

Get current schedule type (if flexible)

Returns
int

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

53 {
54 if ($this->hasFlexibleSchedule() && $this->schedule_type) {
55 return $this->schedule_type;
56 }
57 }
hasFlexibleSchedule()
Can the schedule be configured?

References hasFlexibleSchedule().

Referenced by ilWebResourceCronLinkCheck\__getCheckPeriod().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getScheduleTypesWithValues()

ilCronJob::getScheduleTypesWithValues ( )

◆ getScheduleValue()

ilCronJob::getScheduleValue ( )

Get current schedule value (if flexible)

Returns
int

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

65 {
66 if ($this->hasFlexibleSchedule() && $this->schedule_value) {
67 return $this->schedule_value;
68 }
69 }

References hasFlexibleSchedule().

+ Here is the call graph for this function:

◆ getTitle()

◆ getValidScheduleTypes()

ilCronJob::getValidScheduleTypes ( )

Returns a collection of all valid schedule types for a specific job.

Returns
int[]

Reimplemented in ilMailCronOrphanedMails, and ilSCCronTrash.

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

122 {
123 return $this->getAllScheduleTypes();
124 }
getAllScheduleTypes()
Get all available schedule types.

References getAllScheduleTypes().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasAutoActivation()

◆ hasCustomSettings()

◆ hasFlexibleSchedule()

◆ 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.

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 }
getDefaultScheduleType()
Get schedule type.
getDefaultScheduleValue()
Get schedule value.
checkSchedule($a_ts_last_run, $a_schedule_type, $a_schedule_value)

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

Referenced by ilCronManager\runJob().

+ 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 212 of file class.ilCronJob.php.

213 {
214 return true;
215 }

Referenced by ilCronManagerTableGUI\parseJobToData().

+ Here is the caller graph for this function:

◆ run()

◆ saveCustomSettings()

ilCronJob::saveCustomSettings ( ilPropertyFormGUI  $a_form)

◆ setSchedule()

ilCronJob::setSchedule (   $a_type,
  $a_value 
)

Update current schedule (if flexible)

Parameters
integer$a_type
integer$a_value

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

78 {
79 if ($this->hasFlexibleSchedule() &&
80 in_array($a_type, $this->getValidScheduleTypes()) &&
81 $a_value) {
82 $this->schedule_type = $a_type;
83 $this->schedule_value = $a_value;
84 }
85 }
getValidScheduleTypes()
Returns a collection of all valid schedule types for a specific job.
$a_type
Definition: workflow.php:92

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

+ Here is the call graph for this function:

Field Documentation

◆ SCHEDULE_TYPE_DAILY

const ilCronJob::SCHEDULE_TYPE_DAILY = 1

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

Referenced by ilWebResourceCronLinkCheck\__getCheckPeriod(), checkSchedule(), ilBookCronNotification\getDefaultScheduleType(), ilBookingPrefBookCron\getDefaultScheduleType(), ilXapiResultsCronjob\getDefaultScheduleType(), ilTimingsCronReminder\getDefaultScheduleType(), ilExcCronFeedbackNotification\getDefaultScheduleType(), ilExcCronReminders\getDefaultScheduleType(), ilLearningModuleCronLinkCheck\getDefaultScheduleType(), ilCronUpdateOrgUnitPaths\getDefaultScheduleType(), ilSurveyCronNotification\getDefaultScheduleType(), ilCronFinishUnfinishedTestPasses\getDefaultScheduleType(), ilWebResourceCronLinkCheck\getDefaultScheduleType(), ilConsultationHourCron\getDefaultScheduleType(), ilDAVCronDiskQuota\getDefaultScheduleType(), ilLDAPCronSynchronization\getDefaultScheduleType(), ilLTICronOutcomeService\getDefaultScheduleType(), ilMailCronNotification\getDefaultScheduleType(), ilMailCronOrphanedMails\getDefaultScheduleType(), ilMembershipCronMinMembers\getDefaultScheduleType(), ilMembershipCronNotifications\getDefaultScheduleType(), ilCronOerHarvester\getDefaultScheduleType(), ilCronPersonalWorkspaceRecalculateQuota\getDefaultScheduleType(), ilLuceneIndexer\getDefaultScheduleType(), ilSkillNotifications\getDefaultScheduleType(), ilLPCronObjectStatistics\getDefaultScheduleType(), ilCronDeleteInactivatedUserAccounts\getDefaultScheduleType(), ilCronDeleteInactiveUserAccounts\getDefaultScheduleType(), ilCronDeleteNeverLoggedInUserAccounts\getDefaultScheduleType(), ilUserCronCheckAccounts\getDefaultScheduleType(), ilCronManagerGUI\getScheduleTypeFormElementName(), ilCronDeleteInactiveUserAccounts\getTimeDifferenceBySchedule(), and ilCronManagerTableGUI\parseJobToData().

◆ 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: