, Ghent University * @Copyright Ghent University * @Copyright Patrick Cool * * @package dokeos.forum */ // name of the language file that needs to be included $language_file = 'forum'; // including the global dokeos init file require '../inc/global.inc.php'; $htmlHeadXtra[] = ''; $htmlHeadXtra[] = ''; $htmlHeadXtra[] = ''; // including the global dokeos file require '../inc/global.inc.php'; // the section (tabs) $this_section=SECTION_COURSES; // notice for unauthorized people. api_protect_course_script(true); // including additional library scripts require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'); include_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php'); $nameTools=get_lang('Forum'); /* ----------------------------------------------------------- Including necessary files ----------------------------------------------------------- */ require 'forumconfig.inc.php'; require_once 'forumfunction.inc.php'; /* ============================================================================== MAIN DISPLAY SECTION ============================================================================== */ $fck_attribute['Width'] = '100%'; $fck_attribute['Height'] = '400'; $fck_attribute['Config']['IMUploadPath'] = 'upload/forum/'; $fck_attribute['Config']['FlashUploadPath'] = 'upload/forum/'; if(!api_is_allowed_to_edit(false,true)) { $fck_attribute['Config']['UserStatus'] = 'student'; $fck_attribute['ToolbarSet'] = 'Forum_Student'; } else { $fck_attribute['ToolbarSet'] = 'Forum'; } /* ----------------------------------------------------------- Header and Breadcrumbs ----------------------------------------------------------- */ if (isset($_SESSION['gradebook'])){ $gradebook= $_SESSION['gradebook']; } if (!empty($gradebook) && $gradebook=='view') { $interbreadcrumb[]= array ( 'url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook') ); } $current_forum_category=get_forum_categories($_GET['forumcategory']); $interbreadcrumb[]=array("url" => "index.php?gradebook=$gradebook&search=".Security::remove_XSS(urlencode(isset($_GET['search'])?$_GET['search']:'')),"name" => $nameTools); $interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id']."&origin=".$origin."&search=".Security::remove_XSS(urlencode(isset($_GET['search'])?$_GET['search']:'')),"name" => prepare4display($current_forum_category['cat_title'])); if (!empty($_GET['action']) && !empty($_GET['content'])) { if ($_GET['action']=='add' && $_GET['content']=='forum' ) { $interbreadcrumb[] = array ("url" => api_get_self().'?'.api_get_cidreq().'&action=add&content=forum', 'name' => get_lang('AddForum')); } } //are we in a lp ? $origin = ''; if (isset($_GET['origin'])) { $origin = Security::remove_XSS($_GET['origin']); } if ($origin=='learnpath') { include(api_get_path(INCLUDE_PATH).'reduced_header.inc.php'); } else { Display :: display_header(null); //api_display_tool_title($nameTools); } /* ------------------------------------------------------------------------------------------------------ ACTIONS ------------------------------------------------------------------------------------------------------ */ $whatsnew_post_info=$_SESSION['whatsnew_post_info']; /* ----------------------------------------------------------- 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) AND $current_forum_category['visibility']==0) { forum_not_allowed_here(); } /* ----------------------------------------------------------- Action Links ----------------------------------------------------------- */ echo '
'; echo ''.search_link().''; echo ''.Display::return_icon('back.png').' '.get_lang('BackToForumOverview').''; if (api_is_allowed_to_edit(false,true)) { //echo ''.get_lang('AddForumCategory').' | '; echo ' '.Display::return_icon('forum_new.gif', get_lang('AddForum')).' '.get_lang('AddForum').''; //echo ''.Display::return_icon('forum_new.gif', get_lang('AddForum')).' '.get_lang('AddForum').''; } echo '
'; /* ------------------------------------------------------------------------------------------------------ ACTIONS ------------------------------------------------------------------------------------------------------ */ $action_forums=isset($_GET['action']) ? $_GET['action'] : ''; if (api_is_allowed_to_edit(false,true)) { handle_forum_and_forumcategories(); } // notification if ($action_forums == 'notify' AND isset($_GET['content']) AND isset($_GET['id'])) { $return_message = set_notification($_GET['content'],$_GET['id']); Display :: display_confirmation_message($return_message,false); } if ($action_forums!='add') { /* ------------------------------------------------------------------------------------------------------ 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=array(); $forum_category=get_forum_categories($_GET['forumcategory']); // step 2: we find all the forums $forum_list=array(); $forum_list=get_forums(); /* ------------------------------------------------------------------------------------------------------ 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['dbName'], $_user['user_id']); // all groups in the course (and sorting them as the id of the group = the key of the array $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']); } /* ----------------------------------------------------------- Display Forum Categories and the Forums in it ----------------------------------------------------------- */ echo "\n"; $my_session=isset($_SESSION['id_session']) ? $_SESSION['id_session'] : null; $forum_categories_list=''; echo "\t\n\t\t\n"; if (api_is_allowed_to_edit(false,true) && !($forum_category['session_id']==0 && intval($my_session)!=0)) { echo '\n"; } echo "\t\n"; // step 3: the interim headers (for the forum) echo "\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\n"; // the forums in this category $forums_in_category=get_forums_in_category($forum_category['cat_id']); // step 4: we display all the forums in this category. $forum_count=0; foreach ($forum_list as $key=>$forum) { if ($forum['forum_category']==$forum_category['cat_id']) { // the forum has to be showed if // 1.v it is a not a group forum (teacher and student) // 2.v it is a group forum and it is public (teacher and student) // 3. it is a group forum and it is private (always for teachers only if the user is member of the forum // if the forum is private and it is a group forum and the user is not a member of the group forum then it cannot be displayed //if (!($forum['forum_group_public_private']=='private' AND !is_null($forum['forum_of_group']) AND !in_array($forum['forum_of_group'], $groups_of_user))) //{ $show_forum=false; // SHOULD WE SHOW THIS PARTICULAR FORUM // you are teacher => show forum if (api_is_allowed_to_edit(false,true)) { //echo 'teacher'; $show_forum=true; } else { // you are not a teacher //echo 'student'; // it is not a group forum => show forum (invisible forums are already left out see get_forums function) if ($forum['forum_of_group']=='0') { //echo '-gewoon forum'; $show_forum=true; } else { // it is a group forum //echo '-groepsforum'; // it is a group forum but it is public => show if ($forum['forum_group_public_private']=='public') { $show_forum=true; //echo '-publiek'; } else { // it is a group forum and it is private //echo '-prive'; // it is a group forum and it is private but the user is member of the group if (in_array($forum['forum_of_group'],$groups_of_user)) { //echo '-is lid'; $show_forum=true; } else { //echo '-is GEEN lid'; $show_forum=false; } } } } //echo '
'; $form_count=isset($form_count)?$form_count:0; if ($show_forum === true) { $form_count++; echo "\t\n"; echo "\t\t\n"; 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=substr($my_all_groups_forum_name,0,30); $forum_title_group_addition=' ('.get_lang('GoTo').' '.$group_title.')'; } 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 = ''; } echo "\t\t\n"; //$number_forum_topics_and_posts=get_post_topics_of_forum($forum['forum_id']); // deprecated // the number of topics and posts $my_number_threads=isset($forum['number_of_threads']) ? $forum['number_of_threads'] : ''; $my_number_posts=isset($forum['number_of_posts']) ? $forum['number_of_posts'] : ''; echo "\t\t\n"; echo "\t\t\n"; // the last post in the forum if ($forum['last_poster_name']<>'') { $name=$forum['last_poster_name']; $poster_id=0; } else { $name=$forum['last_poster_firstname'].' '.$forum['last_poster_lastname']; $poster_id=$forum['last_poster_id']; } echo "\t\t\n"; echo "\t\t\n"; echo "\t"; } } } if (count($forum_list) == 0) { echo "\t\n"; } echo "
"; echo ''.prepare4display($forum_category['cat_title']).'
'; echo ''.prepare4display($forum_category['cat_comment']).''; echo "
'; echo "".icon('../img/edit.gif',get_lang('Edit')).""; echo "".icon('../img/delete.gif',get_lang('Delete')).""; display_visible_invisible_icon('forumcategory', $forum_category['cat_id'], $forum_category['visibility'], array("forumcategory"=>$_GET['forumcategory'])); display_lock_unlock_icon('forumcategory',$forum_category['cat_id'], $forum_category['locked'], array("forumcategory"=>$_GET['forumcategory'])); display_up_down_icon('forumcategory',$forum_category['cat_id'], $forum_categories_list); echo "
".get_lang('Forum')."".get_lang('Topics')."".get_lang('Posts')."".get_lang('LastPosts')."".get_lang('Actions')."
"; $my_whatsnew_post_info=isset($whatsnew_post_info[$forum['forum_id']])?$whatsnew_post_info[$forum['forum_id']]:null; if ($forum['forum_of_group']!=='0') { if (is_array($my_whatsnew_post_info) and !empty($my_whatsnew_post_info)) { echo icon('../img/forumgroupnew.gif'); } else { echo icon('../img/forumgroup.gif', get_lang('GroupForum')); } } else { if (is_array($my_whatsnew_post_info) and !empty($my_whatsnew_post_info)) { echo icon('../img/forum.gif', get_lang('Forum')); } else { echo icon('../img/forum.gif'); } } echo "".prepare4display($forum['forum_title']).$session_displayed.''.$forum_title_group_addition.'
'.prepare4display($forum['forum_comment'])."
".$my_number_threads."".$my_number_posts.""; if (!empty($forum['last_post_id'])) { echo $forum['last_post_date']." ".get_lang('By').' '.display_user_link($poster_id, $name); } echo ""; if (api_is_allowed_to_edit(false,true) && !($forum['session_id']==0 && intval(isset($_SESSION['id_session'])?$_SESSION['id_session']:null)!=0)) { echo "".icon('../img/edit.gif',get_lang('Edit')).""; echo "".icon('../img/delete.gif',get_lang('Delete')).""; display_visible_invisible_icon('forum',$forum['forum_id'], $forum['visibility'], array("forumcategory"=>$_GET['forumcategory'])); display_lock_unlock_icon('forum',$forum['forum_id'], $forum['locked'], array("forumcategory"=>$_GET['forumcategory'])); display_up_down_icon('forum',$forum['forum_id'], $forums_in_category); } $iconnotify = 'send_mail.gif'; if (is_array(isset($_SESSION['forum_notification']['forum'])?$_SESSION['forum_notification']['forum']:null)) { if (in_array($forum['forum_id'],$_SESSION['forum_notification']['forum'])) { $iconnotify = 'send_mail_checked.gif'; } } echo "".icon('../img/'.$iconnotify,get_lang('NotifyMe')).""; echo "
".get_lang('NoForumInThisCategory')."
\n"; } /* ============================================================================== FOOTER ============================================================================== */ // footer if ($origin!='learnpath') { Display :: display_footer(); }