$messageclass = 'forum_message_post_text';
     $leftclass = 'forum_message_left';
 }
 $indent = $post['indent_cnt'] * '20';
 echo "<div style=\"margin-left: " . $indent . "px;\">";
 echo "<table width=\"100%\"  class=\"post\" cellspacing=\"5\" border=\"0\">";
 echo "<tr>";
 echo "<td rowspan=\"3\" class=\"{$leftclass}\">";
 $username = sprintf(get_lang('LoginX'), $post['username']);
 if ($post['user_id'] == '0') {
     $name = $post['poster_name'];
 } else {
     $name = api_get_person_name($post['firstname'], $post['lastname']);
 }
 if (api_get_course_setting('allow_user_image_forum')) {
     echo '<br />' . display_user_image($post['user_id'], $name, $origin) . '<br />';
 }
 echo display_user_link($post['user_id'], $name, $origin, $username) . "<br />";
 echo api_convert_and_format_date($post['post_date']) . '<br /><br />';
 // get attach id
 $attachment_list = get_attachment($post['post_id']);
 $id_attach = !empty($attachment_list) ? $attachment_list['id'] : '';
 // 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
 if (GroupManager::is_tutor_of_group(api_get_user_id(), $group_id) or $current_forum['allow_edit'] == 1 and $row['user_id'] == $_user['user_id'] or api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $_SESSION['id_session'])) {
     if ($locked == false) {
         echo "<a href=\"editpost.php?" . api_get_cidreq() . "&forum=" . $clean_forum_id . "&thread=" . $clean_thread_id . "&post=" . $post['post_id'] . "&amp;id_attach=" . $id_attach . "\">" . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . "</a>";
     }
 }
 if (GroupManager::is_tutor_of_group(api_get_user_id(), $group_id) or api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $_SESSION['id_session'])) {
     if ($locked == false) {
     }
     if ($current_forum['locked'] == 1) {
         $closedPost = Display::tag('div', '<i class="fa fa-exclamation-triangle"></i> ' . get_lang('ForumLocked'), array('class' => 'alert alert-warning post-closed'));
     }
     if ($current_thread['locked'] == 1) {
         $closedPost = Display::tag('div', '<i class="fa fa-exclamation-triangle"></i> ' . get_lang('ThreadLocked'), array('class' => 'alert alert-warning post-closed'));
     }
 }
 $html = '';
 $html .= '<div class="panel panel-default forum-post">';
 $html .= '<div class="panel-body">';
 $html .= '<div class="row">';
 $html .= '<div class="col-md-2">';
 if ($origin != 'learnpath') {
     if (api_get_course_setting('allow_user_image_forum')) {
         $html .= '<div class="thumbnail">' . display_user_image($row['user_id'], $name) . '</div>';
     }
     $html .= Display::tag('h4', display_user_link($row['user_id'], $name), array('class' => 'title-username'));
 } else {
     $html .= Display::tag('span', $name, array('title' => api_htmlentities($username, ENT_QUOTES)));
 }
 $html .= Display::tag('p', api_convert_and_format_date($row['post_date']), array('class' => 'post-date'));
 // get attach id
 $attachment_list = get_attachment($row['post_id']);
 $id_attach = !empty($attachment_list) ? $attachment_list['iid'] : '';
 $iconEdit = '';
 // 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
 if (GroupManager::is_tutor_of_group($userId, $groupId) || $current_forum['allow_edit'] == 1 && $row['user_id'] == $_user['user_id'] || api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $sessionId)) {
     if (api_is_allowed_to_session_edit(false, true)) {
    $leftclass = 'forum_message_left';
}
// Displaying the message
// We mark the image we are displaying as set
unset($whatsnew_post_info[$forumId][$threadId][$rows[$display_post_id]['post_id']]);
echo "<table width=\"100%\" class=\"forum_table\" cellspacing=\"5\" border=\"0\">";
echo "<tr>";
echo "<td rowspan=\"3\" class=\"{$leftclass}\">";
$username = sprintf(get_lang('LoginX'), $rows[$display_post_id]['username']);
if ($rows[$display_post_id]['user_id'] == '0') {
    $name = prepare4display($rows[$display_post_id]['poster_name']);
} else {
    $name = api_get_person_name($rows[$display_post_id]['firstname'], $rows[$display_post_id]['lastname']);
}
if (api_get_course_setting('allow_user_image_forum')) {
    echo '<br />' . display_user_image($rows[$display_post_id]['user_id'], $name, $origin) . '<br />';
}
echo display_user_link($rows[$display_post_id]['user_id'], $name, $origin, $username) . "<br />";
echo api_convert_and_format_date($rows[$display_post_id]['post_date']) . '<br /><br />';
// Get attach id
$attachment_list = get_attachment($display_post_id);
$id_attach = !empty($attachment_list) ? $attachment_list['id'] : '';
// 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
if (GroupManager::is_tutor_of_group(api_get_user_id(), $group_id) or $current_forum['allow_edit'] == 1 and $row['user_id'] == $_user['user_id'] or api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $_SESSION['id_session'])) {
    if ($locked == false) {
        echo "<a href=\"editpost.php?" . api_get_cidreq() . "&forum=" . $forumId . "&thread=" . $threadId . "&post=" . $rows[$display_post_id]['post_id'] . "&id_attach=" . $id_attach . "\">" . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>';
    }
}
if (GroupManager::is_tutor_of_group(api_get_user_id(), $group_id) or api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $_SESSION['id_session'])) {
    if ($locked == false) {
 } else {
     $titleclass = 'forum_message_post_title';
     $messageclass = 'forum_message_post_text';
     $leftclass = 'forum_message_left';
 }
 echo "<tr>";
 echo "<td rowspan=\"3\" class=\"{$leftclass}\">";
 if ($row['user_id'] == '0') {
     $name = prepare4display($row['poster_name']);
 } else {
     $name = api_get_person_name($row['firstname'], $row['lastname']);
 }
 $username = sprintf(get_lang('LoginX'), $row['username']);
 if ($origin != 'learnpath') {
     if (api_get_course_setting('allow_user_image_forum')) {
         echo '<br />' . display_user_image($row['user_id'], $name) . '<br />';
     }
     echo display_user_link($row['user_id'], $name, '', $username) . '<br />';
 } else {
     echo Display::tag('span', $name, array('title' => api_htmlentities($username, ENT_QUOTES))) . '<br />';
 }
 $group_id = api_get_group_id();
 echo api_convert_and_format_date($row['post_date']) . '<br /><br />';
 // get attach id
 $attachment_list = get_attachment($row['post_id']);
 $id_attach = !empty($attachment_list) ? $attachment_list['id'] : '';
 // 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
 if (GroupManager::is_tutor_of_group(api_get_user_id(), $group_id) or $current_forum['allow_edit'] == 1 and $row['user_id'] == $_user['user_id'] or api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $_SESSION['id_session'])) {
     if (api_is_allowed_to_session_edit(false, true)) {
         if ($locked == false) {
 $html .= '<div class="row">';
 $html .= '<div class="col-md-2">';
 $username = sprintf(get_lang('LoginX'), $post['username']);
 if ($post['user_id'] == '0') {
     $name = $post['poster_name'];
 } else {
     $name = api_get_person_name($post['firstname'], $post['lastname']);
 }
 if ($origin != 'learnpath') {
     if (api_get_course_setting('allow_user_image_forum')) {
         $html .= '<div class="thumbnail">' . display_user_image($post['user_id'], $name, $origin) . '</div>';
     }
     $html .= Display::tag('h4', display_user_link($post['user_id'], $name, $origin, $username), array('class' => 'title-username'));
 } else {
     if (api_get_course_setting('allow_user_image_forum')) {
         $html .= '<div class="thumbnail">' . display_user_image($post['user_id'], $name, $origin) . '</div>';
     }
     $html .= Display::tag('p', $name, array('title' => api_htmlentities($username, ENT_QUOTES), 'class' => 'lead'));
 }
 if ($origin != 'learnpath') {
     $html .= Display::tag('p', api_convert_and_format_date($post['post_date']), array('class' => 'post-date'));
 } else {
     $html .= Display::tag('p', api_convert_and_format_date($post['post_date'], DATE_TIME_FORMAT_SHORT), array('class' => 'text-muted'));
 }
 // get attach id
 $attachment_list = get_attachment($post['post_id']);
 $id_attach = !empty($attachment_list) ? $attachment_list['iid'] : '';
 $iconEdit = '';
 // 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
 if (GroupManager::is_tutor_of_group(api_get_user_id(), $group_id) || $current_forum['allow_edit'] == 1 && $post['user_id'] == $userId || api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $sessionId)) {