diff --git a/edit.php b/edit.php
index 2f0b7ee..dd0a8fa 100644
--- a/edit.php
+++ b/edit.php
@@ -66,10 +66,11 @@ if ($mform->is_cancelled()) {
$DB->update_record('enrol', $instance);
} else {
-// $fields = array('status'=>$data->status, 'name'=>$data->name, 'password'=>$data->password, 'customint1'=>$data->customint1, 'customint2'=>$data->customint2,
-// 'customint3'=>$data->customint3, 'customint4'=>$data->customint4, 'customtext1'=>$data->customtext1,
-// 'roleid'=>$data->roleid, 'enrolperiod'=>$data->enrolperiod, 'enrolstartdate'=>$data->enrolstartdate, 'enrolenddate'=>$data->enrolenddate);
- $fields = array('status'=>$data->status, 'name'=>$data->name, 'customtext1'=>$data->customtext1);
+ $fields = array(
+ 'status' =>$data->status,
+ 'name' =>$data->name,
+ 'roleid' => $data->roleid,
+ 'customtext1' =>$data->customtext1);
$plugin->add_instance($course, $fields);
}
diff --git a/edit_form.php b/edit_form.php
index 22c5303..b0a8162 100644
--- a/edit_form.php
+++ b/edit_form.php
@@ -25,9 +25,21 @@ class enrol_self_edit_form extends moodleform {
$mform->addElement('text', 'name', get_string('custominstancename', 'enrol'));
$mform->setType('name', PARAM_TEXT);
+
$options = array(ENROL_INSTANCE_ENABLED => get_string('yes'),
ENROL_INSTANCE_DISABLED => get_string('no'));
$mform->addElement('select', 'status', get_string('status', 'enrol_apply'), $options);
+ $mform->addHelpButton('status', 'status', 'enrol_apply');
+ $mform->setDefault('status', $plugin->get_config('status'));
+
+ if ($instance->id) {
+ $roles = get_default_enrol_roles($context, $instance->roleid);
+ } else {
+ $roles = get_default_enrol_roles($context, $plugin->get_config('roleid'));
+ }
+ $mform->addElement('select', 'roleid', get_string('defaultrole', 'role'), $roles);
+ $mform->setDefault('roleid', $plugin->get_config('roleid'));
+
$mform->addElement('textarea', 'customtext1', get_string('editdescription', 'enrol_apply'));
diff --git a/lang/de/enrol_apply.php b/lang/de/enrol_apply.php
index be510cd..389e3db 100644
--- a/lang/de/enrol_apply.php
+++ b/lang/de/enrol_apply.php
@@ -36,4 +36,5 @@ $string['apply:unenrolapply'] = 'Sich selbst aus dem Kurs entfernen';
$string['description'] = '';
$string['notification'] = 'Einschreibungsantrag wurde erfolgreich gesendet..
Sie werden via Mail informiert, sobald Ihre Einschreibung bestätigt wurde. Wenn Sie sich in andere Kurse einschreiben wollen, klicken Sie bitte den "Kurskatalog" im Hauptmenu an.';
+$string['status_desc'] = 'Kurszugriff für intern eingeschriebene Nutzer/innen erlauben.';
?>
\ No newline at end of file
diff --git a/lang/en/enrol_apply.php b/lang/en/enrol_apply.php
index 7c73d45..cb5cc0b 100644
--- a/lang/en/enrol_apply.php
+++ b/lang/en/enrol_apply.php
@@ -50,4 +50,8 @@ $string['mailtoteacher_suject'] = 'New Enrollment request!';
$string['setting_edit'] = 'Edit';
$string['editdescription'] = 'Textarea description';
$string['applymanage'] = 'Manage enrolment applications';
+
+$string['status_desc'] = 'Allow course access of internally enrolled users.';
+
+$string['status_help'] = 'This setting determines whether users can be enrolled on apply.';
?>
\ No newline at end of file
diff --git a/lib.php b/lib.php
index 187c91e..eb8f75f 100644
--- a/lib.php
+++ b/lib.php
@@ -11,6 +11,19 @@
*/
class enrol_apply_plugin extends enrol_plugin {
+ /**
+ * Add new instance of enrol plugin with default settings.
+ * @param object $course
+ * @return int id of new instance
+ */
+ public function add_default_instance($course) {
+ $fields = array(
+ 'status' => $this->get_config('status'),
+ 'roleid' => $this->get_config('roleid', 0)
+ );
+ return $this->add_instance($course, $fields);
+ }
+
public function allow_unenrol(stdClass $instance) {
// users with unenrol cap may unenrol other users manually manually
return true;
diff --git a/settings.php b/settings.php
index a1ad917..913aaf9 100644
--- a/settings.php
+++ b/settings.php
@@ -27,6 +27,25 @@ if ($ADMIN->fulltree) {
$settings->add(new admin_setting_configcheckbox('enrol_apply/sendmailtoteacher',
get_string('sendmailtoteacher', 'enrol_apply'), '', 0));
+ //--- enrol instance defaults ----------------------------------------------------------------------------
+ $settings->add(new admin_setting_heading('enrol_manual_defaults',
+ get_string('enrolinstancedefaults', 'admin'), get_string('enrolinstancedefaults_desc', 'admin')));
+
+ $settings->add(new admin_setting_configcheckbox('enrol_apply/defaultenrol',
+ get_string('defaultenrol', 'enrol'), get_string('defaultenrol_desc', 'enrol'), 0));
+
+ $options = array(ENROL_INSTANCE_ENABLED => get_string('yes'),
+ ENROL_INSTANCE_DISABLED => get_string('no'));
+ $settings->add(new admin_setting_configselect('enrol_apply/status',
+ get_string('status', 'enrol_apply'), get_string('status_desc', 'enrol_apply'), ENROL_INSTANCE_ENABLED, $options));
+
+ if (!during_initial_install()) {
+ $options = get_default_enrol_roles(context_system::instance());
+ $student = get_archetype_roles('student');
+ $student = reset($student);
+ $settings->add(new admin_setting_configselect('enrol_apply/roleid',
+ get_string('defaultrole', 'role'), '', $student->id, $options));
+ }
}
if ($hassiteconfig) { // needs this condition or there is error on login page