$poster_id = 0; } else { $name = api_get_person_name($forum['last_poster_firstname'], $forum['last_poster_lastname']); $poster_id = $forum['last_poster_id']; } $html .= '<div class="col-md-6">'; if (!empty($forum['last_post_id'])) { $html .= Display::return_icon('post-item.png', null, null, ICON_SIZE_TINY) . ' '; $html .= api_convert_and_format_date($forum['last_post_date']) . ' ' . get_lang('By') . ' ' . display_user_link($poster_id, $name); } $html .= '</div>'; $html .= '<div class="col-md-4">'; if (api_is_allowed_to_edit(false, true) && !($forum['session_id'] == 0 && $sessionId != 0)) { $html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&forumcategory=' . Security::remove_XSS($_GET['forumcategory']) . '&action=edit&content=forum&id=' . $forum['forum_id'] . '">' . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>'; $html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&forumcategory=' . Security::remove_XSS($_GET['forumcategory']) . '&action=delete&content=forum&id=' . $forum['forum_id'] . "\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang('DeleteForum'), ENT_QUOTES)) . "')) return false;\">" . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>'; $html .= return_visible_invisible_icon('forum', $forum['forum_id'], $forum['visibility'], array('forumcategory' => $_GET['forumcategory'])); $html .= return_lock_unlock_icon('forum', $forum['forum_id'], $forum['locked'], array('forumcategory' => $_GET['forumcategory'])); $html .= return_up_down_icon('forum', $forum['forum_id'], $forums_in_category); } $iconnotify = 'notification_mail_na.png'; if (is_array(isset($_SESSION['forum_notification']['forum']) ? $_SESSION['forum_notification']['forum'] : null)) { if (in_array($forum['forum_id'], $_SESSION['forum_notification']['forum'])) { $iconnotify = 'notification_mail.png'; } } if (!api_is_anonymous()) { $html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&forumcategory=' . Security::remove_XSS($_GET['forumcategory']) . '&action=notify&content=forum&id=' . $forum['forum_id'] . '">' . Display::return_icon($iconnotify, get_lang('NotifyMe')) . '</a>'; } $html .= '</div>'; $html .= '</div>'; $html .= '</div>';
$username = ""; } else { $name = api_get_person_name($forum['last_poster_firstname'], $forum['last_poster_lastname']); $poster_id = $forum['last_poster_id']; $userinfo = api_get_user_info($poster_id); $username = sprintf(get_lang('LoginX'), $userinfo['username']); } if (!empty($forum['last_post_id'])) { $html .= Display::return_icon('post-item.png', null, null, ICON_SIZE_TINY) . ' ' . api_convert_and_format_date($forum['last_post_date']) . '<br /> ' . get_lang('By') . ' ' . display_user_link($poster_id, $name, '', $username); } $html .= '</div>'; $html .= '<div class="col-md-4">'; if (api_is_allowed_to_edit(false, true) && !($forum['session_id'] == 0 && intval($sessionId) != 0)) { $html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=edit&content=forum&id=' . $forum['forum_id'] . '">' . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>'; $html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=delete&content=forum&id=' . $forum['forum_id'] . "\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang('DeleteForum'), ENT_QUOTES)) . "')) return false;\">" . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>'; $html .= return_visible_invisible_icon('forum', $forum['forum_id'], $forum['visibility']); $html .= return_lock_unlock_icon('forum', $forum['forum_id'], $forum['locked']); $html .= return_up_down_icon('forum', $forum['forum_id'], $forumsInCategory); } $iconnotify = 'notification_mail_na.png'; $session_forum_notification = isset($_SESSION['forum_notification']['forum']) ? $_SESSION['forum_notification']['forum'] : false; if (is_array($session_forum_notification)) { if (in_array($forum['forum_id'], $session_forum_notification)) { $iconnotify = 'notification_mail.png'; } } if (!api_is_anonymous() && api_is_allowed_to_session_edit(false, true)) { $html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=notify&content=forum&id=' . $forum['forum_id'] . '">' . Display::return_icon($iconnotify, get_lang('NotifyMe'), null, ICON_SIZE_SMALL) . '</a>'; } $html .= '</div>'; $html .= '</div>';
/** * This function takes care of the display of the visibility icon * * @param $content what is it that we want to make (in)visible: forum category, forum, thread, post * @param $id the id of the content we want to make invisible * @param $current_visibility_status what is the current status of the visibility (0 = invisible, 1 = visible) * @return void string HTML * * @author Patrick Cool <*****@*****.**>, Ghent University * @version february 2006, dokeos 1.8 */ function display_visible_invisible_icon($content, $id, $current_visibility_status, $additional_url_parameters = '') { echo return_visible_invisible_icon($content, $id, $current_visibility_status, $additional_url_parameters); }
// 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)) { if ($locked == false) { $iconEdit .= "<a href=\"editpost.php?" . api_get_cidreq() . "&forum=" . $clean_forum_id . "&thread=" . $clean_thread_id . "&post=" . $row['post_id'] . "&origin=" . $origin . "&edit=edition&id_attach=" . $id_attach . "\">" . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . "</a>"; } } } if ($origin != 'learnpath') { if (GroupManager::is_tutor_of_group($userId, $groupId) || api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $sessionId)) { if ($locked == false) { $iconEdit .= "<a href=\"" . api_get_self() . "?" . api_get_cidreq() . "&forum=" . $clean_forum_id . "&thread=" . $clean_thread_id . "&action=delete&content=post&id=" . $row['post_id'] . "&origin=" . $origin . "\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang('DeletePost'), ENT_QUOTES)) . "')) return false;\">" . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . "</a>"; } } if (api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $sessionId)) { $iconEdit .= return_visible_invisible_icon('post', $row['post_id'], $row['visible'], array('forum' => $clean_forum_id, 'thread' => $clean_thread_id, 'origin' => $origin)); $iconEdit .= ""; if ($increment > 0) { $iconEdit .= "<a href=\"viewthread.php?" . api_get_cidreq() . "&forum=" . $clean_forum_id . "&thread=" . $clean_thread_id . "&action=move&post=" . $row['post_id'] . "&origin=" . $origin . "\">" . Display::return_icon('move.png', get_lang('MovePost'), array(), ICON_SIZE_SMALL) . "</a>"; } } } $user_status = api_get_status_of_user_in_course($row['user_id'], api_get_course_int_id()); $current_qualify_thread = showQualify('1', $row['poster_id'], $_GET['thread']); if (($current_thread['thread_peer_qualify'] == 1 || api_is_allowed_to_edit(null, true)) && $current_thread['thread_qualify_max'] > 0 && $origin != 'learnpath') { $my_forum_id = $clean_forum_id; if (isset($_GET['gradebook'])) { $info_thread = get_thread_information($clean_thread_id); $my_forum_id = $info_thread['forum_id']; } $userCanEdit = $current_thread['thread_peer_qualify'] == 1 && $row['poster_id'] != $userId;
$cidreq = api_get_cidreq(); // Get attachment id. if (isset($row['post_id'])) { $attachment_list = get_attachment($row['post_id']); } $id_attach = !empty($attachment_list) ? $attachment_list['id'] : ''; $iconsEdit = ''; if ($origin != 'learnpath') { if (api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $sessionId)) { $iconsEdit .= '<a href="' . $forumUrl . 'editthread.php?' . $cidreq . '&forum=' . intval($my_forum) . '&thread=' . intval($row['thread_id']) . '&id_attach=' . $id_attach . '">' . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>'; if (api_resource_is_locked_by_gradebook($row['thread_id'], LINK_FORUM_THREAD)) { $iconsEdit .= Display::return_icon('delete_na.png', get_lang('ResourceLockedByGradebook'), array(), ICON_SIZE_SMALL); } else { $iconsEdit .= '<a href="' . api_get_self() . '?' . $cidreq . '&forum=' . intval($my_forum) . '&action=delete&content=thread&id=' . $row['thread_id'] . $origin_string . "\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang('DeleteCompleteThread'), ENT_QUOTES)) . "')) return false;\">" . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>'; } $iconsEdit .= return_visible_invisible_icon('thread', $row['thread_id'], $row['visibility'], array('forum' => $my_forum, 'origin' => $origin, 'gidReq' => $groupId)); $iconsEdit .= return_lock_unlock_icon('thread', $row['thread_id'], $row['locked'], array('forum' => $my_forum, 'origin' => $origin, 'gidReq' => api_get_group_id())); $iconsEdit .= '<a href="viewforum.php?' . $cidreq . '&forum=' . intval($my_forum) . '&action=move&thread=' . $row['thread_id'] . $origin_string . '">' . Display::return_icon('move.png', get_lang('MoveThread'), array(), ICON_SIZE_SMALL) . '</a>'; } } $iconnotify = 'notification_mail_na.png'; if (is_array(isset($_SESSION['forum_notification']['thread']) ? $_SESSION['forum_notification']['thread'] : null)) { if (in_array($row['thread_id'], $_SESSION['forum_notification']['thread'])) { $iconnotify = 'notification_mail.png'; } } $icon_liststd = 'user.png'; if (!api_is_anonymous() && api_is_allowed_to_session_edit(false, true)) { $iconsEdit .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&forum=' . Security::remove_XSS($my_forum) . "&origin={$origin}&action=notify&content=thread&id={$row['thread_id']}" . '">' . Display::return_icon($iconnotify, get_lang('NotifyMe')) . '</a>'; } if (api_is_allowed_to_edit(null, true) && $origin != 'learnpath') {
$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)) { if ($locked == false) { $iconEdit .= "<a href=\"editpost.php?" . api_get_cidreq() . "&forum={$clean_forum_id}&thread={$clean_thread_id}&post={$post['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) || api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $sessionId)) { if ($locked == false) { $iconEdit .= "<a href=\"" . api_get_self() . "?" . api_get_cidreq() . "&forum={$clean_forum_id}&thread={$clean_thread_id}&action=delete&content=post&id={$post['post_id']}" . "\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang('DeletePost'), ENT_QUOTES)) . "')) return false;\">" . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . "</a>"; } } if (api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $sessionId)) { $iconEdit .= return_visible_invisible_icon('post', $post['post_id'], $post['visible'], array('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&origin={$origin}&post={$post['post_id']}" . "\">" . Display::return_icon('move.png', get_lang('MovePost'), array(), 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 (empty($currentThread['thread_qualify_max'])) { $userCanQualify = false; } if ($userCanQualify) { if ($count > 0) { $current_qualify_thread = showQualify('1', $post['user_id'], $_GET['thread']); if ($locked == false) {
$my_post = getPosts($current_forum, $_GET['thread']); $id_posts = array(); if (!empty($my_post) && is_array($my_post)) { foreach ($my_post as $post_value) { $id_posts[] = $post_value['post_id']; } sort($id_posts, SORT_NUMERIC); reset($id_posts); // The post minor $post_minor = (int) $id_posts[0]; } if (GroupManager::is_tutor_of_group(api_get_user_id(), $groupId) || api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $sessionId)) { if ($locked == false) { echo "<a href=\"" . api_get_self() . "?" . api_get_cidreq() . "&forum=" . $forumId . "&thread=" . $threadId . "&action=delete&content=post&id=" . $rows[$display_post_id]['post_id'] . "\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang('DeletePost'), ENT_QUOTES)) . "')) return false;\">" . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . "</a>"; } echo return_visible_invisible_icon('post', $rows[$display_post_id]['post_id'], $rows[$display_post_id]['visible'], array('forum' => $forumId, 'thread' => $threadId, 'post' => Security::remove_XSS($_GET['post']))); if (!isset($_GET['id']) && $post_id > $post_minor) { echo "<a href=\"viewthread.php?" . api_get_cidreq() . "&forum=" . $forumId . "&thread=" . $threadId . "&origin=" . $origin . "&action=move&post=" . $rows[$display_post_id]['post_id'] . "\">" . Display::return_icon('move.png', get_lang('MovePost'), array(), ICON_SIZE_SMALL) . "</a>"; } } $userCanQualify = $currentThread['thread_peer_qualify'] == 1 && $rows[$display_post_id]['poster_id'] != $userId; if (api_is_allowed_to_edit(null, true)) { $userCanQualify = true; } if (empty($currentThread['thread_qualify_max'])) { $userCanQualify = false; } if ($userCanQualify) { if ($post_id > $post_minor) { $current_qualify_thread = showQualify('1', $rows[$display_post_id]['user_id'], $_GET['thread']); if ($locked == false) {