Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
tool_monitor\rule_manager Class Reference

Rule manager class. More...

Static Public Member Functions

static add_rule ($ruledata)
 Create a new rule.
 
static clean_ruledata_form ($mformdata)
 Clean data submitted by mform.
 
static count_rules_by_courseid ($courseid)
 Get rule count by course id.
 
static delete_rule ($ruleid, $coursecontext=null)
 Delete a rule and associated subscriptions, by rule id.
 
static get_rule ($ruleorid)
 Get an instance of rule class.
 
static get_rules_by_courseid ($courseid, $limitfrom=0, $limitto=0, $includesite=true)
 Get rules by course id.
 
static get_rules_by_event ($eventname)
 Get rules by event name.
 
static get_rules_by_plugin ($plugin)
 Get rules by plugin name.
 
static update_rule ($ruledata)
 Update rule data.
 

Static Protected Member Functions

static get_instances ($arr)
 Helper method to convert db records to instances.
 

Detailed Description

Rule manager class.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ add_rule()

static tool_monitor\rule_manager::add_rule ( $ruledata)
static

Create a new rule.

Parameters
stdClass$ruledatadata to insert as new rule entry.
Return values
ruleAn instance of rule class.

◆ clean_ruledata_form()

static tool_monitor\rule_manager::clean_ruledata_form ( $mformdata)
static

Clean data submitted by mform.

Parameters
stdClass$mformdatadata to insert as new rule entry.
Return values
stdClassCleaned rule data.

◆ count_rules_by_courseid()

static tool_monitor\rule_manager::count_rules_by_courseid ( $courseid)
static

Get rule count by course id.

Parameters
int$courseidcourse id of the rule.
Return values
intcount of rules present in system visible in the given course id.

◆ delete_rule()

static tool_monitor\rule_manager::delete_rule ( $ruleid,
$coursecontext = null )
static

Delete a rule and associated subscriptions, by rule id.

Parameters
int$ruleidid of rule to be deleted.
context | null$coursecontextthe context of the course - this is passed when we can not get the context via context_course as the course has been deleted.
Return values
bool

◆ get_instances()

static tool_monitor\rule_manager::get_instances ( $arr)
staticprotected

Helper method to convert db records to instances.

Parameters
array$arrof rules.
Return values
arrayof rules as instances.

◆ get_rule()

static tool_monitor\rule_manager::get_rule ( $ruleorid)
static

Get an instance of rule class.

Parameters
stdClass | int$ruleoridA rule object from database or rule id.
Return values
ruleobject with rule id.

◆ get_rules_by_courseid()

static tool_monitor\rule_manager::get_rules_by_courseid ( $courseid,
$limitfrom = 0,
$limitto = 0,
$includesite = true )
static

Get rules by course id.

Parameters
int$courseidcourse id of the rule.
int$limitfromLimit from which to fetch rules.
int$limittoLimit to which rules need to be fetched.
bool$includesiteDetermines whether we return site wide rules or not.
Return values
arrayList of rules for the given course id, if specified will also include site rules.

◆ get_rules_by_event()

static tool_monitor\rule_manager::get_rules_by_event ( $eventname)
static

Get rules by event name.

Parameters
string$eventnameevent name of the rule.
Return values
arrayList of rules for the given event.

◆ get_rules_by_plugin()

static tool_monitor\rule_manager::get_rules_by_plugin ( $plugin)
static

Get rules by plugin name.

Parameters
string$pluginplugin name of the rule.
Return values
arrayList of rules for the given plugin name.

◆ update_rule()

static tool_monitor\rule_manager::update_rule ( $ruledata)
static

Update rule data.

Exceptions
coding_exceptionif $record->ruleid is invalid.
Parameters
object$ruledatarule data to be updated.
Return values
bool

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