Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal: Fix forum notification issue for subscribed users in sessions - refs BT#21550 #5419

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions public/main/forum/forumfunction.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -4306,21 +4306,12 @@ function get_notifications(string $content, int $id): array
$field = 'forum_id';
}

$sessionId = api_get_session_id();
$conditionSession = "";
if (!empty($sessionId)) {
$users = SessionManager::getUsersByCourseSession($sessionId, api_get_course_info());
if (!empty($users)) {
$conditionSession = " AND user.id IN(".implode(',', $users).")";
}
}

$sql = "SELECT user.id as user_id, user.firstname, user.lastname, user.email, user.id user
FROM $table_users user, $table_notification notification
WHERE
notification.c_id = $course_id AND user.active = 1 AND
user.id = notification.user_id AND
notification.$field = $id $conditionSession";
notification.$field = $id ";

$result = Database::query($sql);
$return = [];
Expand Down Expand Up @@ -4369,6 +4360,11 @@ function send_notifications(CForum $forum, CForumThread $thread, $post_id = 0)
// Merging the two
$users_to_be_notified = array_merge($users_to_be_notified_by_forum, $users_to_be_notified_by_thread);

$subscribe = (int) api_get_course_setting('subscribe_users_to_forum_notifications');
if (1 === $subscribe) {
$users_to_be_notified = CourseManager::get_user_list_from_course_code(api_get_course_id(), api_get_session_id());
}

if (is_array($users_to_be_notified)) {
foreach ($users_to_be_notified as $value) {
$userInfo = api_get_user_info($value['user_id']);
Expand Down
Loading