Source for file index.php
Documentation is available at index.php
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2006 Dokeos S.A.
Copyright (c) 2006 Ghent University (UGent)
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
==============================================================================
* These files are a complete rework of the forum. The database structure is
* based on phpBB but all the code is rewritten. A lot of new functionalities
* - forum categories and forums can be sorted up or down, locked or made invisible
* - consistent and integrated forum administration
* - forum options: are students allowed to edit their post?
* moderation of posts (approval)
* reply only forums (students cannot create new threads)
* multiple forums per group
* - new view option: nested view
* @Author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @Copyright Ghent University
* @Copyright Patrick Cool
// name of the language file that needs to be included
$language_file = 'forum';
// including the global dokeos file
require ('../inc/global.inc.php');
// notice for unauthorized people.
// 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');
-----------------------------------------------------------
Including necessary files
-----------------------------------------------------------
include('forumconfig.inc.php');
include('forumfunction.inc.php');
$fck_attribute['Width'] = '100%';
$fck_attribute['Height'] = '175';
$fck_attribute['ToolbarSet'] = 'Middle';
$fck_attribute['Config']['IMUploadPath'] = 'upload/forum/';
$fck_attribute['Config']['FlashUploadPath'] = 'upload/forum/';
//error_reporting(E_ALL);
==============================================================================
==============================================================================
-----------------------------------------------------------
-----------------------------------------------------------
$interbreadcrumb[]= array("url" => "index.php?search=". Security::remove_XSS($_GET['search']),"name" => $nameTools);
if ($_GET['action']== 'add' ) {
switch ($_GET['content']){
case 'forumcategory': $interbreadcrumb[] = array ("url" => api_get_self(). '?'. api_get_cidreq(). '&action=add&content=forumcategory', 'name' => get_lang('AddForumCategory'));break;
//echo '<link href="forumstyles.css" rel="stylesheet" type="text/css" />';
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
$fck_attribute['ToolbarSet'] = 'ForumLight';
if ($_GET['action'] == 'notify' AND isset ($_GET['content']) AND isset ($_GET['id']))
if ($_GET['action']!= 'add' && $_GET['action']!= 'edit' )
$whatsnew_post_info = array();
$whatsnew_post_info = $_SESSION['whatsnew_post_info'];
-----------------------------------------------------------
-----------------------------------------------------------
include(api_get_path(LIBRARY_PATH). 'events.lib.inc.php');
------------------------------------------------------------------------------------------------------
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
// Step 1: We store all the forum categories in an array $forum_categories
$forum_categories= array();
// step 2: we find all the forums (only the visible ones if it is a student)
------------------------------------------------------------------------------------------------------
RETRIEVING ALL GROUPS AND THOSE OF THE USER
------------------------------------------------------------------------------------------------------
// the groups of the user
// all groups in the course (and sorting them as the id of the group = the key of the array
foreach ($all_groups as $group)
$all_groups[$group['id']]= $group;
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
//if (api_is_allowed_to_edit() and !$_GET['action'])
echo '<span style="float:right;">'. search_link(). '</span>';
//echo ' | <a href="forum_migration.php">'.get_lang('MigrateForum').'</a>';
------------------------------------------------------------------------------------------------------
Display Forum Categories and the Forums in it
------------------------------------------------------------------------------------------------------
echo '<table class="data_table" width="100%">'. "\n";
// Step 3: we display the forum_categories first
foreach ($forum_categories_list as $forum_category_key => $forum_category)
echo "\t<tr>\n\t\t<th style=\"padding-left:5px;\" align=\"left\" colspan=\"5\">";
if ($forum_category['cat_comment']<> '' AND trim($forum_category['cat_comment'])<> ' ')
echo '<span class="forum_description">'. prepare4display($forum_category['cat_comment']). '</span>';
echo '<th style="padding: 5px; vertical-align: top;" align="center" >';
// step 4: the interim headers (for the forum)
echo "\t<tr class=\"forum_header\">\n";
echo "\t\t<td colspan='2'>". get_lang('Forum'). "</td>\n";
echo "\t\t<td>". get_lang('Topics'). "</td>\n";
echo "\t\t<td>". get_lang('Posts'). "</td>\n";
echo "\t\t<td>". get_lang('LastPosts'). "</td>\n";
echo "\t\t<td>". get_lang('Actions'). "</td>\n";
// the forums in this category
// step 5: we display all the forums in this category.
foreach ($forum_list as $key=> $forum)
// Here we clean the whatnew_post_info array a little bit because to display the icon we
// test if $whatsnew_post_info[$forum['forum_id']] is empty or not.
if(is_array($whatsnew_post_info[$forum['forum_id']]))
foreach ($whatsnew_post_info[$forum['forum_id']] as $key_thread_id => $new_post_array)
if (empty($whatsnew_post_info[$forum['forum_id']][$key_thread_id]))
unset ($whatsnew_post_info[$forum['forum_id']][$key_thread_id]);
unset ($_SESSION['whatsnew_post_info'][$forum['forum_id']][$key_thread_id]);
// note: this can be speeded up if we transform the $forum_list to an array that uses the forum_category as the key.
// 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)))
// SHOULD WE SHOW THIS PARTICULAR FORUM
// you are teacher => show forum
// it is not a group forum => show forum (invisible forums are already left out see get_forums function)
if ($forum['forum_of_group']== '0')
// it is a group forum but it is public => show
if ($forum['forum_group_public_private']== 'public')
// it is a group forum and it is private
// 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 "\t<tr class=\"forum\">\n";
echo "\t\t<td width=\"20\">";
if ($forum['forum_of_group']!== '0')
if (is_array($whatsnew_post_info[$forum['forum_id']]) and !empty($whatsnew_post_info[$forum['forum_id']]))
echo icon('../img/forumgroupnew.gif');
echo icon('../img/forumgroup.gif');
if (is_array($whatsnew_post_info[$forum['forum_id']]) and !empty($whatsnew_post_info[$forum['forum_id']]))
echo icon('../img/forum.gif');
echo icon('../img/forum.gif');
if ($forum['forum_of_group']<> '0')
$group_title= substr($all_groups[$forum['forum_of_group']]['name'],0,30);
$forum_title_group_addition= ' (<a href="../group/group_space.php?'. api_get_cidreq(). '&gidReq='. $all_groups[$forum['forum_of_group']]['id']. '" class="forum_group_link">'. $group_title. '</a>)';
$forum_title_group_addition= '';
//$number_forum_topics_and_posts=get_post_topics_of_forum($forum['forum_id']); // deprecated
// the number of topics and posts
echo "\t\t<td>". $forum['number_of_threads']. "</td>\n";
echo "\t\t<td>". $forum['number_of_posts']. "</td>\n";
// the last post in the forum
if ($forum['last_poster_name']<> '')
$name= $forum['last_poster_name'];
$name= $forum['last_poster_firstname']. ' '. $forum['last_poster_lastname'];
$poster_id= $forum['last_poster_id'];
if (!empty($forum['last_post_id']))
echo "\t\t<td NOWRAP align='center'>";
$iconnotify = 'send_mail.gif';
if (is_array($_SESSION['forum_notification']['forum']))
if (in_array($forum['forum_id'],$_SESSION['forum_notification']['forum']))
$iconnotify = 'send_mail_checked.gif';
if (count($forum_list)== 0)
==============================================================================
==============================================================================
|