diff --git a/lang/en/enrol_apply.php b/lang/en/enrol_apply.php index 55ad7f8..8d280cb 100644 --- a/lang/en/enrol_apply.php +++ b/lang/en/enrol_apply.php @@ -52,12 +52,4 @@ $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 c788050..d3393d9 100644 --- a/lib.php +++ b/lib.php @@ -79,8 +79,12 @@ class enrol_apply_plugin extends enrol_plugin { if ($instance->id == $instanceid) { if ($data = $form->get_data()) { $userInfo = $data; + $applydescription = $userInfo->applydescription; unset($userInfo->applydescription); + $userInfo->id = $USER->id; $res = $DB->update_record('user',$userInfo); + //echo "
";print_r($userInfo);exit; + //var_dump($res);exit; $enrol = enrol_get_plugin('self'); $timestart = time(); if ($instance->enrolperiod) { @@ -96,8 +100,8 @@ class enrol_apply_plugin extends enrol_plugin { } $this->enrol_user($instance, $USER->id, $roleid, $timestart, $timeend,1); - sendConfirmMailToTeachers($instance->courseid, $instance->id, $data); - sendConfirmMailToManagers($instance->courseid,$data); + sendConfirmMailToTeachers($instance->courseid, $instance->id, $data, $applydescription); + sendConfirmMailToManagers($instance->courseid,$data, $applydescription); 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"); @@ -268,7 +272,7 @@ function sendConfirmMail($info){ email_to_user($info, $contact, $apply_setting['confirmmailsubject']->value, html_to_text($body), $body); } -function sendConfirmMailToTeachers($courseid,$instanceid,$info){ +function sendConfirmMailToTeachers($courseid,$instanceid,$info,$applydescription){ global $DB; global $CFG; global $USER; @@ -283,16 +287,33 @@ function sendConfirmMailToTeachers($courseid,$instanceid,$info){ $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') .': '.$info->firstname.' '.$info->lastname.'
'; - $body .= ''. get_string('comment', 'enrol_apply') .': '.$info->applydescription.'
'; + $body .= ''. get_string('comment', 'enrol_apply') .': '.$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 .= ''. get_string('firstname') .': '.$info->firstname.'
'; + $body .= ''. get_string('lastname') .': '.$info->lastname.'
'; + $body .= ''. get_string('email') .': '.$info->email.'
'; + $body .= ''. get_string('city') .': '.$info->city.'
'; + $body .= ''. get_string('country') .': '.$info->country.'
'; + $body .= ''. get_string('lang') .': '.$info->lang.'
'; + $body .= ''. get_string('description') .': '.$info->description_editor['text'].'
'; + + $body .= ''. get_string('firstnamephonetic') .': '.$info->firstnamephonetic.'
'; + $body .= ''. get_string('lastnamephonetic') .': '.$info->lastnamephonetic.'
'; + $body .= ''. get_string('middlename') .': '.$info->middlename.'
'; + $body .= ''. get_string('alternatename') .': '.$info->alternatename.'
'; + $body .= ''. get_string('url') .': '.$info->url.'
'; + $body .= ''. get_string('icq') .': '.$info->icq.'
'; + $body .= ''. get_string('skype') .': '.$info->skype.'
'; + $body .= ''. get_string('aim') .': '.$info->aim.'
'; + $body .= ''. get_string('yahoo') .': '.$info->yahoo.'
'; + $body .= ''. get_string('msn') .': '.$info->msn.'
'; + $body .= ''. get_string('idnumber') .': '.$info->idnumber.'
'; + $body .= ''. get_string('institution') .': '.$info->institution.'
'; + $body .= ''. get_string('department') .': '.$info->department.'
'; + $body .= ''. get_string('phone1') .': '.$info->phone1.'
'; + $body .= ''. get_string('phone2') .': '.$info->phone2.'
'; + $body .= ''. get_string('address') .': '.$info->address.'
'; $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(); @@ -303,7 +324,7 @@ function sendConfirmMailToTeachers($courseid,$instanceid,$info){ } } -function sendConfirmMailToManagers($courseid,$info){ +function sendConfirmMailToManagers($courseid,$info,$applydescription){ global $DB; global $CFG; global $USER; @@ -318,15 +339,32 @@ function sendConfirmMailToManagers($courseid,$info){ $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') .': '.$info->firstname.' '.$info->lastname.'
'; - $body .= ''. get_string('comment', 'enrol_apply') .': '.$info->applydescription.'
'; + $body .= ''. get_string('comment', 'enrol_apply') .': '.$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 .= ''. get_string('firstname') .': '.$info->firstname.'
'; + $body .= ''. get_string('lastname') .': '.$info->lastname.'
'; + $body .= ''. get_string('email') .': '.$info->email.'
'; + $body .= ''. get_string('city') .': '.$info->city.'
'; + $body .= ''. get_string('country') .': '.$info->country.'
'; + $body .= ''. get_string('lang') .': '.$info->lang.'
'; + $body .= ''. get_string('description') .': '.$info->description_editor['text'].'
'; + + $body .= ''. get_string('firstnamephonetic') .': '.$info->firstnamephonetic.'
'; + $body .= ''. get_string('lastnamephonetic') .': '.$info->lastnamephonetic.'
'; + $body .= ''. get_string('middlename') .': '.$info->middlename.'
'; + $body .= ''. get_string('alternatename') .': '.$info->alternatename.'
'; + $body .= ''. get_string('url') .': '.$info->url.'
'; + $body .= ''. get_string('icq') .': '.$info->icq.'
'; + $body .= ''. get_string('skype') .': '.$info->skype.'
'; + $body .= ''. get_string('aim') .': '.$info->aim.'
'; + $body .= ''. get_string('yahoo') .': '.$info->yahoo.'
'; + $body .= ''. get_string('msn') .': '.$info->msn.'
'; + $body .= ''. get_string('idnumber') .': '.$info->idnumber.'
'; + $body .= ''. get_string('institution') .': '.$info->institution.'
'; + $body .= ''. get_string('department') .': '.$info->department.'
'; + $body .= ''. get_string('phone1') .': '.$info->phone1.'
'; + $body .= ''. get_string('phone2') .': '.$info->phone2.'
'; + $body .= ''. get_string('address') .': '.$info->address.'
'; $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 2162dd3..578be5f 100644 --- a/locallib.php +++ b/locallib.php @@ -37,6 +37,7 @@ class enrol_apply_enrol_form extends moodleform { } public function definition() { + global $DB; $mform = $this->_form; $instance = $this->_customdata; $this->instance = $instance; @@ -66,149 +67,11 @@ class enrol_apply_enrol_form extends moodleform { 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); + $user = $DB->get_record('user',array('id'=>$USER->id)); + $editoroptions = $filemanageroptions = null; - $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 .= '
' - . get_string('emailchangecancel', 'auth') . ''; - $mform->addElement('static', 'emailpending', get_string('email'), $notice); - } else { - $mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="30"'); - $mform->addRule('email', $strrequired, 'required', null, 'client'); - $mform->setType('email', PARAM_EMAIL); - } - - $choices = array(); - $choices['0'] = get_string('emaildisplayno'); - $choices['1'] = get_string('emaildisplayyes'); - $choices['2'] = get_string('emaildisplaycourse'); - $mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices); - $mform->setDefault('maildisplay', 2); - - $choices = array(); - $choices['0'] = get_string('textformat'); - $choices['1'] = get_string('htmlformat'); - $mform->addElement('select', 'mailformat', get_string('emailformat'), $choices); - $mform->setDefault('mailformat', 1); - - if (!empty($CFG->allowusermailcharset)) { - $choices = array(); - $charsets = get_list_of_charsets(); - if (!empty($CFG->sitemailcharset)) { - $choices['0'] = get_string('site').' ('.$CFG->sitemailcharset.')'; - } else { - $choices['0'] = get_string('site').' (UTF-8)'; - } - $choices = array_merge($choices, $charsets); - $mform->addElement('select', 'preference_mailcharset', get_string('emailcharset'), $choices); - } - - $choices = array(); - $choices['0'] = get_string('emaildigestoff'); - $choices['1'] = get_string('emaildigestcomplete'); - $choices['2'] = get_string('emaildigestsubjects'); - $mform->addElement('select', 'maildigest', get_string('emaildigest'), $choices); - $mform->setDefault('maildigest', 0); - $mform->addHelpButton('maildigest', 'emaildigest'); - - $choices = array(); - $choices['1'] = get_string('autosubscribeyes'); - $choices['0'] = get_string('autosubscribeno'); - $mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices); - $mform->setDefault('autosubscribe', 1); - - if (!empty($CFG->forum_trackreadposts)) { - $choices = array(); - $choices['0'] = get_string('trackforumsno'); - $choices['1'] = get_string('trackforumsyes'); - $mform->addElement('select', 'trackforums', get_string('trackforums'), $choices); - $mform->setDefault('trackforums', 0); - } - - $editors = editors_get_enabled(); - if (count($editors) > 1) { - $choices = array('' => get_string('defaulteditor')); - $firsteditor = ''; - foreach (array_keys($editors) as $editor) { - if (!$firsteditor) { - $firsteditor = $editor; - } - $choices[$editor] = get_string('pluginname', 'editor_' . $editor); - } - $mform->addElement('select', 'preference_htmleditor', get_string('textediting'), $choices); - $mform->setDefault('preference_htmleditor', ''); - } else { - // Empty string means use the first chosen text editor. - $mform->addElement('hidden', 'preference_htmleditor'); - $mform->setDefault('preference_htmleditor', ''); - $mform->setType('preference_htmleditor', PARAM_PLUGIN); - } - - $mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="21"'); - $mform->setType('city', PARAM_TEXT); - if (!empty($CFG->defaultcity)) { - $mform->setDefault('city', $CFG->defaultcity); - } - - $choices = get_string_manager()->get_list_of_countries(); - $choices= array(''=>get_string('selectacountry').'...') + $choices; - $mform->addElement('select', 'country', get_string('selectacountry'), $choices); - if (!empty($CFG->country)) { - $mform->setDefault('country', $CFG->country); - } - - $choices = get_list_of_timezones(); - $choices['99'] = get_string('serverlocaltime'); - if ($CFG->forcetimezone != 99) { - $mform->addElement('static', 'forcedtimezone', get_string('timezone'), $choices[$CFG->forcetimezone]); - } else { - $mform->addElement('select', 'timezone', get_string('timezone'), $choices); - $mform->setDefault('timezone', '99'); - } - - $mform->addElement('select', 'lang', get_string('preferredlanguage'), get_string_manager()->get_list_of_translations()); - $mform->setDefault('lang', $CFG->lang); - - // Multi-Calendar Support - see MDL-18375. - $calendartypes = \core_calendar\type_factory::get_list_of_calendar_types(); - // We do not want to show this option unless there is more than one calendar type to display. - if (count($calendartypes) > 1) { - $mform->addElement('select', 'calendartype', get_string('preferredcalendar', 'calendar'), $calendartypes); - } - - if (!empty($CFG->allowuserthemes)) { - $choices = array(); - $choices[''] = get_string('default'); - $themes = get_list_of_themes(); - foreach ($themes as $key=>$theme) { - if (empty($theme->hidefromselector)) { - $choices[$key] = get_string('pluginname', 'theme_'.$theme->name); - } - } - $mform->addElement('select', 'theme', get_string('preferredtheme'), $choices); - } - - $mform->addElement('editor', 'description_editor', get_string('userdescription'), null, null); - $mform->setType('description_editor', PARAM_CLEANHTML); + useredit_shared_definition($mform, $editoroptions, $filemanageroptions); + profile_definition($mform, $user->id); $profile_default_values = $user; if (is_object($profile_default_values)) { @@ -225,6 +88,10 @@ class enrol_apply_enrol_form extends moodleform { $mform->addElement('hidden', 'instance'); $mform->setType('instance', PARAM_INT); $mform->setDefault('instance', $instance->id); + + //$mform->addElement('html',""); + //$mform->addElement('html',''); + //$mform->addElement('html',''); } public function validation($data, $files) { diff --git a/version.php b/version.php index ee85139..b670adf 100644 --- a/version.php +++ b/version.php @@ -18,7 +18,7 @@ */ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2015012500; +$plugin->version = 2015032701; $plugin->requires = 2011080100; $plugin->maturity = MATURITY_STABLE; $plugin->release = 'Course Enrol Apply Plugin Version 1.3.1 (build 2014091000)';