Add text "This e-mail was sent via course %s" see BT#13672

- When sending a message to a teacher in the userportal page, add a text
that mentions the course/session.

- If "course_id "is set then add label
"This e-mail was sent via course %s" when sending emails from userportal

- If "course_id" is set and "session_id" is set
"This e-mail was sent via course %s in session %s" when sending emails
from userportal.
pull/2487/head
jmontoyaa 8 years ago
parent 1a97f60c13
commit f5906c1b33
  1. 23
      main/inc/ajax/message.ajax.php
  2. 58
      main/inc/ajax/user_manager.ajax.php
  3. 14
      main/inc/lib/course.lib.php
  4. 6
      main/inc/lib/message.lib.php
  5. 19
      main/inc/lib/notification.lib.php

@ -57,6 +57,29 @@ switch ($action) {
exit;
}
$courseId = isset($_REQUEST['course_id']) ? (int) $_REQUEST['course_id'] : 0;
$sessionId = isset($_REQUEST['session_id']) ? (int) $_REQUEST['session_id'] : 0;
// Add course info
if (!empty($courseId)) {
$courseInfo = api_get_course_info_by_id($courseId);
if (!empty($courseInfo)) {
if (empty($sessionId)) {
$courseNotification = sprintf(get_lang('ThisEmailWasSentViaCourseX'), $courseInfo['title']);
} else {
$sessionInfo = api_get_session_info($sessionId);
if (!empty($sessionInfo)) {
$courseNotification = sprintf(
get_lang('ThisEmailWasSentViaCourseXInSessionX'),
$courseInfo['title'],
$sessionInfo['name']
);
}
}
$messageContent .= '<br /><br />'.$courseNotification;
}
}
$result = MessageManager::send_message($_REQUEST['user_id'], $subject, $messageContent);
if ($result) {
echo Display::return_message(get_lang('MessageHasBeenSent'), 'confirmation');

@ -31,8 +31,10 @@ switch ($action) {
echo json_encode($result);
break;
case 'get_user_popup':
$courseId = isset($_REQUEST['course_id']) ? (int) $_REQUEST['course_id'] : 0;
$sessionId = isset($_REQUEST['session_id']) ? (int) $_REQUEST['session_id'] : 0;
$user_info = api_get_user_info($_REQUEST['user_id']);
$ajax_url = api_get_path(WEB_AJAX_PATH).'message.ajax.php';
$isAnonymous = api_is_anonymous();
echo '<div class="row">';
@ -66,13 +68,15 @@ switch ($action) {
echo '</div>';
echo '</div>';
$url = api_get_path(WEB_AJAX_PATH).'message.ajax.php?a=send_message&user_id='.$user_info['user_id'].'&course_id='.$courseId.'&session_id='.$sessionId;
if ($isAnonymous === false &&
api_get_setting('allow_message_tool') == 'true'
) {
echo '<script>';
echo '
$("#send_message_link").on("click", function() {
var url = "'.$ajax_url.'?a=send_message&user_id='.$user_info['user_id'].'";
var url = "'.$url.'";
var params = $("#send_message").serialize();
$.ajax({
url: url+"&"+params,
@ -156,45 +160,45 @@ switch ($action) {
)
) {
$user_id = intval($_GET['user_id']);
$status = intval($_GET['status']);
$status = intval($_GET['status']);
if (!empty($user_id)) {
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$sql = "UPDATE $user_table
SET active='".$status."'
WHERE user_id='".$user_id."'";
SET active = '".$status."'
WHERE user_id = '".$user_id."'";
$result = Database::query($sql);
//Send and email if account is active
// Send and email if account is active
if ($status == 1) {
$user_info = api_get_user_info($user_id);
$recipient_name = api_get_person_name(
$recipientName = api_get_person_name(
$user_info['firstname'],
$user_info['lastname'],
null,
PERSON_NAME_EMAIL_ADDRESS
);
$emailsubject = '['.api_get_setting('siteName').'] '.get_lang('YourReg').' '.api_get_setting('siteName');
$email_admin = api_get_setting('emailAdministrator');
$subject = '['.api_get_setting('siteName').'] '.get_lang('YourReg').' '.api_get_setting('siteName');
$emailAdmin = api_get_setting('emailAdministrator');
$sender_name = api_get_person_name(
api_get_setting('administratorName'),
api_get_setting('administratorSurname'),
null,
PERSON_NAME_EMAIL_ADDRESS
);
$emailbody = get_lang('Dear')." ".stripslashes($recipient_name).",\n\n";
$emailbody .= sprintf(
$body = get_lang('Dear')." ".stripslashes($recipientName).",\n\n";
$body .= sprintf(
get_lang('YourAccountOnXHasJustBeenApprovedByOneOfOurAdministrators'),
api_get_setting('siteName')
)."\n";
$emailbody .= sprintf(
$body .= sprintf(
get_lang('YouCanNowLoginAtXUsingTheLoginAndThePasswordYouHaveProvided'),
api_get_path(WEB_PATH)
).",\n\n";
$emailbody .= get_lang('HaveFun')."\n\n";
//$emailbody.=get_lang('Problem'). "\n\n". get_lang('SignatureFormula');
$emailbody .= api_get_person_name(
$body .= get_lang('HaveFun')."\n\n";
//$body.=get_lang('Problem'). "\n\n". get_lang('SignatureFormula');
$body .= api_get_person_name(
api_get_setting('administratorName'),
api_get_setting('administratorSurname')
)."\n".
@ -207,17 +211,27 @@ switch ($action) {
'userId' => $user_id
);
$result = api_mail_html(
$recipient_name,
MessageManager::send_message_simple(
$user_id,
$subject,
$body,
null,
false,
false,
$additionalParameters
);
/*$result = api_mail_html(
$recipientName,
$user_info['mail'],
$emailsubject,
$emailbody,
$subject,
$body,
$sender_name,
$email_admin,
$emailAdmin,
null,
null,
$additionalParameters
);
);*/
Event::addEvent(LOG_USER_ENABLE, LOG_USER_ID, $user_id);
} else {
Event::addEvent(LOG_USER_DISABLE, LOG_USER_ID, $user_id);

@ -1963,7 +1963,7 @@ class CourseManager
$rs = Database::query($sql);
$listTeachers = array();
$teachers = array();
$url = api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?a=get_user_popup';
$url = api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?a=get_user_popup&course_id='.$courseId;
while ($teacher = Database::fetch_array($rs)) {
$teachers['id'] = $teacher['user_id'];
$teachers['lastname'] = $teacher['lastname'];
@ -1992,7 +1992,7 @@ class CourseManager
* @param bool $orderList
* @return string List of teachers teaching the course
*/
public static function get_teacher_list_from_course_code_to_string(
public static function getTeacherListFromCourseCodeToString(
$course_code,
$separator = self::USER_SEPARATOR,
$add_link_to_profile = false,
@ -2025,7 +2025,10 @@ class CourseManager
if ($orderList === true) {
$html .= '<ul class="user-teacher">';
foreach ($list as $teacher) {
$html .= Display::tag('li', Display::return_icon('teacher.png', $teacher, null, ICON_SIZE_TINY).' '.$teacher);
$html .= Display::tag(
'li',
Display::return_icon('teacher.png', $teacher, null, ICON_SIZE_TINY).' '.$teacher
);
}
$html .= '</ul>';
} else {
@ -2107,7 +2110,7 @@ class CourseManager
foreach ($coachList as $coach_course) {
$coach_name = $coach_course['full_name'];
if ($add_link_to_profile) {
$url = api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?a=get_user_popup&user_id='.$coach_course['user_id'];
$url = api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?a=get_user_popup&user_id='.$coach_course['user_id'].'&course_id='.$courseId.'&session_id='.$session_id;
$coach_name = Display::url(
$coach_name,
$url,
@ -4210,6 +4213,7 @@ class CourseManager
null,
true
);
$params['real_id'] = $course_info['real_id'];
// Display the "what's new" icons
$notifications = '';
@ -6329,7 +6333,7 @@ class CourseManager
}
$teachers = '';
if (api_get_setting('display_teacher_in_courselist') === 'true') {
$teachers = self::get_teacher_list_from_course_code_to_string(
$teachers = self::getTeacherListFromCourseCodeToString(
$course['code'],
self::USER_SEPARATOR,
true

@ -446,7 +446,8 @@ class MessageManager
$subject,
$content,
$sender_info,
$file_attachments
$file_attachments,
$smsParameters
);
} else {
$usergroup = new UserGroup();
@ -478,7 +479,8 @@ class MessageManager
$subject,
$content,
$group_info,
$file_attachments
$file_attachments,
$smsParameters
);
}

@ -429,6 +429,25 @@ class Notification extends Model
$content = $content.'<br /><br />'.$linkToNewMessage;
}
/*$courseInfo = api_get_course_info();
// Add course info
if (!empty($courseInfo)) {
$sessionId = api_get_session_id();
if (empty($sessionId)) {
$courseNotification = sprintf(get_lang('ThisEmailWasSentViaCourseX'), $courseInfo['title']);
} else {
$sessionInfo = api_get_session_info($sessionId);
if (!empty($sessionInfo)) {
$courseNotification = sprintf(
get_lang('ThisEmailWasSentViaCourseXInSessionX'),
$courseInfo['title'],
$sessionInfo['title']
);
}
}
$content = $content.'<br /><br />'.$courseNotification;
}*/
// You have received this message because you are subscribed text
$content = $content.'<br /><hr><i>'.
sprintf(

Loading…
Cancel
Save