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.

Class represents a single rule.

Copyright: 2014 onwards Ankit Agarwal <ankit.agrr@gmail.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 275 lines (9 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: rule  - X-Ref

Class represents a single rule.

__construct($rule)   X-Ref
Constructor.

param: \stdClass $rule A rule object from database.

can_manage_rule($userid = null)   X-Ref
Can the user manage this rule? Defaults to $USER.

return: bool true if the current user can manage this rule, else false.
param: int $userid Check against this userid.

duplicate_rule($finalcourseid)   X-Ref
Api to duplicate a rule in a given courseid.

param: int $finalcourseid Final course id.

delete_rule()   X-Ref
Delete this rule.

Note: It also removes all associated subscriptions.

get_subscribe_options($courseid)   X-Ref
Gets the rule subscribe options for a given course and rule.

Could be a select drop down with a list of possible module
instances or a single link to subscribe if the rule plugin
is not a module.

return: \single_select|\moodle_url|string
param: int $courseid course id

subscribe_user($courseid, $cmid, $userid = 0)   X-Ref
Subscribe an user to this rule.

param: int $courseid Course id.
param: int $cmid Course module id.
param: int $userid User id.

__get($prop)   X-Ref
Magic get method.

return: mixed
param: string $prop property to get.

get_mform_set_data()   X-Ref
Return the rule data to be used while setting mform.


get_event_name()   X-Ref
Method to get event name.

return: string

get_filters_description()   X-Ref
Get filter description.

return: string

get_course_name($context)   X-Ref
Get properly formatted name of the course associated.

return: string The course fullname.
param: \context $context context where this name would be displayed.

get_name(\context $context)   X-Ref
Get properly formatted name of the rule associated.

return: string Formatted name of the rule.
param: \context $context context where this name would be displayed.

get_description(\context $context)   X-Ref
Get properly formatted description of the rule associated.

return: string Formatted description of the rule.
param: \context $context context where this description would be displayed.

get_plugin_name()   X-Ref
Get name of the plugin associated with this rule

return: string Plugin name.