diff --git a/assets/css/app.scss b/assets/css/app.scss index baf4e6074e..0238dd1cbd 100644 --- a/assets/css/app.scss +++ b/assets/css/app.scss @@ -141,6 +141,45 @@ } } + // Card + .card { + border: 1px solid #ddd; + border-radius: 4px; + box-shadow: 0 2px 5px rgba(0,0,0,0.15); + background-color: #fff; + margin-bottom: 20px; + } + + .card .flex { + display: flex; + justify-content: space-between; + align-items: center; + } + + .card .flex .relative { + position: relative; + font-size: 16px; + font-weight: bold; + } + + .card .flex a { + margin-left: 10px; + font-size: 18px; + color: #333; + } + + .card .sectioncomment { + padding: 15px; + background-color: #f7f7f7; + } + + .card span { + float: right; + margin-right: 15px; + font-size: 14px; + color: #666; + } + // Alerts .alert { @@ -337,14 +376,6 @@ text-decoration: underline; } -.category-forum .custom-panel-group { - width: 100%; -} - -.category-forum .forum_display { - padding: 20px 0px; -} - #date_fields label, .p-float-label .datepicker-label { top: 0px; diff --git a/assets/css/scss/_exercise.scss b/assets/css/scss/_exercise.scss index 98f2d5af56..c552c96d7c 100644 --- a/assets/css/scss/_exercise.scss +++ b/assets/css/scss/_exercise.scss @@ -322,45 +322,6 @@ } } -.card { - border: 1px solid #ddd; - border-radius: 4px; - box-shadow: 0 2px 5px rgba(0,0,0,0.15); - background-color: #fff; - margin-bottom: 20px; -} - -.card .flex { - display: flex; - justify-content: space-between; - align-items: center; - padding: 10px 15px; -} - -.card .flex .relative { - position: relative; - font-size: 16px; - font-weight: bold; -} - -.card .flex a { - margin-left: 10px; - font-size: 22px; - color: #333; -} - -.card .sectioncomment { - padding: 15px; - background-color: #f7f7f7; -} - -.card span { - float: right; - margin-right: 15px; - font-size: 14px; - color: #666; -} - .question_menu { @apply p-4 flex flex-row gap-1; } diff --git a/assets/css/scss/_forums.scss b/assets/css/scss/_forums.scss index 2c56bcb4cd..b3e4ac7d18 100644 --- a/assets/css/scss/_forums.scss +++ b/assets/css/scss/_forums.scss @@ -76,3 +76,204 @@ .ch-tool-icon-disabled { @apply text-gray-50; } + +.category-forum { + .custom-panel-group { + border: none; + margin: 0; + width: 100%; + } + + .custom-panel { + box-shadow: 0 2px 5px rgba(0,0,0,0.2); + margin-bottom: 10px; + border-radius: 4px; + overflow: hidden; + } + + .custom-panel-heading { + padding: 10px 15px; + background-color: #f8f8f8; + border-bottom: 1px solid #ddd; + cursor: pointer; + display: flex; + align-items: center; + } + + .custom-panel-heading .open { + flex-shrink: 0; + } + + .custom-panel-heading h4 { + margin: 0; + padding: 0; + font-size: 18px; + color: #333; + flex-grow: 1; + text-align: left; + } + + .custom-panel-title { + margin-left: 10px; + } + + .pull-right a { + margin-left: 10px; + } + + .custom-panel-body { + padding: 15px; + background-color: #fff; + } +} + +.forum_display { + display: flex; + width: 100%; + margin-bottom: 15px; + border: 1px solid #ddd; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); + + .forum-row { + width: 100%; + padding: 5px; + } + + .card-forum { + display: flex; + flex-direction: row; + width: 100%; + padding: 10px; + align-items: flex-start; + background-color: #fff; + } + + .number-post { + text-align: center; + flex: 0 0 25%; + padding: 30px; + border-right: 1px solid #ddd; + background-color: #f5f5f5; + display: flex; + flex-direction: column; + align-items: center; + margin-right: 20px; + } + + .number-post i { + font-size: 48px; + color: #3276b1; + } + + .number-post p { + font-size: 14px; + margin-top: 8px; + } + + .content-forum { + display: flex; + flex-direction: column; + flex-grow: 1; + padding-left: 15px; + } + + .title-forum { + font-size: 18px; + margin: 0; + } + + .description-forum { + font-size: 14px; + color: #666; + margin-top: 4px; + } + + .actions-forum { + margin-left: auto; + display: flex; + align-items: center; + justify-content: flex-end; + } + + .actions-forum i { + font-size: 22px; + margin-left: 10px; + cursor: pointer; + } + + @media (max-width: 768px) { + flex-direction: column; + + .number-post { + border-right: none; + border-bottom: 1px solid #ddd; + order: -1; + width: 100%; + padding: 15px; + } + + .content-forum { + padding: 15px; + } + + .actions-forum { + justify-content: center; + margin-top: 10px; + } + } +} + +.forum-post { + .post-col1 { + display: flex; + flex-direction: column; + align-items: center; + padding: 10px; + width: 15% !important; + } + + .q-avatar { + border-radius: 50%; + overflow: hidden; + width: 80px; + height: 80px; + } + + .q-avatar img { + width: 100%; + height: auto; + } + + .post-date { + margin-top: 10px; + font-size: 0.8rem; + color: #666; + } + + .flex-row { + display: flex; + margin-top: 10px; + } + + .boot-tooltip { + position: relative; + } + + .boot-tooltip::before { + content: attr(title); + position: absolute; + bottom: 100%; + left: 50%; + transform: translateX(-50%); + background: black; + color: white; + padding: 5px; + border-radius: 4px; + font-size: 0.7rem; + display: none; + } + + .boot-tooltip:hover::before { + display: block; + } +} diff --git a/public/main/forum/forumfunction.inc.php b/public/main/forum/forumfunction.inc.php index b618e2f210..c58fa2e1b9 100644 --- a/public/main/forum/forumfunction.inc.php +++ b/public/main/forum/forumfunction.inc.php @@ -1164,14 +1164,9 @@ function getForum( } /** - * Retrieve all the threads of a given forum. - * - * @param int|null $courseId Optional If is null then it is considered the current course - * @param int|null $sessionId Optional. If is null then it is considered the current session - * - * @return CForumThread[] + * Retrieves all the threads for a given forum or counts them. */ -function get_threads(int $forumId, int $courseId = null, int $sessionId = null): Array +function get_threads(int $forumId, int $courseId = null, int $sessionId = null, bool $count = false): array|int { $repo = Container::getForumThreadRepository(); $courseId = empty($courseId) ? api_get_course_int_id() : $courseId; @@ -1181,7 +1176,12 @@ function get_threads(int $forumId, int $courseId = null, int $sessionId = null): $qb = $repo->getResourcesByCourse($course, $session); $qb->andWhere('resource.forum = :forum')->setParameter('forum', $forumId); - return $qb->getQuery()->getResult(); + if ($count) { + $qb->select('COUNT(resource.iid)'); + return (int) $qb->getQuery()->getSingleScalarResult(); + } else { + return $qb->getQuery()->getResult(); + } } /** @@ -1985,8 +1985,8 @@ function show_add_post_form(CForum $forum, CForumThread $thread, CForumPost $pos 'add_attachment', get_lang('Add attachment'), 'paperclip', - 'default', - 'default', + 'plain', + 'plain', null, ['id' => 'reply-add-attachment'] ); @@ -3286,7 +3286,6 @@ function handle_mail_cue($content, $id) $sql = "SELECT users.firstname, users.lastname, users.id as user_id, users.email FROM $table_mailcue mailcue, $table_posts posts, $table_users users WHERE - posts.c_id = $course_id AND mailcue.c_id = $course_id AND posts.thread_id = $thread_id AND posts.post_notification = '1' AND @@ -3326,14 +3325,14 @@ function handle_mail_cue($content, $id) Database::query($sql); } elseif ('forum' === $content) { $sql = "SELECT iid FROM $table_threads - WHERE c_id = $course_id AND forum_id = $id"; + WHERE forum_id = $id"; $result = Database::query($sql); while ($row = Database::fetch_array($result)) { handle_mail_cue('thread', $row['iid']); } } elseif ('forum_category' === $content) { $sql = "SELECT iid FROM $table_forums - WHERE c_id = $course_id AND forum_category = $id"; + WHERE forum_category = $id"; $result = Database::query($sql); while ($row = Database::fetch_array($result)) { handle_mail_cue('forum', $row['iid']); @@ -3550,22 +3549,22 @@ function store_move_post($values) // Moving the post to the newly created thread. $sql = "UPDATE $table_posts SET thread_id='".$new_thread_id."', post_parent_id = NULL - WHERE c_id = $course_id AND iid ='".(int) ($values['post_id'])."'"; + WHERE iid ='".(int) ($values['post_id'])."'"; Database::query($sql); // Resetting the parent_id of the thread to 0 for all those who had this moved post as parent. $sql = "UPDATE $table_posts SET post_parent_id = NULL - WHERE c_id = $course_id AND post_parent_id='".(int) ($values['post_id'])."'"; + WHERE post_parent_id='".(int) ($values['post_id'])."'"; Database::query($sql); // Updating updating the number of threads in the forum. $sql = "UPDATE $table_forums SET forum_threads=forum_threads+1 - WHERE c_id = $course_id AND iid ='".$forumId."'"; + WHERE iid ='".$forumId."'"; Database::query($sql); // Resetting the last post of the old thread and decreasing the number of replies and the thread. $sql = "SELECT * FROM $table_posts - WHERE c_id = $course_id AND thread_id='".$threadId."' + WHERE thread_id='".$threadId."' ORDER BY iid DESC"; $result = Database::query($sql); $row = Database::fetch_array($result); @@ -3573,19 +3572,18 @@ function store_move_post($values) thread_last_post='".$row['iid']."', thread_replies=thread_replies-1 WHERE - c_id = $course_id AND iid ='".$threadId."'"; Database::query($sql); } else { // Moving to the chosen thread. $sql = 'SELECT thread_id FROM '.$table_posts." - WHERE c_id = $course_id AND iid = '".$values['post_id']."' "; + WHERE iid = '".$values['post_id']."' "; $result = Database::query($sql); $row = Database::fetch_array($result); $original_thread_id = $row['thread_id']; $sql = 'SELECT thread_last_post FROM '.$table_threads." - WHERE c_id = $course_id AND iid = '".$original_thread_id."' "; + WHERE iid = '".$original_thread_id."' "; $result = Database::query($sql); $row = Database::fetch_array($result); @@ -3595,7 +3593,6 @@ function store_move_post($values) if ($thread_is_last_post == $values['post_id']) { $sql = 'SELECT iid as post_id FROM '.$table_posts." WHERE - c_id = $course_id AND thread_id = '".$original_thread_id."' AND iid <> '".$values['post_id']."' ORDER BY post_date DESC LIMIT 1"; @@ -3606,26 +3603,26 @@ function store_move_post($values) $sql = 'UPDATE '.$table_threads." SET thread_last_post = '".$thread_new_last_post."' - WHERE c_id = $course_id AND iid = '".$original_thread_id."' "; + WHERE iid = '".$original_thread_id."' "; Database::query($sql); } $sql = "UPDATE $table_threads SET thread_replies=thread_replies-1 - WHERE c_id = $course_id AND iid ='".$original_thread_id."'"; + WHERE iid ='".$original_thread_id."'"; Database::query($sql); // moving to the chosen thread $sql = "UPDATE $table_posts SET thread_id='".(int) ($_POST['thread'])."', post_parent_id = NULL - WHERE c_id = $course_id AND iid ='".(int) ($values['post_id'])."'"; + WHERE iid ='".(int) ($values['post_id'])."'"; Database::query($sql); // resetting the parent_id of the thread to 0 for all those who had this moved post as parent $sql = "UPDATE $table_posts SET post_parent_id = NULL - WHERE c_id = $course_id AND post_parent_id='".(int) ($values['post_id'])."'"; + WHERE post_parent_id='".(int) ($values['post_id'])."'"; Database::query($sql); $sql = "UPDATE $table_threads SET thread_replies=thread_replies+1 - WHERE c_id = $course_id AND iid ='".(int) ($_POST['thread'])."'"; + WHERE iid ='".(int) ($_POST['thread'])."'"; Database::query($sql); } diff --git a/public/main/forum/index.php b/public/main/forum/index.php index c91a584344..2e3191e526 100644 --- a/public/main/forum/index.php +++ b/public/main/forum/index.php @@ -262,6 +262,13 @@ if ($translate) { placeholder: "'.get_lang('Select a language').'", allowClear: true }); + + $("#extra_language").on("change", function() { + var selectedLanguages = $(this).val(); + if (selectedLanguages.length === 0) { + window.location.reload(); + } + }); }); '; $form = new FormValidator('search_simple', 'get', api_get_self().'?'.api_get_cidreq(), null, null); @@ -447,9 +454,7 @@ if (is_array($forumCategories)) { $groupId = $forum->getForumOfGroup(); $forumInfo['visibility'] = $forumVisibility = $forum->isVisible($courseEntity); - /*$forumInfo['number_threads'] = isset($forum['number_of_threads']) - ? (int) $forum['number_of_threads'] - : 0;*/ + $forumInfo['number_threads'] = (int) get_threads($forumId, api_get_course_int_id(), api_get_session_id(), true); $linkForum = api_get_path(WEB_CODE_PATH).'forum/viewforum.php?'.api_get_cidreq() .'&gid='.$groupId.'&forum='.$forumId; diff --git a/public/main/forum/viewthread.php b/public/main/forum/viewthread.php index 38066a26f3..484eb6102f 100644 --- a/public/main/forum/viewthread.php +++ b/public/main/forum/viewthread.php @@ -446,7 +446,7 @@ foreach ($posts as $post) { get_lang('Edit'), $editUrl, 'pencil', - 'default' + 'plain' ); } } diff --git a/public/main/template/default/forum/list.html.twig b/public/main/template/default/forum/list.html.twig index a38e2a4c99..5a0711507c 100644 --- a/public/main/template/default/forum/list.html.twig +++ b/public/main/template/default/forum/list.html.twig @@ -7,7 +7,7 @@