Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Rule manager class.

Copyright: 2014 onwards Simey Lameze <lameze@gmail.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 290 lines (10 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: rule_manager  - X-Ref

Rule manager class.

add_rule($ruledata)   X-Ref
Create a new rule.

return: rule An instance of rule class.
param: \stdClass $ruledata data to insert as new rule entry.

clean_ruledata_form($mformdata)   X-Ref
Clean data submitted by mform.

return: \stdClass Cleaned rule data.
param: \stdClass $mformdata data to insert as new rule entry.

delete_rule($ruleid, $coursecontext = null)   X-Ref
Delete a rule and associated subscriptions, by rule id.

return: bool
param: int $ruleid id of rule to be deleted.
param: \context|null $coursecontext the context of the course - this is passed when we

get_rule($ruleorid)   X-Ref
Get an instance of rule class.

return: rule object with rule id.
param: \stdClass|int $ruleorid A rule object from database or rule id.

update_rule($ruledata)   X-Ref
Update rule data.

return: bool
param: object $ruledata rule data to be updated.

get_rules_by_courseid($courseid, $limitfrom = 0, $limitto = 0, $includesite = true)   X-Ref
Get rules by course id.

return: array List of rules for the given course id, if specified will also include site rules.
param: int $courseid course id of the rule.
param: int $limitfrom Limit from which to fetch rules.
param: int $limitto  Limit to which rules need to be fetched.
param: bool $includesite Determines whether we return site wide rules or not.

count_rules_by_courseid($courseid)   X-Ref
Get rule count by course id.

return: int count of rules present in system visible in the given course id.
param: int $courseid course id of the rule.

get_rules_by_plugin($plugin)   X-Ref
Get rules by plugin name.

return: array List of rules for the given plugin name.
param: string $plugin plugin name of the rule.

get_rules_by_event($eventname)   X-Ref
Get rules by event name.

return: array List of rules for the given event.
param: string $eventname event name of the rule.

get_instances($arr)   X-Ref
Helper method to convert db records to instances.

return: array of rules as instances.
param: array $arr of rules.