ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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

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

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

260 {
261 // we cannot use ilObject or any higher level construct here
262 // this may be called from setup, so it is limited to handling ilSetting/ilDB mostly
263 }

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

+ Here is the caller graph for this function:

◆ addCustomSettingsToForm()

ilCronJob::addCustomSettingsToForm ( ilPropertyFormGUI  $a_form)

◆ 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 ilLDAPCronSynchronization, ilMembershipCronNotifications, and ilDAVCronDiskQuota.

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

245 {
246
247 }

◆ checkSchedule()

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

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

115 {
116 if(!$a_schedule_type)
117 {
118 return false;
119 }
120 if(!$a_ts_last_run)
121 {
122 return true;
123 }
124
125 $now = time();
126
127 switch($a_schedule_type)
128 {
130 $last = date("Y-m-d", $a_ts_last_run);
131 $ref = date("Y-m-d", $now);
132 return ($last != $ref);
133
135 $last = date("Y-W", $a_ts_last_run);
136 $ref = date("Y-W", $now);
137 return ($last != $ref);
138
140 $last = date("Y-n", $a_ts_last_run);
141 $ref = date("Y-n", $now);
142 return ($last != $ref);
143
145 $last = date("Y", $a_ts_last_run)."-".ceil(date("n", $a_ts_last_run)/3);
146 $ref = date("Y", $now)."-".ceil(date("n", $now)/3);
147 return ($last != $ref);
148
150 $last = date("Y", $a_ts_last_run);
151 $ref = date("Y", $now);
152 return ($last != $ref);
153
155 $diff = floor(($now-$a_ts_last_run)/60);
156 return ($diff >= $a_schedule_value);
157
159 $diff = floor(($now-$a_ts_last_run)/(60*60));
160 return ($diff >= $a_schedule_value);
161
163 $diff = floor(($now-$a_ts_last_run)/(60*60*24));
164 return ($diff >= $a_schedule_value);
165 }
166 }
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:

◆ getDefaultScheduleType()

◆ getDefaultScheduleValue()

◆ getDescription()

◆ getId()

◆ getScheduleType()

ilCronJob::getScheduleType ( )

Get current schedule type (if flexible)

Returns
int

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

55 {
56 if($this->hasFlexibleSchedule() && $this->schedule_type)
57 {
58 return $this->schedule_type;
59 }
60 }
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:

◆ getScheduleValue()

ilCronJob::getScheduleValue ( )

Get current schedule value (if flexible)

Returns
int

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

68 {
69 if($this->hasFlexibleSchedule() && $this->schedule_value)
70 {
71 return $this->schedule_value;
72 }
73 }

References hasFlexibleSchedule().

+ Here is the call graph for this function:

◆ getTitle()

◆ getValidScheduleTypes()

ilCronJob::getValidScheduleTypes ( )

Get all available schedule types.

Returns
int

Reimplemented in ilSCCronTrash.

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

99 {
100 return array(self::SCHEDULE_TYPE_DAILY, self::SCHEDULE_TYPE_IN_MINUTES,
101 self::SCHEDULE_TYPE_IN_HOURS, self::SCHEDULE_TYPE_IN_DAYS,
102 self::SCHEDULE_TYPE_WEEKLY, self::SCHEDULE_TYPE_MONTHLY,
103 self::SCHEDULE_TYPE_QUARTERLY, self::SCHEDULE_TYPE_YEARLY);
104 }

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

+ Here is the caller graph for this function:

◆ hasAutoActivation()

◆ hasCustomSettings()

ilCronJob::hasCustomSettings ( )

Has cron job any custom setting which can be edited?

Returns
boolean

Reimplemented in ilForumCronNotification, ilConsultationHourCron, ilMailCronNotification, ilMailCronOrphanedMails, ilPaymentCronNotification, ilSCCronTrash, ilCronDeleteInactivatedUserAccounts, ilCronDeleteInactiveUserAccounts, and ilDAVCronDiskQuota.

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

212 {
213 return false;
214 }

Referenced by ilCronManagerTableGUI\parseJobToData().

+ Here is the caller graph for this function:

◆ 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 {
39 return true;
40 }
41 if(!$this->hasFlexibleSchedule())
42 {
43 $a_schedule_type = $this->getDefaultScheduleType();
44 $a_schedule_value = $this->getDefaultScheduleValue();
45 }
46 return $this->checkSchedule($a_ts_last_run, $a_schedule_type, $a_schedule_value);
47 }
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 197 of file class.ilCronJob.php.

198 {
199 return true;
200 }

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
Returns
int

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

83 {
84 if($this->hasFlexibleSchedule() &&
85 in_array($a_type, $this->getValidScheduleTypes()) &&
86 $a_value)
87 {
88 $this->schedule_type = $a_type;
89 $this->schedule_value = $a_value;
90 }
91 }
getValidScheduleTypes()
Get all available schedule types.

References getValidScheduleTypes(), and hasFlexibleSchedule().

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