Browse Source

Further adjustments

develop_fields
Flottertotte 10 years ago
parent
commit
d311304059
  1. 1
      edit_form.php
  2. 3
      lang/en/enrol_apply.php
  3. 139
      lib.php
  4. 13
      locallib.php
  5. 10
      settings.php

1
edit_form.php

@ -41,7 +41,6 @@ class enrol_self_edit_form extends moodleform {
$mform->setDefault('roleid', $plugin->get_config('roleid')); $mform->setDefault('roleid', $plugin->get_config('roleid'));
$mform->addElement('textarea', 'customtext1', get_string('editdescription', 'enrol_apply')); $mform->addElement('textarea', 'customtext1', get_string('editdescription', 'enrol_apply'));
$mform->addElement('hidden', 'id'); $mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT); $mform->setType('id', PARAM_INT);

3
lang/en/enrol_apply.php

@ -52,4 +52,7 @@ $string['applymanage'] = 'Manage enrolment applications';
$string['status_desc'] = 'Allow course access of internally enrolled users.'; $string['status_desc'] = 'Allow course access of internally enrolled users.';
$string['user_profile'] = 'User Profile'; $string['user_profile'] = 'User Profile';
$string['show_standard_user_profile'] = 'Show standard user profile fields on enrolment screen';
$string['show_extra_user_profile'] = 'Show extra user profile fields on enrolment screen';
?> ?>

139
lib.php

@ -82,9 +82,15 @@ class enrol_apply_plugin extends enrol_plugin {
$applydescription = $userInfo->applydescription; $applydescription = $userInfo->applydescription;
unset($userInfo->applydescription); unset($userInfo->applydescription);
$userInfo->id = $USER->id; $userInfo->id = $USER->id;
$res = $DB->update_record('user',$userInfo);
//echo "<pre>";print_r($userInfo);exit; $apply_setting = $DB->get_records_sql("select name,value from ".$CFG->prefix."config_plugins where plugin='enrol_apply'");
//var_dump($res);exit; if($apply_setting['show_standard_user_profile']->value == 1 && $apply_setting['show_extra_user_profile']->value == 0){
profile_save_data($userInfo);
//$res = $DB->update_record('user',$userInfoProfile);
}else{
profile_save_data($userInfo);
$res = $DB->update_record('user',$userInfo);
}
$enrol = enrol_get_plugin('self'); $enrol = enrol_get_plugin('self');
$timestart = time(); $timestart = time();
if ($instance->enrolperiod) { if ($instance->enrolperiod) {
@ -286,34 +292,45 @@ function sendConfirmMailToTeachers($courseid,$instanceid,$info,$applydescription
foreach($teachers as $teacher){ foreach($teachers as $teacher){
$editTeacher = $DB->get_record('user',array('id'=>$teacher->userid)); $editTeacher = $DB->get_record('user',array('id'=>$teacher->userid));
$body = '<p>'. get_string('coursename', 'enrol_apply') .': '.format_string($course->fullname).'</p>'; $body = '<p>'. get_string('coursename', 'enrol_apply') .': '.format_string($course->fullname).'</p>';
$body .= '<p>'. get_string('applyuser', 'enrol_apply') .': '.$info->firstname.' '.$info->lastname.'</p>'; $body .= '<p>'. get_string('applyuser', 'enrol_apply') .': '.$USER->firstname.' '.$USER->lastname.'</p>';
$body .= '<p>'. get_string('comment', 'enrol_apply') .': '.$applydescription.'</p>'; $body .= '<p>'. get_string('comment', 'enrol_apply') .': '.$applydescription.'</p>';
$body .= '<p><strong>'. get_string('user_profile', 'enrol_apply').'</strong></p>'; if($apply_setting['show_standard_user_profile']->value == 0){
$body .= '<p>'. get_string('firstname') .': '.$info->firstname.'</p>'; $body .= '<p><strong>'. get_string('user_profile', 'enrol_apply').'</strong></p>';
$body .= '<p>'. get_string('lastname') .': '.$info->lastname.'</p>'; $body .= '<p>'. get_string('firstname') .': '.$info->firstname.'</p>';
$body .= '<p>'. get_string('email') .': '.$info->email.'</p>'; $body .= '<p>'. get_string('lastname') .': '.$info->lastname.'</p>';
$body .= '<p>'. get_string('city') .': '.$info->city.'</p>'; $body .= '<p>'. get_string('email') .': '.$info->email.'</p>';
$body .= '<p>'. get_string('country') .': '.$info->country.'</p>'; $body .= '<p>'. get_string('city') .': '.$info->city.'</p>';
$body .= '<p>'. get_string('preferredlanguage') .': '.$info->lang.'</p>'; $body .= '<p>'. get_string('country') .': '.$info->country.'</p>';
$body .= '<p>'. get_string('description') .': '.$info->description_editor['text'].'</p>'; $body .= '<p>'. get_string('preferredlanguage') .': '.$info->lang.'</p>';
$body .= '<p>'. get_string('description') .': '.$info->description_editor['text'].'</p>';
$body .= '<p>'. get_string('firstnamephonetic') .': '.$info->firstnamephonetic.'</p>';
$body .= '<p>'. get_string('lastnamephonetic') .': '.$info->lastnamephonetic.'</p>'; $body .= '<p>'. get_string('firstnamephonetic') .': '.$info->firstnamephonetic.'</p>';
$body .= '<p>'. get_string('middlename') .': '.$info->middlename.'</p>'; $body .= '<p>'. get_string('lastnamephonetic') .': '.$info->lastnamephonetic.'</p>';
$body .= '<p>'. get_string('alternatename') .': '.$info->alternatename.'</p>'; $body .= '<p>'. get_string('middlename') .': '.$info->middlename.'</p>';
$body .= '<p>'. get_string('url') .': '.$info->url.'</p>'; $body .= '<p>'. get_string('alternatename') .': '.$info->alternatename.'</p>';
$body .= '<p>'. get_string('icqnumber') .': '.$info->icq.'</p>'; $body .= '<p>'. get_string('url') .': '.$info->url.'</p>';
$body .= '<p>'. get_string('skypeid') .': '.$info->skype.'</p>'; $body .= '<p>'. get_string('icqnumber') .': '.$info->icq.'</p>';
$body .= '<p>'. get_string('aimid') .': '.$info->aim.'</p>'; $body .= '<p>'. get_string('skypeid') .': '.$info->skype.'</p>';
$body .= '<p>'. get_string('yahooid') .': '.$info->yahoo.'</p>'; $body .= '<p>'. get_string('aimid') .': '.$info->aim.'</p>';
$body .= '<p>'. get_string('msnid') .': '.$info->msn.'</p>'; $body .= '<p>'. get_string('yahooid') .': '.$info->yahoo.'</p>';
$body .= '<p>'. get_string('idnumber') .': '.$info->idnumber.'</p>'; $body .= '<p>'. get_string('msnid') .': '.$info->msn.'</p>';
$body .= '<p>'. get_string('institution') .': '.$info->institution.'</p>'; $body .= '<p>'. get_string('idnumber') .': '.$info->idnumber.'</p>';
$body .= '<p>'. get_string('department') .': '.$info->department.'</p>'; $body .= '<p>'. get_string('institution') .': '.$info->institution.'</p>';
$body .= '<p>'. get_string('phone') .': '.$info->phone1.'</p>'; $body .= '<p>'. get_string('department') .': '.$info->department.'</p>';
$body .= '<p>'. get_string('phone2') .': '.$info->phone2.'</p>'; $body .= '<p>'. get_string('phone') .': '.$info->phone1.'</p>';
$body .= '<p>'. get_string('address') .': '.$info->address.'</p>'; $body .= '<p>'. get_string('phone2') .': '.$info->phone2.'</p>';
$body .= '<p>'. get_string('address') .': '.$info->address.'</p>';
}
if($apply_setting['show_extra_user_profile']->value == 0){
require_once($CFG->dirroot.'/user/profile/lib.php');
$user = $DB->get_record('user',array('id'=>$USER->id));
profile_load_custom_fields($user);
foreach ($user->profile as $key => $value) {
$body .= '<p>'. $key .': '.$value.'</p>';
}
}
$body .= '<p>'. html_writer::link(new moodle_url("/enrol/apply/apply.php", array('id'=>$courseid,'enrolid'=>$instanceid)), get_string('applymanage', 'enrol_apply')).'</p>'; $body .= '<p>'. html_writer::link(new moodle_url("/enrol/apply/apply.php", array('id'=>$courseid,'enrolid'=>$instanceid)), get_string('applymanage', 'enrol_apply')).'</p>';
$contact = core_user::get_support_user(); $contact = core_user::get_support_user();
@ -338,33 +355,45 @@ function sendConfirmMailToManagers($courseid,$info,$applydescription){
foreach($managers as $manager){ foreach($managers as $manager){
$userWithManagerRole = $DB->get_record('user',array('id'=>$manager->userid)); $userWithManagerRole = $DB->get_record('user',array('id'=>$manager->userid));
$body = '<p>'. get_string('coursename', 'enrol_apply') .': '.format_string($course->fullname).'</p>'; $body = '<p>'. get_string('coursename', 'enrol_apply') .': '.format_string($course->fullname).'</p>';
$body .= '<p>'. get_string('applyuser', 'enrol_apply') .': '.$info->firstname.' '.$info->lastname.'</p>'; $body .= '<p>'. get_string('applyuser', 'enrol_apply') .': '.$USER->firstname.' '.$USER->lastname.'</p>';
$body .= '<p>'. get_string('comment', 'enrol_apply') .': '.$applydescription.'</p>'; $body .= '<p>'. get_string('comment', 'enrol_apply') .': '.$applydescription.'</p>';
$body .= '<p><strong>'. get_string('user_profile', 'enrol_apply').'</strong></p>'; if($apply_setting['show_standard_user_profile']->value == 0){
$body .= '<p>'. get_string('firstname') .': '.$info->firstname.'</p>'; $body .= '<p><strong>'. get_string('user_profile', 'enrol_apply').'</strong></p>';
$body .= '<p>'. get_string('lastname') .': '.$info->lastname.'</p>'; $body .= '<p>'. get_string('firstname') .': '.$info->firstname.'</p>';
$body .= '<p>'. get_string('email') .': '.$info->email.'</p>'; $body .= '<p>'. get_string('lastname') .': '.$info->lastname.'</p>';
$body .= '<p>'. get_string('city') .': '.$info->city.'</p>'; $body .= '<p>'. get_string('email') .': '.$info->email.'</p>';
$body .= '<p>'. get_string('country') .': '.$info->country.'</p>'; $body .= '<p>'. get_string('city') .': '.$info->city.'</p>';
$body .= '<p>'. get_string('preferredlanguage') .': '.$info->lang.'</p>'; $body .= '<p>'. get_string('country') .': '.$info->country.'</p>';
$body .= '<p>'. get_string('description') .': '.$info->description_editor['text'].'</p>'; $body .= '<p>'. get_string('preferredlanguage') .': '.$info->lang.'</p>';
$body .= '<p>'. get_string('description') .': '.$info->description_editor['text'].'</p>';
$body .= '<p>'. get_string('firstnamephonetic') .': '.$info->firstnamephonetic.'</p>';
$body .= '<p>'. get_string('lastnamephonetic') .': '.$info->lastnamephonetic.'</p>'; $body .= '<p>'. get_string('firstnamephonetic') .': '.$info->firstnamephonetic.'</p>';
$body .= '<p>'. get_string('middlename') .': '.$info->middlename.'</p>'; $body .= '<p>'. get_string('lastnamephonetic') .': '.$info->lastnamephonetic.'</p>';
$body .= '<p>'. get_string('alternatename') .': '.$info->alternatename.'</p>'; $body .= '<p>'. get_string('middlename') .': '.$info->middlename.'</p>';
$body .= '<p>'. get_string('url') .': '.$info->url.'</p>'; $body .= '<p>'. get_string('alternatename') .': '.$info->alternatename.'</p>';
$body .= '<p>'. get_string('icqnumber') .': '.$info->icq.'</p>'; $body .= '<p>'. get_string('url') .': '.$info->url.'</p>';
$body .= '<p>'. get_string('skypeid') .': '.$info->skype.'</p>'; $body .= '<p>'. get_string('icqnumber') .': '.$info->icq.'</p>';
$body .= '<p>'. get_string('aimid') .': '.$info->aim.'</p>'; $body .= '<p>'. get_string('skypeid') .': '.$info->skype.'</p>';
$body .= '<p>'. get_string('yahooid') .': '.$info->yahoo.'</p>'; $body .= '<p>'. get_string('aimid') .': '.$info->aim.'</p>';
$body .= '<p>'. get_string('msnid') .': '.$info->msn.'</p>'; $body .= '<p>'. get_string('yahooid') .': '.$info->yahoo.'</p>';
$body .= '<p>'. get_string('idnumber') .': '.$info->idnumber.'</p>'; $body .= '<p>'. get_string('msnid') .': '.$info->msn.'</p>';
$body .= '<p>'. get_string('institution') .': '.$info->institution.'</p>'; $body .= '<p>'. get_string('idnumber') .': '.$info->idnumber.'</p>';
$body .= '<p>'. get_string('department') .': '.$info->department.'</p>'; $body .= '<p>'. get_string('institution') .': '.$info->institution.'</p>';
$body .= '<p>'. get_string('phone') .': '.$info->phone1.'</p>'; $body .= '<p>'. get_string('department') .': '.$info->department.'</p>';
$body .= '<p>'. get_string('phone2') .': '.$info->phone2.'</p>'; $body .= '<p>'. get_string('phone') .': '.$info->phone1.'</p>';
$body .= '<p>'. get_string('address') .': '.$info->address.'</p>'; $body .= '<p>'. get_string('phone2') .': '.$info->phone2.'</p>';
$body .= '<p>'. get_string('address') .': '.$info->address.'</p>';
}
if($apply_setting['show_extra_user_profile']->value == 0){
require_once($CFG->dirroot.'/user/profile/lib.php');
$user = $DB->get_record('user',array('id'=>$USER->id));
profile_load_custom_fields($user);
foreach ($user->profile as $key => $value) {
$body .= '<p>'. $key .': '.$value.'</p>';
}
}
$body .= '<p>'. html_writer::link(new moodle_url('/enrol/apply/manage.php'), get_string('applymanage', 'enrol_apply')).'</p>'; $body .= '<p>'. html_writer::link(new moodle_url('/enrol/apply/manage.php'), get_string('applymanage', 'enrol_apply')).'</p>';
$contact = core_user::get_support_user(); $contact = core_user::get_support_user();
$info = $userWithManagerRole; $info = $userWithManagerRole;

13
locallib.php

@ -60,7 +60,7 @@ class enrol_apply_enrol_form extends moodleform {
$mform->addElement('textarea', 'applydescription', get_string('comment', 'enrol_apply'),'cols="80"'); $mform->addElement('textarea', 'applydescription', get_string('comment', 'enrol_apply'),'cols="80"');
//user profile //user profile
global $USER,$CFG; global $USER,$CFG,$DB;
require_once($CFG->libdir.'/gdlib.php'); require_once($CFG->libdir.'/gdlib.php');
require_once($CFG->dirroot.'/user/edit_form.php'); require_once($CFG->dirroot.'/user/edit_form.php');
require_once($CFG->dirroot.'/user/editlib.php'); require_once($CFG->dirroot.'/user/editlib.php');
@ -70,8 +70,15 @@ class enrol_apply_enrol_form extends moodleform {
$user = $DB->get_record('user',array('id'=>$USER->id)); $user = $DB->get_record('user',array('id'=>$USER->id));
$editoroptions = $filemanageroptions = null; $editoroptions = $filemanageroptions = null;
useredit_shared_definition($mform, $editoroptions, $filemanageroptions); $apply_setting = $DB->get_records_sql("select name,value from ".$CFG->prefix."config_plugins where plugin='enrol_apply'");
profile_definition($mform, $user->id);
if($apply_setting['show_standard_user_profile']->value == 0){
useredit_shared_definition($mform, $editoroptions, $filemanageroptions);
}
if($apply_setting['show_extra_user_profile']->value == 0){
profile_definition($mform, $user->id);
}
$profile_default_values = $user; $profile_default_values = $user;
if (is_object($profile_default_values)) { if (is_object($profile_default_values)) {

10
settings.php

@ -41,6 +41,16 @@ if ($ADMIN->fulltree) {
$settings->add(new admin_setting_configselect('enrol_apply/status', $settings->add(new admin_setting_configselect('enrol_apply/status',
get_string('status', 'enrol_apply'), get_string('status_desc', 'enrol_apply'), ENROL_INSTANCE_ENABLED, $options)); get_string('status', 'enrol_apply'), get_string('status_desc', 'enrol_apply'), ENROL_INSTANCE_ENABLED, $options));
$options = array(ENROL_INSTANCE_ENABLED => get_string('yes'),
ENROL_INSTANCE_DISABLED => get_string('no'));
$settings->add(new admin_setting_configselect('enrol_apply/show_standard_user_profile',
get_string('show_standard_user_profile', 'enrol_apply'), '', ENROL_INSTANCE_ENABLED, $options));
$options = array(ENROL_INSTANCE_ENABLED => get_string('yes'),
ENROL_INSTANCE_DISABLED => get_string('no'));
$settings->add(new admin_setting_configselect('enrol_apply/show_extra_user_profile',
get_string('show_extra_user_profile', 'enrol_apply'), '', ENROL_INSTANCE_ENABLED, $options));
if (!during_initial_install()) { if (!during_initial_install()) {
$options = get_default_enrol_roles(context_system::instance()); $options = get_default_enrol_roles(context_system::instance());
$student = get_archetype_roles('student'); $student = get_archetype_roles('student');

Loading…
Cancel
Save