, Ghent University * @copyright Ghent University * @copyright Patrick Cool * * @package chamilo.forum */ /** * Code */ // Name of the language file that needs to be included. $language_file = 'forum'; // Including the global initialization file. require_once '../inc/global.inc.php'; $current_course_tool = TOOL_FORUM; $htmlHeadXtra[] = ''; $htmlHeadXtra[] = ''; // The section (tabs). $this_section = SECTION_COURSES; // Notification for unauthorized people. api_protect_course_script(true); // Including additional library scripts. $nameTools = get_lang('Forums'); // Including necessary files. require_once 'forumconfig.inc.php'; require_once 'forumfunction.inc.php'; if (!empty($_GET['gradebook']) && $_GET['gradebook'] == 'view') { $_SESSION['gradebook'] = Security::remove_XSS($_GET['gradebook']); $gradebook = $_SESSION['gradebook']; } elseif (empty($_GET['gradebook'])) { unset($_SESSION['gradebook']); $gradebook = ''; } if (!empty($gradebook) && $gradebook == 'view') { $interbreadcrumb[] = array ( 'url' => '../gradebook/' . $_SESSION['gradebook_dest'], 'name' => get_lang('ToolGradebook') ); } $search_forum = isset($_GET['search']) ? Security::remove_XSS($_GET['search']) : ''; /* ACTIONS */ $actions = isset($_GET['action']) ? $_GET['action'] : ''; if ($actions == 'add') { switch ($_GET['content']) { case 'forum': $interbreadcrumb[] = array('url' => 'index.php?gradebook='.$gradebook.'&search='.$search_forum, 'name' => get_lang('Forum')); $interbreadcrumb[] = array('url' =>'#', 'name' => get_lang('AddForum')); break; case 'forumcategory': $interbreadcrumb[] = array('url' =>'index.php?gradebook='.$gradebook.'&search='.$search_forum, 'name' => get_lang('Forum')); $interbreadcrumb[] = array('url' =>'#', 'name' => get_lang('AddForumCategory')); break; default: break; } } else { $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('ForumCategories')); } Display::display_header(''); // Tool introduction Display::display_introduction_section(TOOL_FORUM); $form_count = 0; if (api_is_allowed_to_edit(false, true)) { //if is called from a learning path lp_id $lp_id = isset($_REQUEST['lp_id']) ? Security::remove_XSS($_REQUEST['lp_id']): null; handle_forum_and_forumcategories($lp_id); } // Notification if ($actions == 'notify' && isset($_GET['content']) && isset($_GET['id'])) { if (api_get_session_id() != 0 && api_is_allowed_to_session_edit(false, true) == false) { api_not_allowed(); } $return_message = set_notification($_GET['content'], $_GET['id']); Display :: display_confirmation_message($return_message, false); } get_whats_new(); $whatsnew_post_info = array(); $whatsnew_post_info = $_SESSION['whatsnew_post_info']; /* TRACKING */ event_access_tool(TOOL_FORUM); /* RETRIEVING ALL THE FORUM CATEGORIES AND FORUMS note: we do this here just after het handling of the actions to be sure that we already incorporate the latest changes */ // Step 1: We store all the forum categories in an array $forum_categories. $forum_categories_list = get_forum_categories(); // Step 2: We find all the forums (only the visible ones if it is a student). $forum_list = array(); $forum_list = get_forums(); $user_id = api_get_user_id(); /* RETRIEVING ALL GROUPS AND THOSE OF THE USER */ // The groups of the user. $groups_of_user = array(); $groups_of_user = GroupManager::get_group_ids($_course['real_id'], $user_id); // All groups in the course (and sorting them as the id of the group = the key of the array). if (!api_is_anonymous()) { $all_groups = GroupManager::get_group_list(); if (is_array($all_groups)) { foreach ($all_groups as $group) { $all_groups[$group['id']] = $group; } } } /* CLEAN GROUP ID FOR AJAXFILEMANAGER */ if (isset($_SESSION['_gid'])) { unset($_SESSION['_gid']); } /* ACTION LINKS */ $session_id = api_get_session_id(); echo '
';
echo ''.prepare4display($forum_category['cat_title']).$session_displayed.''. $session_img .' '; if ($forum_category['cat_comment'] != '' && trim($forum_category['cat_comment']) != ' ') { echo ''.prepare4display($forum_category['cat_comment']).''; } echo ' | ';
echo ''; if (api_is_allowed_to_edit(false, true) && !($forum_category['session_id'] == 0 && intval($session_id) != 0)) { echo ''.Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).''; echo '".Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).''; display_visible_invisible_icon('forumcategory', strval(intval($forum_category['cat_id'])), strval(intval($forum_category['visibility']))); display_lock_unlock_icon('forumcategory', strval(intval($forum_category['cat_id'])), strval(intval($forum_category['locked']))); display_up_down_icon('forumcategory', strval(intval($forum_category['cat_id'])), $forum_categories_list); } echo ' | '; echo '|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
'; echo ' | '.get_lang('Forum').' | '; echo ''.get_lang('Topics').' | '; echo ''.get_lang('Posts').' | '; echo ''.get_lang('LastPosts').' | '; echo ''.get_lang('Actions').' | '; echo ''; // Showing the image if (!empty($forum['forum_image'])) { $image_path = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/upload/forum/images/'.$forum['forum_image']; $image_size = api_getimagesize($image_path); $img_attributes = ''; if (!empty($image_size)) { if ($image_size['width'] > 100 || $image_size['height'] > 100) { //limit display width and height to 100px $img_attributes = ' style="width:100px" width="100px" height="100px"'; } $forum_image = ""; } else { $forum_image = ''; } echo $forum_image; } else { if ($forum['forum_of_group'] !== '0') { if (is_array($mywhatsnew_post_info) && !empty($mywhatsnew_post_info)) { echo Display::return_icon('forumgroupnew.gif'); } else { echo Display::return_icon('forumgroup.gif', get_lang('GroupForum')); } } else { if (is_array($mywhatsnew_post_info) && !empty($mywhatsnew_post_info)) { echo Display::return_icon('forum.gif', get_lang('Forum')); } else { echo Display::return_icon('forum.gif'); } } } echo ' | '; // Validacion when belongs to a session $session_img = api_get_session_image($forum['session_id'], $_user['status']); if ($forum['forum_of_group'] != '0') { $my_all_groups_forum_name = isset($all_groups[$forum['forum_of_group']]['name']) ? $all_groups[$forum['forum_of_group']]['name'] : null; $my_all_groups_forum_id = isset($all_groups[$forum['forum_of_group']]['id']) ? $all_groups[$forum['forum_of_group']]['id'] : null; $group_title = api_substr($my_all_groups_forum_name, 0, 30); $forum_title_group_addition = ' ('.get_lang('GoTo').' '.$group_title.')' . $session_img; } else { $forum_title_group_addition = ''; } if ((!isset($_SESSION['id_session']) || $_SESSION['id_session'] == 0) && !empty($forum['session_name'])) { $session_displayed = ' ('.$forum['session_name'].')'; } else { $session_displayed = ''; } $forum['forum_of_group'] == 0 ? $groupid = '' : $groupid = $forum['forum_of_group']; echo '';
//Forum title
echo prepare4display($forum['forum_title']).$session_displayed.''.$forum_title_group_addition.' '; echo ''.prepare4display($forum['forum_comment']).''; echo ' | ';
//$number_forum_topics_and_posts = get_post_topics_of_forum($forum['forum_id']); // deprecated
// The number of topics and posts.
$number_threads = isset($forum['number_of_threads']) ? $forum['number_of_threads'] : null;
$number_posts = isset($forum['number_of_posts']) ? $forum['number_of_posts'] : null;
echo ''.$number_threads.' | '; echo ''.$number_posts.' | '; // The last post in the forum. if ($forum['last_poster_name'] != '') { $name = $forum['last_poster_name']; $poster_id = 0; $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']); } echo '';
if (!empty($forum['last_post_id'])) {
echo api_convert_and_format_date($forum['last_post_date']).' '.get_lang('By').' '.display_user_link($poster_id, $name, '', $username); } echo ' | ';
echo ''; if (api_is_allowed_to_edit(false, true) && !($forum['session_id'] == 0 && intval($session_id) != 0)) { echo ''.Display::return_icon('edit.png',get_lang('Edit'), array(), ICON_SIZE_SMALL).''; echo '".Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).''; display_visible_invisible_icon('forum', $forum['forum_id'], $forum['visibility']); display_lock_unlock_icon('forum', $forum['forum_id'], $forum['locked']); display_up_down_icon('forum', $forum['forum_id'], $forums_in_category); } $iconnotify = 'send_mail.gif'; $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 = 'send_mail_checked.gif'; } } if (!api_is_anonymous() && api_is_allowed_to_session_edit(false, true) ) { echo ''.Display::return_icon($iconnotify, get_lang('NotifyMe')).''; } echo ' | '; } } } } else { echo '|
'.get_lang('NoForumInThisCategory').' | '.(api_is_allowed_to_edit(false, true) ? '' : ' | ').' |