mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 09:26:35 +02:00
MDL-36514 add new option to prevent only new self enrolments
Hopefully this will resolve all confusion around the enrol->status flag in this plugin.
This commit is contained in:
parent
ca48fe5f97
commit
e1fa177cf9
7 changed files with 45 additions and 4 deletions
|
@ -48,6 +48,10 @@ class enrol_self_plugin extends enrol_plugin {
|
|||
$key = false;
|
||||
$nokey = false;
|
||||
foreach ($instances as $instance) {
|
||||
if (!$instance->customint6) {
|
||||
// New enrols not allowed.
|
||||
continue;
|
||||
}
|
||||
if ($instance->password or $instance->customint1) {
|
||||
$key = true;
|
||||
} else {
|
||||
|
@ -107,6 +111,12 @@ class enrol_self_plugin extends enrol_plugin {
|
|||
if ($instance->status != ENROL_INSTANCE_ENABLED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$instance->customint6) {
|
||||
// New enrols not allowed.
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($instance->customint5) {
|
||||
require_once("$CFG->dirroot/cohort/lib.php");
|
||||
return cohort_is_member($instance->customint5, $USER->id);
|
||||
|
@ -200,6 +210,11 @@ class enrol_self_plugin extends enrol_plugin {
|
|||
return null;
|
||||
}
|
||||
|
||||
if (!$instance->customint6) {
|
||||
// New enrols not allowed.
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($instance->customint5) {
|
||||
require_once("$CFG->dirroot/cohort/lib.php");
|
||||
if (!cohort_is_member($instance->customint5, $USER->id)) {
|
||||
|
@ -298,6 +313,7 @@ class enrol_self_plugin extends enrol_plugin {
|
|||
$fields['customint3'] = $this->get_config('maxenrolled');
|
||||
$fields['customint4'] = $this->get_config('sendcoursewelcomemessage');
|
||||
$fields['customint5'] = 0;
|
||||
$fields['customint6'] = $this->get_config('newenrols');
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue