35 public function isActive($a_ts_last_run, $a_schedule_type, $a_schedule_value, $a_manual =
false)
44 return $this->
checkSchedule($a_ts_last_run, $a_schedule_type, $a_schedule_value);
55 return $this->schedule_type;
67 return $this->schedule_value;
83 $this->schedule_value = $a_value;
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
134 protected function checkSchedule($a_ts_last_run, $a_schedule_type, $a_schedule_value)
136 if (!$a_schedule_type) {
139 if (!$a_ts_last_run) {
145 switch ($a_schedule_type) {
146 case self::SCHEDULE_TYPE_DAILY:
147 $last = date(
"Y-m-d", $a_ts_last_run);
148 $ref = date(
"Y-m-d", $now);
149 return ($last != $ref);
151 case self::SCHEDULE_TYPE_WEEKLY:
152 $last = date(
"Y-W", $a_ts_last_run);
153 $ref = date(
"Y-W", $now);
154 return ($last != $ref);
156 case self::SCHEDULE_TYPE_MONTHLY:
157 $last = date(
"Y-n", $a_ts_last_run);
158 $ref = date(
"Y-n", $now);
159 return ($last != $ref);
161 case self::SCHEDULE_TYPE_QUARTERLY:
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);
166 case self::SCHEDULE_TYPE_YEARLY:
167 $last = date(
"Y", $a_ts_last_run);
168 $ref = date(
"Y", $now);
169 return ($last != $ref);
171 case self::SCHEDULE_TYPE_IN_MINUTES:
172 $diff = floor(($now - $a_ts_last_run) / 60);
173 return ($diff >= $a_schedule_value);
175 case self::SCHEDULE_TYPE_IN_HOURS:
176 $diff = floor(($now - $a_ts_last_run) / (60 * 60));
177 return ($diff >= $a_schedule_value);
179 case self::SCHEDULE_TYPE_IN_DAYS:
180 $diff = floor(($now - $a_ts_last_run) / (60 * 60 * 24));
181 return ($diff >= $a_schedule_value);
288 abstract public function getId();
323 abstract public function run();
setSchedule($a_type, $a_value)
Update current schedule (if flexible)
getValidScheduleTypes()
Returns a collection of all valid schedule types for a specific job.
getAllScheduleTypes()
Get all available schedule types.
checkSchedule($a_ts_last_run, $a_schedule_type, $a_schedule_value)
addToExternalSettingsForm($a_form_id, array &$a_fields, $a_is_active)
Add external settings to form.
Cron job application base class.
const SCHEDULE_TYPE_IN_MINUTES
getDescription()
Get description.
activationWasToggled($a_currently_active)
Cron job status was changed.
const SCHEDULE_TYPE_MONTHLY
const SCHEDULE_TYPE_WEEKLY
addCustomSettingsToForm(ilPropertyFormGUI $a_form)
Add custom settings to form.
hasFlexibleSchedule()
Can the schedule be configured?
isActive($a_ts_last_run, $a_schedule_type, $a_schedule_value, $a_manual=false)
Is job currently active?
const SCHEDULE_TYPE_IN_DAYS
getScheduleTypesWithValues()
hasCustomSettings()
Has cron job any custom setting which can be edited?
const SCHEDULE_TYPE_YEARLY
getDefaultScheduleType()
Get schedule type.
const SCHEDULE_TYPE_DAILY
getDefaultScheduleValue()
Get schedule value.
saveCustomSettings(ilPropertyFormGUI $a_form)
Save custom settings.
const SCHEDULE_TYPE_QUARTERLY
getScheduleValue()
Get current schedule value (if flexible)
const SCHEDULE_TYPE_IN_HOURS
hasAutoActivation()
Is to be activated on "installation".
isManuallyExecutable()
Defines whether or not a cron job can be started manually.
getScheduleType()
Get current schedule type (if flexible)