UI Improvements + lots of bugfixes * * @package chamilo.forum */ // Delete attachment file if ((isset($_GET['action']) && $_GET['action'] == 'delete_attach') && isset($_GET['id_attach']) ) { delete_attachment(0, $_GET['id_attach']); } // Are we in a lp ? $origin = api_get_origin(); $sessionId = api_get_session_id(); $_user = api_get_user_info(); $userId = api_get_user_id(); $groupId = api_get_group_id(); // Decide whether we show the latest post first $sortDirection = isset($_GET['posts_order']) && $_GET['posts_order'] === 'desc' ? 'DESC' : ($origin != 'learnpath' ? 'ASC' : 'DESC'); if (isset($current_thread['thread_id'])) { $rows = getPosts($current_forum, $current_thread['thread_id'], $sortDirection); $increment = 0; $clean_forum_id = intval($_GET['forum']); $clean_thread_id = intval($_GET['thread']); $locked = api_resource_is_locked_by_gradebook( $clean_thread_id, LINK_FORUM_THREAD ); $buttonReply = ''; $buttonQuote = ''; $closedPost = ''; if (!empty($rows)) { $postCount = count($rows); foreach ($rows as $row) { $posterId = isset($row['user_id']) ? $row['user_id'] : 0; $name = ''; if (empty($posterId)) { $name = prepare4display($row['poster_name']); } else { if (isset($row['complete_name'])) { $name = $row['complete_name']; } } $username = ''; if (isset($row['username'])) { $username = sprintf(get_lang('LoginX'), $row['username']); } if (($current_forum_category && $current_forum_category['locked'] == 0) && $current_forum['locked'] == 0 && $current_thread['locked'] == 0 || api_is_allowed_to_edit(false, true) ) { if ($userId || ($current_forum['allow_anonymous'] == 1 && !$userId)) { if ((api_is_anonymous() && $current_forum['allow_anonymous'] == 1) || (!api_is_anonymous() && api_is_allowed_to_session_edit(false, true)) ) { $buttonReply = Display::toolbarButton( get_lang('ReplyToMessage'), 'reply.php?'.api_get_cidreq().'&'.http_build_query([ 'forum' => $clean_forum_id, 'thread' => $clean_thread_id, 'post' => $row['post_id'], 'action' => 'replymessage', ]), 'reply', 'primary', ['id' => "reply-to-post-{$row['post_id']}"] ); $buttonQuote = Display::toolbarButton( get_lang('QuoteMessage'), 'reply.php?'.api_get_cidreq().'&'.http_build_query([ 'forum' => $clean_forum_id, 'thread' => $clean_thread_id, 'post' => $row['post_id'], 'action' => 'quote', ]), 'quote-left', 'success', ['id' => "quote-post-{$row['post_id']}"] ); } } } else { if (($current_forum_category && $current_forum_category['locked'] == 1)) { $closedPost = Display::tag( 'div', ' '.get_lang('ForumcategoryLocked'), ['class' => 'alert alert-warning post-closed'] ); } if ($current_forum['locked'] == 1) { $closedPost = Display::tag( 'div', ' '.get_lang('ForumLocked'), ['class' => 'alert alert-warning post-closed'] ); } if ($current_thread['locked'] == 1) { $closedPost = Display::tag( 'div', ' '.get_lang('ThreadLocked'), ['class' => 'alert alert-warning post-closed'] ); } } $html = ''; $html .= '