Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
tool_monitor\task\check_subscriptions Class Reference
Inheritance diagram for tool_monitor\task\check_subscriptions:
core\task\scheduled_task core\task\task_base

Public Member Functions

 eval_cron_field ($field, $min, $max)
 Take a cron field definition and return an array of valid numbers with the range min-max. More...
 
 execute ()
 Checks all course-level rule subscriptions and activates/deactivates based on current course access. More...
 
 get_component ()
 Getter for $component. More...
 
 get_cron_lock ()
 Get the current lock for the entire cron. More...
 
 get_day ()
 Getter for $day. More...
 
 get_day_of_week ()
 Getter for $dayofweek. More...
 
 get_disabled ()
 Getter for $disabled. More...
 
 get_fail_delay ()
 Getter for $faildelay. More...
 
 get_hour ()
 Getter for $hour. More...
 
 get_last_run_time ()
 Get the last run time for this scheduled task. More...
 
 get_lock ()
 Get the current lock for this task. More...
 
 get_minute ()
 Getter for $minute. More...
 
 get_month ()
 Getter for $month. More...
 
 get_name ()
 Get a descriptive name for this task. More...
 
 get_next_run_time ()
 Get the next run time for this task. More...
 
 get_next_scheduled_time ()
 Calculate when this task should next be run based on the schedule. More...
 
 get_run_if_component_disabled ()
 Override this function if you want this scheduled task to run, even if the component is disabled. More...
 
 is_blocking ()
 Getter for $blocking. More...
 
 is_customised ()
 Has this task been changed from it's default config? More...
 
 set_blocking ($blocking)
 Setter for $blocking. More...
 
 set_component ($component)
 Setter for $component. More...
 
 set_cron_lock (\core\lock\lock $lock)
 Set the current lock for the entire cron process. More...
 
 set_customised ($customised)
 Has this task been changed from it's default config? More...
 
 set_day ($day)
 Setter for $day. More...
 
 set_day_of_week ($dayofweek)
 Setter for $dayofweek. More...
 
 set_disabled ($disabled)
 Setter for $disabled. More...
 
 set_fail_delay ($faildelay)
 Setter for $faildelay. More...
 
 set_hour ($hour)
 Setter for $hour. More...
 
 set_last_run_time ($lastruntime)
 Set the last run time for this scheduled task. More...
 
 set_lock (\core\lock\lock $lock)
 Set the current lock for this task. More...
 
 set_minute ($minute)
 Setter for $minute. More...
 
 set_month ($month)
 Setter for $month. More...
 
 set_next_run_time ($nextruntime)
 Set the next run time for this task. More...
 

Public Attributes

const DAYOFWEEKMAX = 6
 Maximum dayofweek value.
 
const DAYOFWEEKMIN = 0
 Minimum dayofweek value.
 
const HOURMAX = 23
 Maximum hour value.
 
const HOURMIN = 0
 Minimum hour value.
 
const MINUTEMAX = 59
 Maximum minute value.
 
const MINUTEMIN = 0
 Minimum minute value.
 

Protected Member Functions

 get_course_from_rowdata ($rowdata)
 Returns a partial course record, created from properties of the supplied recordset row object. More...
 
 get_subscription_from_rowdata ($rowdata)
 Returns a partial subscription record, created from properties of the supplied recordset row object. More...
 
 get_user_from_rowdata ($rowdata)
 Returns a partial user record, created from properties of the supplied recordset row object. More...
 
 is_user_setup ($user)
 Determines whether a user is fully set up, using cached results where possible. More...
 
 user_can_access_course ($user, $course, $capability)
 Determines a user's access to a course with a given capability, using cached results where possible. More...
 

Protected Attributes

array $courseaccesscache = array()
 2d static cache, indexed by courseid and userid, storing whether a user can access the course with the 'tool/monitor:subscribe' capability.
 
array $userssetupcache = array()
 1d static cache, indexed by userid, storing whether or not the user has been fully set up.
 

Member Function Documentation

◆ eval_cron_field()

core\task\scheduled_task::eval_cron_field (   $field,
  $min,
  $max 
)
inherited

Take a cron field definition and return an array of valid numbers with the range min-max.

Parameters
string$field- The field definition.
int$min- The minimum allowable value.
int$max- The maximum allowable value.
Return values
array(int)

◆ execute()

tool_monitor\task\check_subscriptions::execute ( )

Checks all course-level rule subscriptions and activates/deactivates based on current course access.

The ordering of checks within the task is important for optimisation purposes. The aim is to be able to make a decision about whether to activate/deactivate each subscription without making unnecessary checks. The ordering roughly follows the context model, starting with system and user checks and moving down to course and course-module only when necessary.

For example, if the user is suspended, then any active subscription is made inactive right away. I.e. there is no need to check site-level, course-level or course-module-level permissions. Likewise, if a subscriptions is site-level, there is no need to check course-level and course-module-level permissions.

The task performs the following checks, in this order:

  1. Check for a suspended user, breaking if suspended.
  2. Check for an incomplete (not set up) user, breaking if not fully set up.
  3. Check for the required capability in the relevant context, breaking if the capability is not found.
  4. Check whether the subscription is site-context, breaking if true.
  5. Check whether the user has course access, breaking only if the subscription is not also course-module-level.
  6. Check whether the user has course-module access.
Since
3.2.0

Reimplemented from core\task\task_base.

◆ get_component()

core\task\task_base::get_component ( )
inherited

Getter for $component.

Return values
string

◆ get_course_from_rowdata()

tool_monitor\task\check_subscriptions::get_course_from_rowdata (   $rowdata)
protected

Returns a partial course record, created from properties of the supplied recordset row object.

Intended to return a minimal record for specific use within this class and in subsequent access control calls only.

Since
3.2.0
Parameters
stdClass$rowdatathe row object.
Return values
stdClassa partial course record.

◆ get_cron_lock()

core\task\task_base::get_cron_lock ( )
inherited

Get the current lock for the entire cron.

Return values
core

◆ get_day()

core\task\scheduled_task::get_day ( )
inherited

Getter for $day.

Return values
string

◆ get_day_of_week()

core\task\scheduled_task::get_day_of_week ( )
inherited

Getter for $dayofweek.

Return values
string

◆ get_disabled()

core\task\scheduled_task::get_disabled ( )
inherited

Getter for $disabled.

Return values
bool

◆ get_fail_delay()

core\task\task_base::get_fail_delay ( )
inherited

Getter for $faildelay.

Return values
int

◆ get_hour()

core\task\scheduled_task::get_hour ( )
inherited

Getter for $hour.

Return values
string

◆ get_last_run_time()

core\task\scheduled_task::get_last_run_time ( )
inherited

Get the last run time for this scheduled task.

Return values
int

◆ get_lock()

core\task\task_base::get_lock ( )
inherited

Get the current lock for this task.

Return values
core

◆ get_minute()

core\task\scheduled_task::get_minute ( )
inherited

Getter for $minute.

Return values
string

◆ get_month()

core\task\scheduled_task::get_month ( )
inherited

Getter for $month.

Return values
string

◆ get_name()

tool_monitor\task\check_subscriptions::get_name ( )

Get a descriptive name for this task.

Since
3.2.0
Return values
stringname of the task.

Reimplemented from core\task\scheduled_task.

◆ get_next_run_time()

core\task\task_base::get_next_run_time ( )
inherited

Get the next run time for this task.

Return values
inttimestamp

◆ get_next_scheduled_time()

core\task\scheduled_task::get_next_scheduled_time ( )
inherited

Calculate when this task should next be run based on the schedule.

Return values
int::$nextruntime,.

◆ get_run_if_component_disabled()

core\task\scheduled_task::get_run_if_component_disabled ( )
inherited

Override this function if you want this scheduled task to run, even if the component is disabled.

Return values
bool

◆ get_subscription_from_rowdata()

tool_monitor\task\check_subscriptions::get_subscription_from_rowdata (   $rowdata)
protected

Returns a partial subscription record, created from properties of the supplied recordset row object.

Intended to return a minimal record for specific use within this class and in subsequent access control calls only.

Since
3.2.0
Parameters
stdClass$rowdatathe row object.
Return values
stdClassa partial subscription record.

◆ get_user_from_rowdata()

tool_monitor\task\check_subscriptions::get_user_from_rowdata (   $rowdata)
protected

Returns a partial user record, created from properties of the supplied recordset row object.

Intended to return a minimal record for specific use within this class and in subsequent access control calls only.

Since
3.2.0
Parameters
stdClass$rowdatathe row object.
Return values
stdClassa partial user record.

◆ is_blocking()

core\task\task_base::is_blocking ( )
inherited

Getter for $blocking.

Return values
bool

◆ is_customised()

core\task\scheduled_task::is_customised ( )
inherited

Has this task been changed from it's default config?

Return values
bool

◆ is_user_setup()

tool_monitor\task\check_subscriptions::is_user_setup (   $user)
protected

Determines whether a user is fully set up, using cached results where possible.

Since
3.2.0
Parameters
stdClass$userthe user record.
Return values
booltrue if the user is fully set up, false otherwise.

◆ set_blocking()

core\task\task_base::set_blocking (   $blocking)
inherited

Setter for $blocking.

Parameters
bool$blocking

◆ set_component()

core\task\task_base::set_component (   $component)
inherited

Setter for $component.

Parameters
string$component

◆ set_cron_lock()

core\task\task_base::set_cron_lock ( \core\lock\lock  $lock)
inherited

Set the current lock for the entire cron process.

Parameters
core\lock\lock$lock

◆ set_customised()

core\task\scheduled_task::set_customised (   $customised)
inherited

Has this task been changed from it's default config?

Parameters
bool

◆ set_day()

core\task\scheduled_task::set_day (   $day)
inherited

Setter for $day.

Parameters
string$day

◆ set_day_of_week()

core\task\scheduled_task::set_day_of_week (   $dayofweek)
inherited

Setter for $dayofweek.

Parameters
string$dayofweek

◆ set_disabled()

core\task\scheduled_task::set_disabled (   $disabled)
inherited

Setter for $disabled.

Parameters
bool$disabled

◆ set_fail_delay()

core\task\task_base::set_fail_delay (   $faildelay)
inherited

Setter for $faildelay.

Parameters
int$faildelay

◆ set_hour()

core\task\scheduled_task::set_hour (   $hour)
inherited

Setter for $hour.

Accepts a special 'R' value which will be translated to a random hour.

Parameters
string$hour

◆ set_last_run_time()

core\task\scheduled_task::set_last_run_time (   $lastruntime)
inherited

Set the last run time for this scheduled task.

Parameters
int$lastruntime

◆ set_lock()

core\task\task_base::set_lock ( \core\lock\lock  $lock)
inherited

Set the current lock for this task.

Parameters
core\lock\lock$lock

◆ set_minute()

core\task\scheduled_task::set_minute (   $minute)
inherited

Setter for $minute.

Accepts a special 'R' value which will be translated to a random minute.

Parameters
string$minute

◆ set_month()

core\task\scheduled_task::set_month (   $month)
inherited

Setter for $month.

Parameters
string$month

◆ set_next_run_time()

core\task\task_base::set_next_run_time (   $nextruntime)
inherited

Set the next run time for this task.

Parameters
int$nextruntime

◆ user_can_access_course()

tool_monitor\task\check_subscriptions::user_can_access_course (   $user,
  $course,
  $capability 
)
protected

Determines a user's access to a course with a given capability, using cached results where possible.

Since
3.2.0
Parameters
stdClass$userthe user record.
stdClass$coursethe course record.
string$capabilitythe capability to check.
Return values
booltrue if the user can access the course with the specified capability, false otherwise.

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