Skip to content
Snippets Groups Projects
Commit a1fe901e authored by Elke Kreim's avatar Elke Kreim
Browse files

Add settings for enrolment of default roles

parent eb978c89
No related branches found
No related tags found
No related merge requests found
...@@ -9,6 +9,9 @@ $string['settingslabel'] = 'HSH course request'; ...@@ -9,6 +9,9 @@ $string['settingslabel'] = 'HSH course request';
$string['categoriesenabledvisiblename'] = 'Course categories'; $string['categoriesenabledvisiblename'] = 'Course categories';
$string['categoriesenabledhelper'] = 'Select course categories for hsh course request form'; $string['categoriesenabledhelper'] = 'Select course categories for hsh course request form';
$string['categoriesenableddefault'] = 'No course category selected'; $string['categoriesenableddefault'] = 'No course category selected';
$string['defaultrolevisiblename'] = 'Default roles';
$string['defaultrolehelper'] = 'Select default role to assign to request user by default additional to editing teacher';
$string['defaultroledefault'] = 'No default role selected';
$string['courserequest'] = 'Course request'; $string['courserequest'] = 'Course request';
$string['courserequestsuccess'] = 'Your course request has been saved successfully. You will be sent an email to inform you whether your request was approved.'; $string['courserequestsuccess'] = 'Your course request has been saved successfully. You will be sent an email to inform you whether your request was approved.';
// request_form // request_form
......
...@@ -374,10 +374,16 @@ class course_request_hsh ...@@ -374,10 +374,16 @@ class course_request_hsh
} }
} }
// < HsH // < HsH
// enrol the requester as teacher if necessary // enrol default roles from plugin config settings
if (!empty($CFG->creatornewroleid) && !isguestuser($user) && !is_enrolled($context, $user, 'moodle/role:assign')) { $default_roles=get_config('local_hsh', 'defaultrole');
if (!empty($default_roles) && !isguestuser($user) && !is_enrolled($context, $user, 'moodle/role:assign')) {
$roles = explode(',', $default_roles);
foreach($roles as $role) {
enrol_try_internal_enrol($course->id, $user->id, $role);
}
} elseif (!empty($CFG->creatornewroleid) && !isguestuser($user) && !is_enrolled($context, $user, 'moodle/role:assign')) {
enrol_try_internal_enrol($course->id, $user->id, $CFG->creatornewroleid); enrol_try_internal_enrol($course->id, $user->id, $CFG->creatornewroleid);
} } // enrol the requester as teacher if necessary
$this->delete(); $this->delete();
......
...@@ -33,8 +33,6 @@ if ($hassiteconfig) { ...@@ -33,8 +33,6 @@ if ($hassiteconfig) {
// Create // Create
$ADMIN->add('localplugins', $settings); $ADMIN->add('localplugins', $settings);
$settings -> add(new admin_setting_configmultiselect( $settings -> add(new admin_setting_configmultiselect(
'local_hsh/categoriesenabled', 'local_hsh/categoriesenabled',
get_string('categoriesenabledvisiblename', 'local_hsh' ), get_string('categoriesenabledvisiblename', 'local_hsh' ),
...@@ -43,22 +41,18 @@ if ($hassiteconfig) { ...@@ -43,22 +41,18 @@ if ($hassiteconfig) {
core_course_category::make_categories_list() core_course_category::make_categories_list()
)); ));
// Get roles as choicelist for selectbutton
$roles = role_fix_names(get_all_roles());
$roleslist = [];
foreach ($roles as $role) {
$roleslist[$role->id] = $role->shortname;
}
// Add a setting field to the settings for this page $settings -> add(new admin_setting_configmultiselect(
// $settings->add(new admin_setting_configtext( 'local_hsh/defaultrole',
// // This is the reference you will use to your configuration get_string('defaultrolevisiblename', 'local_hsh' ),
// 'local_hsh/categoriesenabled', get_string('defaultrolehelper', 'local_hsh' ),
// array(),
// // This is the friendly title for the config, which will be displayed $roleslist
// get_string('categoriesenabledvisiblename', 'local_hsh' ), ));
//
// // This is helper text for this config field
// get_string('categoriesenabledhelper', 'local_hsh' ),
//
// // This is the default value
// get_string('categoriesenableddefault', 'local_hsh' ),
//
// // This is the type of Parameter this config is
// PARAM_TEXT
// ));
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment