Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]

Scheduled task abstract class.

Copyright: 2013 Damyon Wiese
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 439 lines (13 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: scheduled_task  - X-Ref

Abstract class defining a scheduled task.

get_last_run_time()   X-Ref
Get the last run time for this scheduled task.

return: int

set_last_run_time($lastruntime)   X-Ref
Set the last run time for this scheduled task.

param: int $lastruntime

is_customised()   X-Ref
Has this task been changed from it's default config?

return: bool

set_customised($customised)   X-Ref
Has this task been changed from it's default config?

param: bool

is_overridden()   X-Ref
Has this task been changed from it's default config?

return: bool

set_overridden(bool $overridden)   X-Ref
Set the overridden value.

param: bool $overridden

set_minute($minute, $expandr = true)   X-Ref
Setter for $minute. Accepts a special 'R' value
which will be translated to a random minute.

param: string $minute
param: bool $expandr - if true (default) an 'R' value in a time is expanded to an appropriate int.

get_minute()   X-Ref
Getter for $minute.

return: string

set_hour($hour, $expandr = true)   X-Ref
Setter for $hour. Accepts a special 'R' value
which will be translated to a random hour.

param: string $hour
param: bool $expandr - if true (default) an 'R' value in a time is expanded to an appropriate int.

get_hour()   X-Ref
Getter for $hour.

return: string

set_month($month)   X-Ref
Setter for $month.

param: string $month

get_month()   X-Ref
Getter for $month.

return: string

set_day($day)   X-Ref
Setter for $day.

param: string $day

get_day()   X-Ref
Getter for $day.

return: string

set_day_of_week($dayofweek, $expandr = true)   X-Ref
Setter for $dayofweek.

param: string $dayofweek
param: bool $expandr - if true (default) an 'R' value in a time is expanded to an appropriate int.

get_day_of_week()   X-Ref
Getter for $dayofweek.

return: string

set_disabled($disabled)   X-Ref
Setter for $disabled.

param: bool $disabled

get_disabled()   X-Ref
Getter for $disabled.

return: bool

get_run_if_component_disabled()   X-Ref
Override this function if you want this scheduled task to run, even if the component is disabled.

return: bool

eval_cron_field($field, $min, $max)   X-Ref
Take a cron field definition and return an array of valid numbers with the range min-max.

param: string $field - The field definition.
param: int $min - The minimum allowable value.
param: int $max - The maximum allowable value.
return: array(int)

next_in_list($current, $list)   X-Ref
Assuming $list is an ordered list of items, this function returns the item
in the list that is greater than or equal to the current value (or 0). If
no value is greater than or equal, this will return the first valid item in the list.
If list is empty, this function will return 0.

param: int $current The current value
param: int[] $list The list of valid items.
return: int $next.

get_next_scheduled_time()   X-Ref
Calculate when this task should next be run based on the schedule.

return: int $nextruntime.