|
@@ -1,6 +1,8 @@
|
|
|
<?php
|
|
|
/* For licensing terms, see /license.txt */
|
|
|
|
|
|
+use Chamilo\CourseBundle\Entity\CForumPost;
|
|
|
+
|
|
|
/**
|
|
|
* @author Julio Montoya <gugli100@gmail.com> UI Improvements + lots of bugfixes
|
|
|
*
|
|
@@ -125,6 +127,14 @@ switch ($my_action) {
|
|
|
header('Location: '.$currentUrl);
|
|
|
exit;
|
|
|
break;
|
|
|
+ case 'ask_revision':
|
|
|
+ $postId = isset($_GET['post_id']) ? $_GET['post_id'] : 0;
|
|
|
+
|
|
|
+ $result = savePostRevision($postId, $current_forum, $current_thread);
|
|
|
+ Display::addFlash(Display::return_message(get_lang('Saved')));
|
|
|
+ header('Location: '.$currentUrl);
|
|
|
+ exit;
|
|
|
+ break;
|
|
|
}
|
|
|
|
|
|
if (!empty($groupId)) {
|
|
@@ -144,36 +154,36 @@ if (!empty($groupId)) {
|
|
|
'url' => api_get_path(WEB_CODE_PATH).'forum/viewthread.php?forum='.intval($_GET['forum']).'&'.api_get_cidreq().'&thread='.intval($_GET['thread']),
|
|
|
'name' => Security::remove_XSS($current_thread['thread_title']),
|
|
|
];
|
|
|
-
|
|
|
- Display::display_header('');
|
|
|
} else {
|
|
|
$my_search = isset($_GET['search']) ? $_GET['search'] : '';
|
|
|
- if ($origin == 'learnpath') {
|
|
|
- Display::display_reduced_header();
|
|
|
- } else {
|
|
|
+ if ($origin != 'learnpath') {
|
|
|
$interbreadcrumb[] = [
|
|
|
- 'url' => api_get_path(WEB_CODE_PATH).'forum/index.php?'.api_get_cidreq().'&search='.Security::remove_XSS(urlencode($my_search)),
|
|
|
+ 'url' => api_get_path(WEB_CODE_PATH).'forum/index.php?'.api_get_cidreq().'&search='.Security::remove_XSS(
|
|
|
+ urlencode($my_search)
|
|
|
+ ),
|
|
|
'name' => $nameTools,
|
|
|
];
|
|
|
$interbreadcrumb[] = [
|
|
|
- 'url' => api_get_path(WEB_CODE_PATH).'forum/viewforumcategory.php?forumcategory='.$current_forum_category['cat_id']."&search=".Security::remove_XSS(urlencode($my_search)),
|
|
|
+ 'url' => api_get_path(
|
|
|
+ WEB_CODE_PATH
|
|
|
+ ).'forum/viewforumcategory.php?forumcategory='.$current_forum_category['cat_id']."&search=".Security::remove_XSS(
|
|
|
+ urlencode($my_search)
|
|
|
+ ),
|
|
|
'name' => Security::remove_XSS($current_forum_category['cat_title']),
|
|
|
];
|
|
|
$interbreadcrumb[] = [
|
|
|
- 'url' => api_get_path(WEB_CODE_PATH).'forum/viewforum.php?'.api_get_cidreq().'&forum='.intval($_GET['forum'])."&search=".Security::remove_XSS(urlencode($my_search)),
|
|
|
+ 'url' => api_get_path(WEB_CODE_PATH).'forum/viewforum.php?'.api_get_cidreq().'&forum='.intval(
|
|
|
+ $_GET['forum']
|
|
|
+ )."&search=".Security::remove_XSS(urlencode($my_search)),
|
|
|
'name' => Security::remove_XSS($current_forum['forum_title']),
|
|
|
];
|
|
|
$interbreadcrumb[] = [
|
|
|
- 'url' => '#', 'name' => Security::remove_XSS($current_thread['thread_title']),
|
|
|
+ 'url' => '#',
|
|
|
+ 'name' => Security::remove_XSS($current_thread['thread_title']),
|
|
|
];
|
|
|
-
|
|
|
- // the last element of the breadcrumb navigation is already set in interbreadcrumb, so give empty string
|
|
|
- Display::display_header('');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-/* Is the user allowed here? */
|
|
|
-
|
|
|
// If the user is not a course administrator and the forum is hidden
|
|
|
// then the user is not allowed here.
|
|
|
if (!api_is_allowed_to_edit(false, true) &&
|
|
@@ -184,17 +194,19 @@ if (!api_is_allowed_to_edit(false, true) &&
|
|
|
|
|
|
increase_thread_view($_GET['thread']);
|
|
|
|
|
|
-/* Action Links */
|
|
|
if ($origin == 'learnpath') {
|
|
|
- echo '<div style="height:15px"> </div>';
|
|
|
+ $template = new Template('', false, false, true, true, false);
|
|
|
+} else {
|
|
|
+ $template = new Template();
|
|
|
}
|
|
|
-echo '<div class="actions">';
|
|
|
-echo '<span style="float:right;">'.search_link().'</span>';
|
|
|
+
|
|
|
+$actions = '<span style="float:right;">'.search_link().'</span>';
|
|
|
if ($origin != 'learnpath') {
|
|
|
- echo '<a href="'.$forumUrl.'viewforum.php?forum='
|
|
|
+ $actions .= '<a href="'.$forumUrl.'viewforum.php?forum='
|
|
|
.intval($_GET['forum']).'&'.api_get_cidreq().'">'
|
|
|
.Display::return_icon('back.png', get_lang('BackToForum'), '', ICON_SIZE_MEDIUM).'</a>';
|
|
|
}
|
|
|
+
|
|
|
// The reply to thread link should only appear when the forum_category is
|
|
|
// not locked AND the forum is not locked AND the thread is not locked.
|
|
|
// If one of the three levels is locked then the link should not be displayed.
|
|
@@ -208,7 +220,7 @@ if (($current_forum_category &&
|
|
|
if ($_user['user_id'] || ($current_forum['allow_anonymous'] == 1 && !$_user['user_id'])) {
|
|
|
// reply link
|
|
|
if (!api_is_anonymous() && api_is_allowed_to_session_edit(false, true)) {
|
|
|
- echo '<a href="'.$forumUrl.'reply.php?'.api_get_cidreq().'&forum='
|
|
|
+ $actions .= '<a href="'.$forumUrl.'reply.php?'.api_get_cidreq().'&forum='
|
|
|
.intval($_GET['forum']).'&thread='
|
|
|
.intval($_GET['thread']).'&action=replythread">'
|
|
|
.Display::return_icon('reply_thread.png', get_lang('ReplyToThread'), '', ICON_SIZE_MEDIUM)
|
|
@@ -223,9 +235,9 @@ if (($current_forum_category &&
|
|
|
($current_forum['allow_new_threads'] == 1 && !isset($_user['user_id']) && $current_forum['allow_anonymous'] == 1)
|
|
|
) {
|
|
|
if ($current_forum['locked'] != 1 && $current_forum['locked'] != 1) {
|
|
|
- echo ' ';
|
|
|
+ $actions .= ' ';
|
|
|
} else {
|
|
|
- echo get_lang('ForumLocked');
|
|
|
+ $actions .= get_lang('ForumLocked');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -233,19 +245,20 @@ if (($current_forum_category &&
|
|
|
|
|
|
// The different views of the thread.
|
|
|
if ($origin != 'learnpath') {
|
|
|
- $my_url = '<a href="'.$forumUrl.'viewthread.php?'.api_get_cidreq().'&'.api_get_cidreq()
|
|
|
+ /*$actions .= '<a href="'.$forumUrl.'viewthread.php?'.api_get_cidreq().'&'.api_get_cidreq()
|
|
|
.'&forum='.intval($_GET['forum']).'&thread='.intval($_GET['thread'])
|
|
|
.'&search='.Security::remove_XSS(urlencode($my_search));
|
|
|
echo $my_url.'&view=flat">'
|
|
|
.Display::return_icon('forum_listview.png', get_lang('FlatView'), null, ICON_SIZE_MEDIUM)
|
|
|
.'</a>';
|
|
|
+ /*
|
|
|
echo $my_url.'&view=nested">'
|
|
|
.Display::return_icon('forum_nestedview.png', get_lang('NestedView'), null, ICON_SIZE_MEDIUM)
|
|
|
- .'</a>';
|
|
|
+ .'</a>';*/
|
|
|
}
|
|
|
-$my_url = null;
|
|
|
|
|
|
-echo '</div> ';
|
|
|
+$template->assign('forum_actions', $actions);
|
|
|
+$template->assign('origin', api_get_origin());
|
|
|
|
|
|
/* Display Forum Category and the Forum information */
|
|
|
if (!isset($_SESSION['view'])) {
|
|
@@ -259,27 +272,399 @@ if (isset($_GET['view']) && in_array($_GET['view'], $whiteList)) {
|
|
|
$viewMode = $_GET['view'];
|
|
|
$_SESSION['view'] = $viewMode;
|
|
|
}
|
|
|
+
|
|
|
if (empty($viewMode)) {
|
|
|
$viewMode = 'flat';
|
|
|
}
|
|
|
|
|
|
if ($current_thread['thread_peer_qualify'] == 1) {
|
|
|
- echo Display::return_message(get_lang('ForumThreadPeerScoringStudentComment'), 'info');
|
|
|
+ Display::addFlash(Display::return_message(get_lang('ForumThreadPeerScoringStudentComment'), 'info'));
|
|
|
}
|
|
|
|
|
|
$allowReport = reportAvailable();
|
|
|
|
|
|
-switch ($viewMode) {
|
|
|
- case 'threaded':
|
|
|
- case 'nested':
|
|
|
- include_once 'viewthread_nested.inc.php';
|
|
|
- break;
|
|
|
- case 'flat':
|
|
|
- default:
|
|
|
- include_once 'viewthread_flat.inc.php';
|
|
|
- break;
|
|
|
+// Are we in a lp ?
|
|
|
+$origin = api_get_origin();
|
|
|
+//delete attachment file
|
|
|
+if (isset($_GET['action']) &&
|
|
|
+ $_GET['action'] == 'delete_attach' &&
|
|
|
+ isset($_GET['id_attach'])
|
|
|
+) {
|
|
|
+ delete_attachment(0, $_GET['id_attach']);
|
|
|
}
|
|
|
|
|
|
-if ($origin != 'learnpath') {
|
|
|
- Display::display_footer();
|
|
|
+$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');
|
|
|
+$posts = getPosts($current_forum, $_GET['thread'], $sortDirection, true);
|
|
|
+$count = 0;
|
|
|
+$clean_forum_id = intval($_GET['forum']);
|
|
|
+$clean_thread_id = intval($_GET['thread']);
|
|
|
+$group_id = api_get_group_id();
|
|
|
+$locked = api_resource_is_locked_by_gradebook($clean_thread_id, LINK_FORUM_THREAD);
|
|
|
+$sessionId = api_get_session_id();
|
|
|
+$currentThread = get_thread_information($clean_forum_id, $_GET['thread']);
|
|
|
+$userId = api_get_user_id();
|
|
|
+$groupInfo = GroupManager::get_group_properties($group_id);
|
|
|
+$postCount = 1;
|
|
|
+$allowUserImageForum = api_get_course_setting('allow_user_image_forum');
|
|
|
+
|
|
|
+// The user who posted it can edit his thread only if the course admin allowed this in the properties
|
|
|
+// of the forum
|
|
|
+// The course admin him/herself can do this off course always
|
|
|
+$tutorGroup = GroupManager::is_tutor_of_group(api_get_user_id(), $groupInfo);
|
|
|
+
|
|
|
+$postList = [];
|
|
|
+foreach ($posts as $post) {
|
|
|
+ $posterId = isset($post['user_id']) ? $post['user_id'] : 0;
|
|
|
+ $username = '';
|
|
|
+ if (isset($post['username'])) {
|
|
|
+ $username = sprintf(get_lang('LoginX'), $post['username']);
|
|
|
+ }
|
|
|
+
|
|
|
+ $name = $post['complete_name'];
|
|
|
+ if (empty($posterId)) {
|
|
|
+ $name = $post['poster_name'];
|
|
|
+ }
|
|
|
+
|
|
|
+ $post['user_data'] = '';
|
|
|
+ if ($origin != 'learnpath') {
|
|
|
+ if ($allowUserImageForum) {
|
|
|
+ $post['user_data'] = '<div class="thumbnail">'.
|
|
|
+ display_user_image($posterId, $name, $origin).'</div>';
|
|
|
+ }
|
|
|
+
|
|
|
+ $post['user_data'] .= Display::tag(
|
|
|
+ 'h4',
|
|
|
+ display_user_link($posterId, $name, $origin, $username),
|
|
|
+ ['class' => 'title-username']
|
|
|
+ );
|
|
|
+
|
|
|
+ $_user = api_get_user_info($posterId);
|
|
|
+ $urlImg = api_get_path(WEB_IMG_PATH);
|
|
|
+ $iconStatus = null;
|
|
|
+ $isAdmin = UserManager::is_admin($posterId);
|
|
|
+
|
|
|
+ if ($_user['status'] == 5) {
|
|
|
+ if ($_user['has_certificates']) {
|
|
|
+ $iconStatus = '<img src="'.$urlImg.'icons/svg/ofaj_graduated.svg" width="22px" height="22px">';
|
|
|
+ } else {
|
|
|
+ $iconStatus = '<img src="'.$urlImg.'icons/svg/ofaj_student.svg" width="22px" height="22px">';
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if ($_user['status'] == 1) {
|
|
|
+ if ($isAdmin) {
|
|
|
+ $iconStatus = '<img src="'.$urlImg.'icons/svg/ofaj_admin.svg" width="22px" height="22px">';
|
|
|
+ } else {
|
|
|
+ $iconStatus = '<img src="'.$urlImg.'icons/svg/ofaj_teacher.svg" width="22px" height="22px">';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $post['user_data'] .= '<div class="text-center">'.$iconStatus.'</div>';
|
|
|
+ } else {
|
|
|
+ if ($allowUserImageForum) {
|
|
|
+ $post['user_data'] .= '<div class="thumbnail">'.
|
|
|
+ display_user_image($posterId, $name, $origin).'</div>';
|
|
|
+ }
|
|
|
+
|
|
|
+ $post['user_data'] .= Display::tag(
|
|
|
+ 'p',
|
|
|
+ $name,
|
|
|
+ [
|
|
|
+ 'title' => api_htmlentities($username, ENT_QUOTES),
|
|
|
+ 'class' => 'lead',
|
|
|
+ ]
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($origin != 'learnpath') {
|
|
|
+ $post['user_data'] .= Display::tag(
|
|
|
+ 'p',
|
|
|
+ Display::dateToStringAgoAndLongDate($post['post_date']),
|
|
|
+ ['class' => 'post-date']
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ $post['user_data'] .= Display::tag(
|
|
|
+ 'p',
|
|
|
+ Display::dateToStringAgoAndLongDate($post['post_date']),
|
|
|
+ ['class' => 'text-muted']
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ // get attach id
|
|
|
+ $attachment_list = get_attachment($post['post_id']);
|
|
|
+ $id_attach = !empty($attachment_list) ? $attachment_list['iid'] : '';
|
|
|
+
|
|
|
+ $iconEdit = '';
|
|
|
+ $editButton = '';
|
|
|
+ $askForRevision = '';
|
|
|
+
|
|
|
+ if ((isset($groupInfo['iid']) && $tutorGroup) ||
|
|
|
+ ($current_forum['allow_edit'] == 1 && $posterId == $userId) ||
|
|
|
+ (api_is_allowed_to_edit(false, true) &&
|
|
|
+ !(api_is_session_general_coach() && $current_forum['session_id'] != $sessionId))
|
|
|
+ ) {
|
|
|
+ if ($locked == false && postIsEditableByStudent($current_forum, $post)) {
|
|
|
+ $editUrl = api_get_path(WEB_CODE_PATH).'forum/editpost.php?'.api_get_cidreq();
|
|
|
+ $editUrl .= "&forum=$clean_forum_id&thread=$clean_thread_id&post={$post['post_id']}&id_attach=$id_attach";
|
|
|
+ $iconEdit .= "<a href='".$editUrl."'>"
|
|
|
+ .Display::return_icon('edit.png', get_lang('Edit'), [], ICON_SIZE_SMALL)
|
|
|
+ ."</a>";
|
|
|
+
|
|
|
+ $editButton = Display::toolbarButton(
|
|
|
+ get_lang('Edit'),
|
|
|
+ $editUrl,
|
|
|
+ 'pencil',
|
|
|
+ 'default'
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if ((isset($groupInfo['iid']) && $tutorGroup) ||
|
|
|
+ api_is_allowed_to_edit(false, true) &&
|
|
|
+ !(api_is_session_general_coach() && $current_forum['session_id'] != $sessionId)
|
|
|
+ ) {
|
|
|
+ if ($locked == false) {
|
|
|
+ $deleteUrl = api_get_self().'?'.api_get_cidreq().'&'.http_build_query([
|
|
|
+ 'forum' => $clean_forum_id,
|
|
|
+ 'thread' => $clean_thread_id,
|
|
|
+ 'action' => 'delete',
|
|
|
+ 'content' => 'post',
|
|
|
+ 'id' => $post['post_id'],
|
|
|
+ ]);
|
|
|
+ $iconEdit .= Display::url(
|
|
|
+ Display::return_icon('delete.png', get_lang('Delete'), [], ICON_SIZE_SMALL),
|
|
|
+ $deleteUrl,
|
|
|
+ [
|
|
|
+ 'onclick' => "javascript:if(!confirm('"
|
|
|
+ .addslashes(api_htmlentities(get_lang('DeletePost'), ENT_QUOTES))
|
|
|
+ ."')) return false;",
|
|
|
+ 'id' => "delete-post-{$post['post_id']}",
|
|
|
+ ]
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (api_is_allowed_to_edit(false, true) &&
|
|
|
+ !(
|
|
|
+ api_is_session_general_coach() &&
|
|
|
+ $current_forum['session_id'] != $sessionId
|
|
|
+ )
|
|
|
+ ) {
|
|
|
+ $iconEdit .= return_visible_invisible_icon(
|
|
|
+ 'post',
|
|
|
+ $post['post_id'],
|
|
|
+ $post['visible'],
|
|
|
+ [
|
|
|
+ 'forum' => $clean_forum_id,
|
|
|
+ 'thread' => $clean_thread_id,
|
|
|
+ ]
|
|
|
+ );
|
|
|
+
|
|
|
+ if ($count > 0) {
|
|
|
+ $iconEdit .= "<a href=\"viewthread.php?".api_get_cidreq()
|
|
|
+ ."&forum=$clean_forum_id&thread=$clean_thread_id&action=move&post={$post['post_id']}"
|
|
|
+ ."\">".Display::return_icon('move.png', get_lang('MovePost'), [], ICON_SIZE_SMALL)."</a>";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $userCanQualify = $currentThread['thread_peer_qualify'] == 1 && $post['poster_id'] != $userId;
|
|
|
+ if (api_is_allowed_to_edit(null, true)) {
|
|
|
+ $userCanQualify = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($post['poster_id'] == $userId) {
|
|
|
+ $revision = getPostRevision($post['post_id']);
|
|
|
+ if (empty($revision)) {
|
|
|
+ $askForRevision = getAskRevisionButton($post['post_id'], $current_thread);
|
|
|
+ } else {
|
|
|
+ $languageId = api_get_language_id(strtolower($revision));
|
|
|
+ $languageInfo = api_get_language_info($languageId);
|
|
|
+ if ($languageInfo) {
|
|
|
+ $askForRevision = '<span class="flag-icon flag-icon-'.$languageInfo['isocode'].'"></span> ';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (postNeedsRevision($post['post_id'])) {
|
|
|
+ $askForRevision = giveRevisionButton($post['post_id'], $current_thread);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (empty($currentThread['thread_qualify_max'])) {
|
|
|
+ $userCanQualify = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($userCanQualify) {
|
|
|
+ if ($count > 0) {
|
|
|
+ $current_qualify_thread = showQualify(
|
|
|
+ '1',
|
|
|
+ $posterId,
|
|
|
+ $_GET['thread']
|
|
|
+ );
|
|
|
+ if ($locked == false) {
|
|
|
+ $iconEdit .= "<a href=\"forumqualify.php?".api_get_cidreq()
|
|
|
+ ."&forum=$clean_forum_id&thread=$clean_thread_id&action=list&post={$post['post_id']}"
|
|
|
+ ."&user={$post['user_id']}&user_id={$post['user_id']}"
|
|
|
+ ."&idtextqualify=$current_qualify_thread"
|
|
|
+ ."\" >".Display::return_icon('quiz.png', get_lang('Qualify'))."</a>";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $reportButton = '';
|
|
|
+ if ($allowReport) {
|
|
|
+ $reportButton = getReportButton($post['post_id'], $current_thread);
|
|
|
+ }
|
|
|
+
|
|
|
+ $statusIcon = getPostStatus($current_forum, $post);
|
|
|
+ if (!empty($iconEdit)) {
|
|
|
+ $post['user_data'] .= "<div class='tools-icons'> $iconEdit $statusIcon </div>";
|
|
|
+ } else {
|
|
|
+ if (!empty(strip_tags($statusIcon))) {
|
|
|
+ $post['user_data'] .= "<div class='tools-icons'> $statusIcon </div>";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $buttonReply = '';
|
|
|
+ $buttonQuote = '';
|
|
|
+ $waitingValidation = '';
|
|
|
+
|
|
|
+ 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() && 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' => $post['post_id'],
|
|
|
+ 'action' => 'replymessage',
|
|
|
+ ]),
|
|
|
+ 'reply',
|
|
|
+ 'primary',
|
|
|
+ ['id' => "reply-to-post-{$post['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' => $post['post_id'],
|
|
|
+ 'action' => 'quote',
|
|
|
+ ]),
|
|
|
+ 'quote-left',
|
|
|
+ 'success',
|
|
|
+ ['id' => "quote-post-{$post['post_id']}"]
|
|
|
+ );
|
|
|
+
|
|
|
+ if ($current_forum['moderated'] && !api_is_allowed_to_edit(false, true)) {
|
|
|
+ if (empty($post['status']) || $post['status'] == CForumPost::STATUS_WAITING_MODERATION) {
|
|
|
+ $buttonReply = '';
|
|
|
+ $buttonQuote = '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $closedPost = '';
|
|
|
+ if ($current_forum_category && $current_forum_category['locked'] == 1) {
|
|
|
+ $closedPost = Display::tag(
|
|
|
+ 'div',
|
|
|
+ '<em class="fa fa-exclamation-triangle"></em> '.get_lang('ForumcategoryLocked'),
|
|
|
+ ['class' => 'alert alert-warning post-closed']
|
|
|
+ );
|
|
|
+ }
|
|
|
+ if ($current_forum['locked'] == 1) {
|
|
|
+ $closedPost = Display::tag(
|
|
|
+ 'div',
|
|
|
+ '<em class="fa fa-exclamation-triangle"></em> '.get_lang('ForumLocked'),
|
|
|
+ ['class' => 'alert alert-warning post-closed']
|
|
|
+ );
|
|
|
+ }
|
|
|
+ if ($current_thread['locked'] == 1) {
|
|
|
+ $closedPost = Display::tag(
|
|
|
+ 'div',
|
|
|
+ '<em class="fa fa-exclamation-triangle"></em> '.get_lang('ThreadLocked'),
|
|
|
+ ['class' => 'alert alert-warning post-closed']
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ $post['user_data'] .= $closedPost;
|
|
|
+ }
|
|
|
+
|
|
|
+ // note: this can be removed here because it will be displayed in the tree
|
|
|
+ if (isset($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$post['post_id']]) &&
|
|
|
+ !empty($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$post['post_id']]) &&
|
|
|
+ !empty($whatsnew_post_info[$_GET['forum']][$post['thread_id']])
|
|
|
+ ) {
|
|
|
+ $post_image = Display::return_icon('forumpostnew.gif');
|
|
|
+ } else {
|
|
|
+ $post_image = Display::return_icon('forumpost.gif');
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($post['post_notification'] == '1' && $post['poster_id'] == $userId) {
|
|
|
+ $post_image .= Display::return_icon(
|
|
|
+ 'forumnotification.gif',
|
|
|
+ get_lang('YouWillBeNotified')
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ $post['current'] = false;
|
|
|
+ if (isset($_GET['post_id']) && $_GET['post_id'] == $post['post_id']) {
|
|
|
+ $post['current'] = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // The post title
|
|
|
+ $titlePost = Display::tag('h3', $post['post_title'], ['class' => 'forum_post_title']);
|
|
|
+ $post['post_data'] = Display::tag('div', $titlePost, ['class' => 'post-header']);
|
|
|
+ $post['post_data'] .= '<a name="post_id_'.$post['post_id'].'"></a>';
|
|
|
+
|
|
|
+ // the post body
|
|
|
+ $post['post_data'] .= Display::tag('div', $post['post_text'], ['class' => 'post-body']);
|
|
|
+
|
|
|
+ // The check if there is an attachment
|
|
|
+ $post['post_attachments'] = '';
|
|
|
+ $attachment_list = getAllAttachment($post['post_id']);
|
|
|
+ if (!empty($attachment_list) && is_array($attachment_list)) {
|
|
|
+ foreach ($attachment_list as $attachment) {
|
|
|
+ $user_filename = $attachment['filename'];
|
|
|
+ $post['post_attachments'] .= Display::return_icon('attachment.gif', get_lang('Attachment'));
|
|
|
+ $post['post_attachments'] .= '<a href="download.php?file=';
|
|
|
+ $post['post_attachments'] .= $attachment['path'];
|
|
|
+ $post['post_attachments'] .= ' "> '.$user_filename.' </a>';
|
|
|
+ $post['post_attachments'] .= '<span class="forum_attach_comment" >'.$attachment['comment'].'</span>';
|
|
|
+ if (($current_forum['allow_edit'] == 1 && $post['user_id'] == $userId) ||
|
|
|
+ (api_is_allowed_to_edit(false, true) && !(api_is_session_general_coach() && $current_forum['session_id'] != $sessionId))
|
|
|
+ ) {
|
|
|
+ $post['post_attachments'] .= ' <a href="'.api_get_self().'?'.api_get_cidreq().'&action=delete_attach&id_attach='
|
|
|
+ .$attachment['iid'].'&forum='.$clean_forum_id.'&thread='.$clean_thread_id
|
|
|
+ .'" onclick="javascript:if(!confirm(\''
|
|
|
+ .addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)).'\')) return false;">'
|
|
|
+ .Display::return_icon('delete.png', get_lang('Delete')).'</a><br />';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $post['post_buttons'] = "$askForRevision $editButton $reportButton $buttonReply $buttonQuote $waitingValidation";
|
|
|
+ $postList[] = $post;
|
|
|
+
|
|
|
+ // The post has been displayed => it can be removed from the what's new array
|
|
|
+ unset($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$post['post_id']]);
|
|
|
+ unset($_SESSION['whatsnew_post_info'][$current_forum['forum_id']][$current_thread['thread_id']][$post['post_id']]);
|
|
|
+
|
|
|
+ $count++;
|
|
|
}
|
|
|
+$template->assign('posts', $postList);
|
|
|
+
|
|
|
+$layout = $template->get_template('forum/posts.tpl');
|
|
|
+
|
|
|
+$template->display($layout);
|