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:
Petr Škoda 2012-11-11 16:49:16 +01:00
parent ca48fe5f97
commit e1fa177cf9
7 changed files with 45 additions and 4 deletions

View file

@ -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;
}