Merge remote-tracking branch 'upstream/preprodparkur' into ofaj

ofaj
NicoDucou 3 years ago
commit 656dedb8fd
  1. 18
      main/forum/forumfunction.inc.php
  2. 32
      main/inc/lib/sessionmanager.lib.php
  3. 5
      main/install/configuration.dist.php

@ -5789,6 +5789,8 @@ function send_notifications($forum_id = 0, $thread_id = 0, $post_id = 0)
}
$current_thread = get_thread_information($forum_id, $thread_id);
$courseInfo = api_get_course_info_by_id($current_thread['c_id']);
$courseCode = $courseInfo['code'];
// User who subscribed to the thread
if ($thread_id != 0) {
@ -5806,8 +5808,20 @@ function send_notifications($forum_id = 0, $thread_id = 0, $post_id = 0)
if (is_array($users_to_be_notified)) {
foreach ($users_to_be_notified as $value) {
$userInfo = api_get_user_info($value['user_id']);
send_mail($userInfo, $forumInfo, $current_thread, $postInfo);
$notifyUser = true;
if ((api_get_course_setting('share_forums_in_sessions',$courseCode) === -1 || !api_get_course_setting('share_forums_in_sessions',$courseCode)) && $current_thread['session_id'] != 0) {
$notifyUser = false;
$userSessions = SessionManager::get_sessions_by_user($value['user_id']);
foreach ($userSessions as $userSession) {
if ($userSession['session_id'] == $current_thread['session_id']) {
$notifyUser = true;
}
}
}
if ($notifyUser === true) {
$userInfo = api_get_user_info($value['user_id']);
send_mail($userInfo, $forumInfo, $current_thread, $postInfo);
}
}
}
}

@ -2337,6 +2337,8 @@ class SessionManager
}
}
}
$courseInfo = api_get_course_info_by_id($courseId);
$courseCode = $courseInfo['code'];
// Replace with this new function
// insert new users into session_rel_course_rel_user and ignore if they already exist
@ -2357,6 +2359,25 @@ class SessionManager
if (Database::affected_rows($result)) {
$nbr_users++;
}
if (!empty($courseInfo)) {
$enregUserInfo = api_get_user_info($enreg_user);
$subscribe = (int) api_get_course_setting('subscribe_users_to_forum_notifications', $courseCode);
if ($subscribe === 1) {
require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php';
$forums = get_forums(0, $courseCode, true, $sessionId);
foreach ($forums as $forum) {
$forumId = $forum['iid'];
set_notification('forum', $forumId, false, $enregUserInfo, $courseInfo);
}
if (api_get_configuration_value('subscribe_users_to_forum_notifications_also_in_base_course')) {
$forums = get_forums(0, $courseCode, true, 0);
foreach ($forums as $forum) {
$forumId = $forum['iid'];
set_notification('forum', $forumId, false, $enregUserInfo, $courseInfo);
}
}
}
}
Event::addEvent(
LOG_SESSION_ADD_USER_COURSE,
@ -2646,9 +2667,13 @@ class SessionManager
$courseId = $courseInfo['real_id'];
$subscribe = (int) api_get_course_setting('subscribe_users_to_forum_notifications', $course_code);
$forums = [];
$forumsBaseCourse = [];
if ($subscribe === 1) {
require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php';
$forums = get_forums(0, $course_code, true, $session_id);
if (api_get_configuration_value('subscribe_users_to_forum_notifications_also_in_base_course')) {
$forumsBaseCourse = get_forums(0, $courseCode, true, 0);
}
}
if ($removeUsersNotInList) {
@ -2705,6 +2730,13 @@ class SessionManager
set_notification('forum', $forumId, false, $userInfo, $courseInfo);
}
}
if (!empty($forumsBaseCourse)) {
$userInfo = api_get_user_info($enreg_user);
foreach ($forumsBaseCourse as $forum) {
$forumId = $forum['iid'];
set_notification('forum', $forumId, false, $userInfo, $courseInfo);
}
}
// Checking if user exists in session - user table.
$sql = "SELECT count(user_id) as count

@ -1216,6 +1216,11 @@ $_configuration['required_extra_fields_in_profile'] = [
// Requires new forum_category and forum_post "language" extra fields (multiple select)
//$_configuration['allow_forum_post_revisions'] = false;
//Allows to subscribe to notification of forums of the base course for users subscribed in a session
//Only works if subscribe_users_to_forum_notifications is set to true in the course's settings
//$_configuration['subscribe_users_to_forum_notifications_also_in_base_course'] = false;
// Allow to show users in a map, users need to have a coordinates extra field BT#15176
//$_configuration['allow_social_map_fields'] = ['fields' => ['terms_villedustage', 'terms_ville']];

Loading…
Cancel
Save