Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

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.

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

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.

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

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.

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

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.

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

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

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

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

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

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

return: string Plugin name.