mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
MDL-45849 enrol_self: Added self enrol capability
This commit is contained in:
parent
49a9e8b07d
commit
37c99bd07e
@ -73,4 +73,13 @@ $capabilities = array(
|
||||
)
|
||||
),
|
||||
|
||||
/* Ability to enrol self in courses. */
|
||||
'enrol/self:enrolself' => array(
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'archetypes' => array(
|
||||
'user' => CAP_ALLOW,
|
||||
)
|
||||
),
|
||||
|
||||
);
|
||||
|
@ -98,6 +98,7 @@ $string['requirepassword'] = 'Require enrolment key';
|
||||
$string['requirepassword_desc'] = 'Require enrolment key in new courses and prevent removing of enrolment key from existing courses.';
|
||||
$string['role'] = 'Default assigned role';
|
||||
$string['self:config'] = 'Configure self enrol instances';
|
||||
$string['self:enrolself'] = 'Self enrol in course';
|
||||
$string['self:holdkey'] = 'Appear as the self enrolment key holder';
|
||||
$string['self:manage'] = 'Manage enrolled users';
|
||||
$string['self:unenrol'] = 'Unenrol users from course';
|
||||
|
@ -248,6 +248,11 @@ class enrol_self_plugin extends enrol_plugin {
|
||||
return get_string('canntenrol', 'enrol_self');
|
||||
}
|
||||
|
||||
// Check if user has the capability to enrol in this context.
|
||||
if (!has_capability('enrol/self:enrolself', context_course::instance($instance->courseid))) {
|
||||
return get_string('canntenrol', 'enrol_self');
|
||||
}
|
||||
|
||||
if ($instance->enrolstartdate != 0 and $instance->enrolstartdate > time()) {
|
||||
return get_string('canntenrolearly', 'enrol_self', userdate($instance->enrolstartdate));
|
||||
}
|
||||
|
@ -24,6 +24,6 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2020061500; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->version = 2020061501; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2020060900; // Requires this Moodle version
|
||||
$plugin->component = 'enrol_self'; // Full name of the plugin (used for diagnostics)
|
||||
|
Loading…
x
Reference in New Issue
Block a user