@ -79,8 +79,12 @@ class enrol_apply_plugin extends enrol_plugin {
if ($instance->id == $instanceid) {
if ($instance->id == $instanceid) {
if ($data = $form->get_data()) {
if ($data = $form->get_data()) {
$userInfo = $data;
$userInfo = $data;
$applydescription = $userInfo->applydescription;
unset($userInfo->applydescription);
unset($userInfo->applydescription);
$userInfo->id = $USER->id;
$res = $DB->update_record('user',$userInfo);
$res = $DB->update_record('user',$userInfo);
//echo "< pre > ";print_r($userInfo);exit;
//var_dump($res);exit;
$enrol = enrol_get_plugin('self');
$enrol = enrol_get_plugin('self');
$timestart = time();
$timestart = time();
if ($instance->enrolperiod) {
if ($instance->enrolperiod) {
@ -96,8 +100,8 @@ class enrol_apply_plugin extends enrol_plugin {
}
}
$this->enrol_user($instance, $USER->id, $roleid, $timestart, $timeend,1);
$this->enrol_user($instance, $USER->id, $roleid, $timestart, $timeend,1);
sendConfirmMailToTeachers($instance->courseid, $instance->id, $data);
sendConfirmMailToTeachers($instance->courseid, $instance->id, $data, $applydescription );
sendConfirmMailToManagers($instance->courseid,$data);
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!
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");
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);
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 $DB;
global $CFG;
global $CFG;
global $USER;
global $USER;
@ -283,16 +287,33 @@ function sendConfirmMailToTeachers($courseid,$instanceid,$info){
$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') .': '.$info->firstname.' '.$info->lastname.'< / p > ';
$body .= '< p > '. get_string('comment', 'enrol_apply') .': '.$info-> applydescription.'< / p > ';
$body .= '< p > '. get_string('comment', 'enrol_apply') .': '.$applydescription.'< / p > ';
$body .= '< p > < strong > '. get_string('user_profile', 'enrol_apply').'< / strong > < / p > ';
$body .= '< p > < strong > '. get_string('user_profile', 'enrol_apply').'< / strong > < / p > ';
$body .= '< p > '. get_string('firstname', 'enrol_apply') .': '.$info->firstname.'< / p > ';
$body .= '< p > '. get_string('firstname') .': '.$info->firstname.'< / p > ';
$body .= '< p > '. get_string('lastname', 'enrol_apply') .': '.$info->lastname.'< / p > ';
$body .= '< p > '. get_string('lastname') .': '.$info->lastname.'< / p > ';
$body .= '< p > '. get_string('email', 'enrol_apply') .': '.$info->email.'< / p > ';
$body .= '< p > '. get_string('email') .': '.$info->email.'< / p > ';
$body .= '< p > '. get_string('city', 'enrol_apply') .': '.$info->city.'< / p > ';
$body .= '< p > '. get_string('city') .': '.$info->city.'< / p > ';
$body .= '< p > '. get_string('country', 'enrol_apply') .': '.$info->country.'< / p > ';
$body .= '< p > '. get_string('country') .': '.$info->country.'< / p > ';
$body .= '< p > '. get_string('lang', 'enrol_apply') .': '.$info->lang.'< / p > ';
$body .= '< p > '. get_string('lang') .': '.$info->lang.'< / p > ';
$body .= '< p > '. get_string('description_editor', 'enrol_apply') .': '.$info->description_editor['text'].'< / 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('middlename') .': '.$info->middlename.'< / p > ';
$body .= '< p > '. get_string('alternatename') .': '.$info->alternatename.'< / p > ';
$body .= '< p > '. get_string('url') .': '.$info->url.'< / p > ';
$body .= '< p > '. get_string('icq') .': '.$info->icq.'< / p > ';
$body .= '< p > '. get_string('skype') .': '.$info->skype.'< / p > ';
$body .= '< p > '. get_string('aim') .': '.$info->aim.'< / p > ';
$body .= '< p > '. get_string('yahoo') .': '.$info->yahoo.'< / p > ';
$body .= '< p > '. get_string('msn') .': '.$info->msn.'< / p > ';
$body .= '< p > '. get_string('idnumber') .': '.$info->idnumber.'< / p > ';
$body .= '< p > '. get_string('institution') .': '.$info->institution.'< / p > ';
$body .= '< p > '. get_string('department') .': '.$info->department.'< / p > ';
$body .= '< p > '. get_string('phone1') .': '.$info->phone1.'< / p > ';
$body .= '< p > '. get_string('phone2') .': '.$info->phone2.'< / p > ';
$body .= '< p > '. get_string('address') .': '.$info->address.'< / 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();
@ -303,7 +324,7 @@ function sendConfirmMailToTeachers($courseid,$instanceid,$info){
}
}
}
}
function sendConfirmMailToManagers($courseid,$info){
function sendConfirmMailToManagers($courseid,$info,$applydescription ){
global $DB;
global $DB;
global $CFG;
global $CFG;
global $USER;
global $USER;
@ -318,15 +339,32 @@ function sendConfirmMailToManagers($courseid,$info){
$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') .': '.$info->firstname.' '.$info->lastname.'< / p > ';
$body .= '< p > '. get_string('comment', 'enrol_apply') .': '.$info-> applydescription.'< / p > ';
$body .= '< p > '. get_string('comment', 'enrol_apply') .': '.$applydescription.'< / p > ';
$body .= '< p > < strong > '. get_string('user_profile', 'enrol_apply').'< / strong > < / p > ';
$body .= '< p > < strong > '. get_string('user_profile', 'enrol_apply').'< / strong > < / p > ';
$body .= '< p > '. get_string('firstname', 'enrol_apply') .': '.$info->firstname.'< / p > ';
$body .= '< p > '. get_string('firstname') .': '.$info->firstname.'< / p > ';
$body .= '< p > '. get_string('lastname', 'enrol_apply') .': '.$info->lastname.'< / p > ';
$body .= '< p > '. get_string('lastname') .': '.$info->lastname.'< / p > ';
$body .= '< p > '. get_string('email', 'enrol_apply') .': '.$info->email.'< / p > ';
$body .= '< p > '. get_string('email') .': '.$info->email.'< / p > ';
$body .= '< p > '. get_string('city', 'enrol_apply') .': '.$info->city.'< / p > ';
$body .= '< p > '. get_string('city') .': '.$info->city.'< / p > ';
$body .= '< p > '. get_string('country', 'enrol_apply') .': '.$info->country.'< / p > ';
$body .= '< p > '. get_string('country') .': '.$info->country.'< / p > ';
$body .= '< p > '. get_string('lang', 'enrol_apply') .': '.$info->lang.'< / p > ';
$body .= '< p > '. get_string('lang') .': '.$info->lang.'< / p > ';
$body .= '< p > '. get_string('description_editor', 'enrol_apply') .': '.$info->description_editor['text'].'< / 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('middlename') .': '.$info->middlename.'< / p > ';
$body .= '< p > '. get_string('alternatename') .': '.$info->alternatename.'< / p > ';
$body .= '< p > '. get_string('url') .': '.$info->url.'< / p > ';
$body .= '< p > '. get_string('icq') .': '.$info->icq.'< / p > ';
$body .= '< p > '. get_string('skype') .': '.$info->skype.'< / p > ';
$body .= '< p > '. get_string('aim') .': '.$info->aim.'< / p > ';
$body .= '< p > '. get_string('yahoo') .': '.$info->yahoo.'< / p > ';
$body .= '< p > '. get_string('msn') .': '.$info->msn.'< / p > ';
$body .= '< p > '. get_string('idnumber') .': '.$info->idnumber.'< / p > ';
$body .= '< p > '. get_string('institution') .': '.$info->institution.'< / p > ';
$body .= '< p > '. get_string('department') .': '.$info->department.'< / p > ';
$body .= '< p > '. get_string('phone1') .': '.$info->phone1.'< / p > ';
$body .= '< p > '. get_string('phone2') .': '.$info->phone2.'< / p > ';
$body .= '< p > '. get_string('address') .': '.$info->address.'< / 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;