';
diff --git a/lang/ca/enrol_apply.php b/lang/ca/enrol_apply.php
index 6744fd3..89a972b 100644
--- a/lang/ca/enrol_apply.php
+++ b/lang/ca/enrol_apply.php
@@ -42,8 +42,10 @@ $string['apply:unenrolapply'] = 'Cancel·lar-se a si mateix del curs'; // Needs
$string['notification'] = 'Sol·licitud d\'inscripció enviada correctament.
Rebràs una notificació per correu electrònic un cop estigui confirmada la inscripció.';
$string['sendmailtoteacher'] = 'Enviar notificacions per correu als professors';
+$string['sendmailtomanager'] = 'Enviar notificacions per correu als administradors';
$string['mailtoteacher_suject'] = 'Nova inscripció al curs!';
$string['editdescription'] = 'Descripció de l\'àrea de text';
+$string['comment'] = 'Comentari';
$string['applymanage'] = 'Gestionar inscripcions';
$string['status_desc'] = 'Allow course access of internally enrolled users.';
diff --git a/lang/en/enrol_apply.php b/lang/en/enrol_apply.php
index e369443..a269b09 100644
--- a/lang/en/enrol_apply.php
+++ b/lang/en/enrol_apply.php
@@ -42,8 +42,10 @@ $string['apply:unenrolapply'] = 'Cancel self from the course';
$string['notification'] = 'Enrollment Application successfully sent.
You will be informed by email as soon as your enrollment has been confirmed. If you want to enroll to other courses, please click "course catalogue" in the top menu.';
$string['sendmailtoteacher'] = 'Send email notification to teachers';
+$string['sendmailtomanager'] = 'Send email notification to managers';
$string['mailtoteacher_suject'] = 'New Enrollment request!';
$string['editdescription'] = 'Textarea description';
+$string['comment'] = 'Comment';
$string['applymanage'] = 'Manage enrolment applications';
$string['status_desc'] = 'Allow course access of internally enrolled users.';
diff --git a/lang/es/enrol_apply.php b/lang/es/enrol_apply.php
index 21c380e..bec4033 100644
--- a/lang/es/enrol_apply.php
+++ b/lang/es/enrol_apply.php
@@ -42,8 +42,10 @@ $string['apply:unenrolapply'] = 'Cancelarse a si mismo del curso'; // Needs more
$string['notification'] = 'Solicitud de matriculación enviada correctamente.
Será notificado por correo electrónico en cuanto se confirme su matriculación.';
$string['sendmailtoteacher'] = 'Enviar notificaciones por correo a los profesores';
+$string['sendmailtomanager'] = 'Enviar notificaciones por correo a los gestores';
$string['mailtoteacher_suject'] = 'Nueva matrícula!';
$string['editdescription'] = 'Descripción del área de texto';
+$string['comment'] = 'Comentario';
$string['applymanage'] = 'Gestionar matrículas';
$string['status_desc'] = 'Allow course access of internally enrolled users.'; // needs to be translated
diff --git a/lib.php b/lib.php
index 65f0dc2..db82aba 100644
--- a/lib.php
+++ b/lib.php
@@ -93,7 +93,8 @@ class enrol_apply_plugin extends enrol_plugin {
}
$this->enrol_user($instance, $USER->id, $roleid, $timestart, $timeend,1);
- sendConfirmMailToTeachers($instance->courseid,$data->applydescription);
+ 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");
@@ -160,7 +161,7 @@ function getAllEnrolment($id = null){
if($id){
$userenrolments = $DB->get_records_sql('select ue.userid,ue.id,u.firstname,u.lastname,u.email,u.picture,c.fullname as course,ue.timecreated from '.$CFG->prefix.'user_enrolments as ue left join '.$CFG->prefix.'user as u on ue.userid=u.id left join '.$CFG->prefix.'enrol as e on ue.enrolid=e.id left join '.$CFG->prefix.'course as c on e.courseid=c.id where ue.status=1 and e.courseid='.$id);
}else{
- $userenrolments = $DB->get_records_sql('select ue.userid,ue.id,u.firstname,u.lastname,u.email,u.picture,c.fullname as course,ue.timecreated from '.$CFG->prefix.'user_enrolments as ue left join '.$CFG->prefix.'user as u on ue.userid=u.id left join '.$CFG->prefix.'enrol as e on ue.enrolid=e.id left join '.$CFG->prefix.'course as c on e.courseid=c.id where ue.status=1');
+ $userenrolments = $DB->get_records_sql('select ue.id,ue.userid,u.firstname,u.lastname,u.email,u.picture,c.fullname as course,ue.timecreated from '.$CFG->prefix.'user_enrolments as ue left join '.$CFG->prefix.'user as u on ue.userid=u.id left join '.$CFG->prefix.'enrol as e on ue.enrolid=e.id left join '.$CFG->prefix.'course as c on e.courseid=c.id where ue.status=1');
}
return $userenrolments;
}
@@ -202,7 +203,7 @@ function sendCancelMail($info){
global $CFG;
$apply_setting = $DB->get_records_sql("select name,value from ".$CFG->prefix."config_plugins where plugin='enrol_apply'");
- $replace = array('firstname'=>$info->firstname,'content'=>$info->coursename,'lastname'=>$info->lastname,'username'=>$info->username);
+ $replace = array('firstname'=>$info->firstname,'content'=>format_string($info->coursename),'lastname'=>$info->lastname,'username'=>$info->username);
$body = $apply_setting['cancelmailcontent']->value;
$body = updateMailContent($body,$replace);
$contact = get_admin();
@@ -214,27 +215,30 @@ function sendConfirmMail($info){
global $CFG;
$apply_setting = $DB->get_records_sql("select name,value from ".$CFG->prefix."config_plugins where plugin='enrol_apply'");
- $replace = array('firstname'=>$info->firstname,'content'=>$info->coursename,'lastname'=>$info->lastname,'username'=>$info->username);
+ $replace = array('firstname'=>$info->firstname,'content'=>format_string($info->coursename),'lastname'=>$info->lastname,'username'=>$info->username);
$body = $apply_setting['confirmmailcontent']->value;
$body = updateMailContent($body,$replace);
$contact = get_admin();
email_to_user($info, $contact, $apply_setting['confirmmailsubject']->value, '', $body);
}
-function sendConfirmMailToTeachers($courseid,$desc){
+function sendConfirmMailToTeachers($courseid,$instanceid,$desc){
global $DB;
global $CFG;
global $USER;
$apply_setting = $DB->get_records_sql("select name,value from ".$CFG->prefix."config_plugins where plugin='enrol_apply'");
if($apply_setting['sendmailtoteacher']->value == 1){
- $course = $DB->get_record('course',array('id'=>$courseid));
+ $course = get_course($courseid);
$context = context_course::instance($courseid, MUST_EXIST);
$teacherType = $DB->get_record('role',array("shortname"=>"editingteacher"));
$teachers = $DB->get_records('role_assignments', array('contextid'=>$context->id,'roleid'=>$teacherType->id));
foreach($teachers as $teacher){
$editTeacher = $DB->get_record('user',array('id'=>$teacher->userid));
- $body = '