diff --git a/.gitignore b/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/lang/en/enrol_apply.php b/lang/en/enrol_apply.php index f6ea2b0..55ad7f8 100644 --- a/lang/en/enrol_apply.php +++ b/lang/en/enrol_apply.php @@ -51,4 +51,13 @@ $string['comment'] = 'Comment'; $string['applymanage'] = 'Manage enrolment applications'; $string['status_desc'] = 'Allow course access of internally enrolled users.'; +$string['user_profile'] = 'User Profile'; + +$string['firstname'] = 'First name'; +$string['lastname'] = 'Surname'; +$string['email'] = 'Email address'; +$string['city'] = 'City/town'; +$string['country'] = 'Country'; +$string['lang'] = 'Preferred language'; +$string['description_editor'] = 'Description'; ?> \ No newline at end of file diff --git a/lib.php b/lib.php index 4a872e6..c788050 100644 --- a/lib.php +++ b/lib.php @@ -78,6 +78,9 @@ class enrol_apply_plugin extends enrol_plugin { $instanceid = optional_param('instance', 0, PARAM_INT); if ($instance->id == $instanceid) { if ($data = $form->get_data()) { + $userInfo = $data; + unset($userInfo->applydescription); + $res = $DB->update_record('user',$userInfo); $enrol = enrol_get_plugin('self'); $timestart = time(); if ($instance->enrolperiod) { @@ -93,8 +96,8 @@ class enrol_apply_plugin extends enrol_plugin { } $this->enrol_user($instance, $USER->id, $roleid, $timestart, $timeend,1); - sendConfirmMailToTeachers($instance->courseid, $instance->id, $data->applydescription); - sendConfirmMailToManagers($instance->courseid,$data->applydescription); + sendConfirmMailToTeachers($instance->courseid, $instance->id, $data); + sendConfirmMailToManagers($instance->courseid,$data); add_to_log($instance->courseid, 'course', 'enrol', '../enrol/users.php?id='.$instance->courseid, $instance->courseid); //there should be userid somewhere! redirect("$CFG->wwwroot/course/view.php?id=$instance->courseid"); @@ -265,7 +268,7 @@ function sendConfirmMail($info){ email_to_user($info, $contact, $apply_setting['confirmmailsubject']->value, html_to_text($body), $body); } -function sendConfirmMailToTeachers($courseid,$instanceid,$desc){ +function sendConfirmMailToTeachers($courseid,$instanceid,$info){ global $DB; global $CFG; global $USER; @@ -279,8 +282,18 @@ function sendConfirmMailToTeachers($courseid,$instanceid,$desc){ foreach($teachers as $teacher){ $editTeacher = $DB->get_record('user',array('id'=>$teacher->userid)); $body = '
'. get_string('coursename', 'enrol_apply') .': '.format_string($course->fullname).'
'; - $body .= ''. get_string('applyuser', 'enrol_apply') .': '.$USER->firstname.' '.$USER->lastname.'
'; - $body .= ''. get_string('comment', 'enrol_apply') .': '.$desc.'
'; + $body .= ''. get_string('applyuser', 'enrol_apply') .': '.$info->firstname.' '.$info->lastname.'
'; + $body .= ''. get_string('comment', 'enrol_apply') .': '.$info->applydescription.'
'; + + $body .= ''. get_string('user_profile', 'enrol_apply').'
'; + $body .= ''. get_string('firstname', 'enrol_apply') .': '.$info->firstname.'
'; + $body .= ''. get_string('lastname', 'enrol_apply') .': '.$info->lastname.'
'; + $body .= ''. get_string('email', 'enrol_apply') .': '.$info->email.'
'; + $body .= ''. get_string('city', 'enrol_apply') .': '.$info->city.'
'; + $body .= ''. get_string('country', 'enrol_apply') .': '.$info->country.'
'; + $body .= ''. get_string('lang', 'enrol_apply') .': '.$info->lang.'
'; + $body .= ''. get_string('description_editor', 'enrol_apply') .': '.$info->description_editor['text'].'
'; + $body .= ''. html_writer::link(new moodle_url("/enrol/apply/apply.php", array('id'=>$courseid,'enrolid'=>$instanceid)), get_string('applymanage', 'enrol_apply')).'
'; $contact = core_user::get_support_user(); $info = $editTeacher; @@ -290,7 +303,7 @@ function sendConfirmMailToTeachers($courseid,$instanceid,$desc){ } } -function sendConfirmMailToManagers($courseid,$desc){ +function sendConfirmMailToManagers($courseid,$info){ global $DB; global $CFG; global $USER; @@ -304,8 +317,16 @@ function sendConfirmMailToManagers($courseid,$desc){ foreach($managers as $manager){ $userWithManagerRole = $DB->get_record('user',array('id'=>$manager->userid)); $body = ''. get_string('coursename', 'enrol_apply') .': '.format_string($course->fullname).'
'; - $body .= ''. get_string('applyuser', 'enrol_apply') .': '.$USER->firstname.' '.$USER->lastname.'
'; - $body .= ''. get_string('comment', 'enrol_apply') .': '.$desc.'
'; + $body .= ''. get_string('applyuser', 'enrol_apply') .': '.$info->firstname.' '.$info->lastname.'
'; + $body .= ''. get_string('comment', 'enrol_apply') .': '.$info->applydescription.'
'; + $body .= ''. get_string('user_profile', 'enrol_apply').'
'; + $body .= ''. get_string('firstname', 'enrol_apply') .': '.$info->firstname.'
'; + $body .= ''. get_string('lastname', 'enrol_apply') .': '.$info->lastname.'
'; + $body .= ''. get_string('email', 'enrol_apply') .': '.$info->email.'
'; + $body .= ''. get_string('city', 'enrol_apply') .': '.$info->city.'
'; + $body .= ''. get_string('country', 'enrol_apply') .': '.$info->country.'
'; + $body .= ''. get_string('lang', 'enrol_apply') .': '.$info->lang.'
'; + $body .= ''. get_string('description_editor', 'enrol_apply') .': '.$info->description_editor['text'].'
'; $body .= ''. html_writer::link(new moodle_url('/enrol/apply/manage.php'), get_string('applymanage', 'enrol_apply')).'
'; $contact = core_user::get_support_user(); $info = $userWithManagerRole; diff --git a/locallib.php b/locallib.php index a668aa5..2162dd3 100644 --- a/locallib.php +++ b/locallib.php @@ -57,6 +57,165 @@ class enrol_apply_enrol_form extends moodleform { $mform->addElement('html', ''.$instance->customtext1.'
'); $mform->addElement('textarea', 'applydescription', get_string('comment', 'enrol_apply'),'cols="80"'); + + //user profile + global $USER,$CFG; + require_once($CFG->libdir.'/gdlib.php'); + require_once($CFG->dirroot.'/user/edit_form.php'); + require_once($CFG->dirroot.'/user/editlib.php'); + require_once($CFG->dirroot.'/user/profile/lib.php'); + require_once($CFG->dirroot.'/user/lib.php'); + + $user = $USER; + $personalcontext = context_user::instance($user->id); + //profile_load_data($user); + + $mform->addElement('header', 'selfheader', 'User profile'); + //useredit_load_preferences($user, false); + + $strrequired = get_string('required'); + foreach (useredit_get_required_name_fields() as $fullname) { + $mform->addElement('text', $fullname, get_string($fullname), 'maxlength="100" size="30"'); + $mform->addRule($fullname, $strrequired, 'required', null, 'client'); + $mform->setType($fullname, PARAM_NOTAGS); + } + $enabledusernamefields = useredit_get_enabled_name_fields(); + foreach ($enabledusernamefields as $addname) { + $mform->addElement('text', $addname, get_string($addname), 'maxlength="100" size="30"'); + $mform->setType($addname, PARAM_NOTAGS); + } + + //Do not show email field if change confirmation is pending + if (!empty($CFG->emailchangeconfirmation) and !empty($user->preference_newemail)) { + $notice = get_string('emailchangepending', 'auth', $user); + $notice .= '