From b70f12622a2ba68e39f6c3535704db86844f9fbd Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 7 Dec 2018 13:06:53 +0100 Subject: [PATCH] Add "send_notify_teacher" action see BT#15020 --- main/lp/lp_controller.php | 72 +++++++++++++++++++ .../default/mail/content_ending_learnpath.tpl | 7 ++ 2 files changed, 79 insertions(+) create mode 100644 main/template/default/mail/content_ending_learnpath.tpl diff --git a/main/lp/lp_controller.php b/main/lp/lp_controller.php index 644663127a..fd1690278c 100755 --- a/main/lp/lp_controller.php +++ b/main/lp/lp_controller.php @@ -412,6 +412,78 @@ if ($debug > 0) { } switch ($action) { + // ## NSR + case 'send_notify_teacher': + // Enviar correo al profesor + $studentInfo = api_get_user_info(); + $course_info = api_get_course_info(); + + global $_configuration; + $root_web = $_configuration['root_web']; + + if (api_get_session_id() > 0) { + $session_info = api_get_session_info(api_get_session_id()); + $course_name = $session_info['name']; + $course_url = $root_web.'courses/'.$course_info['code'].'/index.php?id_session='.api_get_session_id(); + } else { + $course_name = $course_info['title']; + $course_url = $root_web.'courses/'.$course_info['code'].'/index.php?'; + } + $url = ''.$course_name.''; + + /*$sql = "SELECT c.* FROM plugin_licences_customers c + INNER JOIN plugin_licences_student_rel_customer s + ON s.user_id = c.user_id + WHERE s.student_id = ".$studentInfo['user_id']; + $res = Database::query($sql); + if (Database::num_rows($res) > 0) { + $row = Database::fetch_assoc($res); + if (!empty($row['telefono'])) { + $telefono = htmlspecialchars($row['telefono']); + } else { + $telefono = ''; + } + if (!empty($row['prefix'])) { + $prefix = htmlspecialchars($row['prefix']); + } else { + $prefix = ''; + } + } else { + $telefono = ''; + $prefix = ''; + }*/ + + $coachList = CourseManager::get_coachs_from_course(api_get_session_id(), api_get_course_int_id()); + foreach ($coachList as $coach_course) { + $recipient_name = $coach_course['full_name']; + + $coachInfo = api_get_user_info($coach_course['user_id']); + $email = $coachInfo['email']; + + $tplContent = new Template(null, false, false, false, false, false); + // variables for the default template + $tplContent->assign('name_teacher', $recipient_name); + $tplContent->assign('name_student', $studentInfo['firstname'].' '.$studentInfo['lastname']); + $tplContent->assign('course_name', $course_name);; + $tplContent->assign('course_url', $url); + $tplContent->assign('telefono', $telefono); + $tplContent->assign('prefix', $prefix); + $layoutContent = $tplContent->get_template('mail/content_ending_learnpath.tpl'); + $emailBody = $tplContent->fetch($layoutContent); + + api_mail_html( + $recipient_name, + $email, + 'Alumno con lecciones finalizadas', + $emailBody, + $studentInfo['firstname'].' '.$studentInfo['lastname'], + $studentInfo['email'], + true + ); + } + Display::addFlash(Display::return_message('Notificación enviada al profesor')); + require 'lp_list.php'; + break; case 'add_item': if (!$is_allowed_to_edit) { api_not_allowed(true); diff --git a/main/template/default/mail/content_ending_learnpath.tpl b/main/template/default/mail/content_ending_learnpath.tpl new file mode 100644 index 0000000000..e82fa9fe0a --- /dev/null +++ b/main/template/default/mail/content_ending_learnpath.tpl @@ -0,0 +1,7 @@ +

{{ 'Dear'|get_lang }} {{ name_teacher }},

+

El estudiante {{ name_student }} ha finalizado las lecciones del grupo {{ course_name }}

+

{{ course_url }}

+

{{ 'SignatureFormula'|get_lang }}

+

{{ prefix ? prefix }}
+ {{ telefono ? 'Tlfno. ' ~ telefono }} +