[svn r14793] Ajouter une annxe dans Blogs et Forums - 1 (FS#2396)

skala
Julio Montoya 17 years ago
parent b0d9e4c931
commit 18b82ae616
  1. 16
      main/blog/blog.php
  2. 10
      main/blog/blog_admin.php
  3. 90
      main/blog/download.php
  4. 13
      main/css/default_with_tabs/default.css
  5. 92
      main/forum/download.php
  6. 113
      main/forum/forumconfig.inc.php
  7. 5827
      main/forum/forumfunction.inc.php
  8. 709
      main/forum/viewforum.php
  9. 361
      main/forum/viewthread_flat.inc.php
  10. 23
      main/forum/viewthread_nested.inc.php
  11. 19
      main/forum/viewthread_threaded.inc.php
  12. 42
      main/inc/lib/add_course.lib.inc.php
  13. 5415
      main/inc/lib/blog.lib.php
  14. 4
      main/inc/lib/database.lib.php
  15. 3
      main/install/migrate-db-1.8.4-1.8.5-pre.sql

@ -3,7 +3,7 @@
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004 Dokeos S.A.
Copyright (c) 2004-2008 Dokeos SPRL
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
Copyright (c) various contributors
@ -18,7 +18,8 @@
See the GNU General Public License for more details.
Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
info@dokeos.com
==============================================================================
@ -57,6 +58,7 @@ require_once (api_get_path(LIBRARY_PATH)."/display.lib.php");
require_once (api_get_path(LIBRARY_PATH)."/text.lib.php");
require_once (api_get_path(LIBRARY_PATH)."/blog.lib.php");
require_once (api_get_path(LIBRARY_PATH)."/fckeditor.lib.php");
$blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
$nameTools = get_lang("Blogs");
$DaysShort = array (get_lang("SundayShort"), get_lang("MondayShort"), get_lang("TuesdayShort"), get_lang("WednesdayShort"), get_lang("ThursdayShort"), get_lang("FridayShort"), get_lang("SaturdayShort"));
@ -71,8 +73,8 @@ $current_page = $_GET['action'];
==============================================================================
*/
if ($_POST['new_post_submit'])
{
Blog :: create_post($_POST['post_title'], $_POST['post_full_text'], $blog_id);
{
Blog :: create_post($_POST['post_title'], $_POST['post_full_text'], $_POST['post_file_comment'],$blog_id);
}
if ($_POST['edit_post_submit'])
{
@ -80,7 +82,7 @@ if ($_POST['edit_post_submit'])
}
if ($_POST['new_comment_submit'])
{
Blog :: create_comment($_POST['comment_title'], $_POST['comment_text'], $blog_id, (int)$_GET['post_id'], $_POST['comment_parent_id']);
Blog :: create_comment($_POST['comment_title'], $_POST['comment_text'], $_POST['post_file_comment'],$blog_id, (int)$_GET['post_id'], $_POST['comment_parent_id']);
}
if ($_POST['new_task_submit'])
@ -144,8 +146,8 @@ if ($_GET['action'] == 'view_post')
if ($_GET['do'] == 'delete_comment')
{
if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_delete', $task_id))
{
Blog :: delete_comment($blog_id, (int)$_GET['comment_id']);
{
Blog :: delete_comment($blog_id, (int)$_GET['post_id'],(int)$_GET['comment_id']);
}
else
{

@ -3,7 +3,7 @@
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004 Dokeos S.A.
Copyright (c) 2004-2008 Dokeos SPRL
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
Copyright (c) various contributors
@ -18,7 +18,8 @@
See the GNU General Public License for more details.
Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
info@dokeos.com
==============================================================================
@ -36,6 +37,8 @@ $language_file = "blog";
include('../inc/global.inc.php');
$this_section=SECTION_COURSES;
$blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
/* ------------ ACCESS RIGHTS ------------ */
// notice for unauthorized people.
api_protect_course_script(true);
@ -51,8 +54,7 @@ if (api_is_allowed_to_edit())
{
require_once(api_get_path(LIBRARY_PATH) . "blog.lib.php");
$nameTools = get_lang("blog_management");
$nameTools = get_lang("blog_management");
// showing the header if we are not in the learning path, if we are in
// the learning path, we do not include the banner so we have to explicitly

@ -0,0 +1,90 @@
<?php // $Id: download.php 12218 2007-05-01 18:27:14Z yannoo $
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2008 Dokeos SPRL
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, rue du Corbeau, 108, B-1030 Brussels, Belgium
info@dokeos.com
==============================================================================
*/
/**
==============================================================================
* This file is responsible for passing requested documents to the browser.
* Html files are parsed to fix a few problems with URLs,
* but this code will hopefully be replaced soon by an Apache URL
* rewrite mechanism.
*
* @package dokeos.document
==============================================================================
*/
/*
==============================================================================
MAIN CODE
==============================================================================
*/
session_cache_limiter('public');
include('../inc/global.inc.php');
$this_section=SECTION_COURSES;
include(api_get_path(LIBRARY_PATH).'document.lib.php');
// IMPORTANT to avoid caching of documents
header('Expires: Wed, 01 Jan 1990 00:00:00 GMT');
header('Cache-Control: public');
header('Pragma: no-cache');
//protection
api_protect_course_script(true);
$doc_url = $_GET['file'];
//change the '&' that got rewritten to '///' by mod_rewrite back to '&'
$doc_url = str_replace('///', '&', $doc_url);
//still a space present? it must be a '+' (that got replaced by mod_rewrite)
$doc_url = str_replace(' ', '+', $doc_url);
$doc_url = str_replace('/..', '', $doc_url); //echo $doc_url;
include(api_get_path(LIBRARY_PATH).'events.lib.inc.php');
if (! isset($_course))
{
api_not_allowed(true);
}
//if the rewrite rule asks for a directory, we redirect to the document explorer
if (is_dir(api_get_path(SYS_COURSE_PATH).$_course['path'].'/upload/blog/'.$doc_url))
{
//remove last slash if present
while ($doc_url{$dul = strlen($doc_url)-1}=='/') $doc_url = substr($doc_url,0,$dul);
//create the path
$document_explorer = api_get_path(WEB_COURSE_PATH).api_get_course_path(); // home course path
//redirect
header('Location: '.$document_explorer);
}
$blog_table_attachment = '`'.$_course['dbNameGlu'].'blog_attachment'.'`';
// launch event
event_download($doc_url);
$sys_course_path = api_get_path(SYS_COURSE_PATH);
$full_file_name = $sys_course_path.$_course['path'].'/upload/blog/'.$doc_url;
$sql = 'SELECT filename FROM '.$blog_table_attachment.' WHERE path LIKE BINARY "'.$doc_url.'"';
$result= api_sql_query($sql, __FILE__, __LINE__);
$row= Database::fetch_array($result);
DocumentManager::file_send_for_download($full_file_name,TRUE, $row['filename']);
exit;
?>

@ -1108,6 +1108,13 @@ a.forum_group_link {
font-weight: normal;
}
.forum_attach_comment {
color: #737780;
font-style: italic ;
font-weight: normal;
}
/* **** BLOG **** */
span.blog_title {
@ -1233,6 +1240,12 @@ div.comments {
background-color: #F4F4F4;
}
.attachment_comment {
color: #737780;
font-style: italic ;
font-weight: normal;
}
.link {text-decoration: none; font-weight : bold; color : #1657A9; cursor: pointer}
.link:hover {text-decoration: none; color: #abd9f1; font-weight: bold; cursor: pointer}

@ -0,0 +1,92 @@
<?php // $Id: download.php 12218 2007-05-01 18:27:14Z yannoo $
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2008 Dokeos SPRL
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, rue du Corbeau, 108, B-1030 Brussels, Belgium
info@dokeos.com
==============================================================================
*/
/**
==============================================================================
* This file is responsible for passing requested documents to the browser.
* Html files are parsed to fix a few problems with URLs,
* but this code will hopefully be replaced soon by an Apache URL
* rewrite mechanism.
*
* @package dokeos.document
==============================================================================
*/
/*
==============================================================================
MAIN CODE
==============================================================================
*/
session_cache_limiter('public');
include('../inc/global.inc.php');
$this_section=SECTION_COURSES;
include(api_get_path(LIBRARY_PATH).'document.lib.php');
// IMPORTANT to avoid caching of documents
header('Expires: Wed, 01 Jan 1990 00:00:00 GMT');
header('Cache-Control: public');
header('Pragma: no-cache');
//protection
api_protect_course_script(true);
$doc_url = $_GET['file'];
//change the '&' that got rewritten to '///' by mod_rewrite back to '&'
$doc_url = str_replace('///', '&', $doc_url);
//still a space present? it must be a '+' (that got replaced by mod_rewrite)
$doc_url = str_replace(' ', '+', $doc_url);
$doc_url = str_replace('/..', '', $doc_url); //echo $doc_url;
include(api_get_path(LIBRARY_PATH).'events.lib.inc.php');
if (! isset($_course))
{
api_not_allowed(true);
}
//if the rewrite rule asks for a directory, we redirect to the document explorer
if (is_dir(api_get_path(SYS_COURSE_PATH).$_course['path'].'/upload/forum/'.$doc_url))
{
//remove last slash if present
//$doc_url = ($doc_url{strlen($doc_url)-1}=='/')?substr($doc_url,0,strlen($doc_url)-1):$doc_url;
//mod_rewrite can change /some/path/ to /some/path// in some cases, so clean them all off (Ren<EFBFBD>)
while ($doc_url{$dul = strlen($doc_url)-1}=='/') $doc_url = substr($doc_url,0,$dul);
//create the path
$document_explorer = api_get_path(WEB_CODE_PATH).'forum';
//redirect
header('Location: '.$document_explorer);
}
$tbl_blogs_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
// launch event
event_download($doc_url);
$sys_course_path = api_get_path(SYS_COURSE_PATH);
$full_file_name = $sys_course_path.$_course['path'].'/upload/forum/'.$doc_url;
$sql = 'SELECT filename FROM '.$tbl_blogs_attachment.' WHERE path LIKE BINARY "'.$doc_url.'"';
$result= api_sql_query($sql, __FILE__, __LINE__);
$row= Database::fetch_array($result);
DocumentManager::file_send_for_download($full_file_name,TRUE, $row['filename']);
exit;
?>

@ -1,57 +1,58 @@
<?php
/**
* @todo use Database :: get_course_table
* @todo move the tool constants to the appropriate place
* @todo make config settings out of $forum_setting
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8
*/
/*
-----------------------------------------------------------
Database Variables
-----------------------------------------------------------
*/
$table_categories = "`".$_course["dbNameGlu"]."forum_category"."`";
$table_forums = "`".$_course["dbNameGlu"]."forum_forum"."`";
$table_threads = "`".$_course["dbNameGlu"]."forum_thread"."`";
$table_posts = "`".$_course["dbNameGlu"]."forum_post"."`";
$table_mailcue = "`".$_course["dbNameGlu"]."forum_mailcue"."`";
$table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
$table_users = Database :: get_main_table(TABLE_MAIN_USER);
/*
-----------------------------------------------------------
Constants
-----------------------------------------------------------
*/
define("TOOL_FORUM_CATEGORY",'forum_category');
define("TOOL_FORUM",'forum');
define("TOOL_FORUM_THREAD",'forum_thread');
define("TOOL_FORUM_POST",'forum_post');
/*
-----------------------------------------------------------
Some configuration settings
(these can go to the dokeos config settings afterwards)
-----------------------------------------------------------
*/
// if this setting is true then an I-frame will be displayed when replying
$forum_setting['show_thread_iframe_on_reply']=true;
// if this setting is true then students and teachers can check a checkbox so that they receive a mail when somebody replies to the thread
$forum_setting['allow_post_notificiation']=true;
// when this setting is true then the course admin can post threads that are important. These posts remain on top all the time (until made unsticky)
// these special posts are indicated with a special icon also
$forum_setting['allow_sticky']=true;
// when this setting is true there will be a column that displays the latest post (date and poster) of the given forum. This requires quite some sql statements that
// might slow down the page with the fora.
// note: I'm currently investigating how it would be possible to increase the performance of this part.
$forum_setting['show_last_post']=false;
<?php
/**
* @todo use Database :: get_course_table
* @todo move the tool constants to the appropriate place
* @todo make config settings out of $forum_setting
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @version february 2006, dokeos 1.8
*/
/*
-----------------------------------------------------------
Database Variables
-----------------------------------------------------------
*/
$table_categories = "`".$_course["dbNameGlu"]."forum_category"."`";
$table_forums = "`".$_course["dbNameGlu"]."forum_forum"."`";
$table_threads = "`".$_course["dbNameGlu"]."forum_thread"."`";
$table_posts = "`".$_course["dbNameGlu"]."forum_post"."`";
$table_mailcue = "`".$_course["dbNameGlu"]."forum_mailcue"."`";
$forum_table_attachment = Database::get_course_table(TABLE_FORUM_ATTACHMENT);
$table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
$table_users = Database :: get_main_table(TABLE_MAIN_USER);
/*
-----------------------------------------------------------
Constants
-----------------------------------------------------------
*/
define("TOOL_FORUM_CATEGORY",'forum_category');
define("TOOL_FORUM",'forum');
define("TOOL_FORUM_THREAD",'forum_thread');
define("TOOL_FORUM_POST",'forum_post');
/*
-----------------------------------------------------------
Some configuration settings
(these can go to the dokeos config settings afterwards)
-----------------------------------------------------------
*/
// if this setting is true then an I-frame will be displayed when replying
$forum_setting['show_thread_iframe_on_reply']=true;
// if this setting is true then students and teachers can check a checkbox so that they receive a mail when somebody replies to the thread
$forum_setting['allow_post_notificiation']=true;
// when this setting is true then the course admin can post threads that are important. These posts remain on top all the time (until made unsticky)
// these special posts are indicated with a special icon also
$forum_setting['allow_sticky']=true;
// when this setting is true there will be a column that displays the latest post (date and poster) of the given forum. This requires quite some sql statements that
// might slow down the page with the fora.
// note: I'm currently investigating how it would be possible to increase the performance of this part.
$forum_setting['show_last_post']=false;
?>

File diff suppressed because it is too large Load Diff

@ -1,354 +1,355 @@
<?php
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2006-2008 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
Mail: info@dokeos.com
==============================================================================
*/
/**
* 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
* are added:
* - 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
* - sticky messages
* - new view option: nested view
* - quoting a message
*
* @Author Patrick Cool <patrick.cool@UGent.be>, 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 file
require ('../inc/global.inc.php');
// notice for unauthorized people.
api_protect_course_script(true);
// the section (tabs)
$this_section=SECTION_COURSES;
// 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');
//are we in a lp ?
$origin = '';
if(isset($_GET['origin']))
{
$origin = Security::remove_XSS($_GET['origin']);
$origin_string = '&origin='.$origin;
}
/*
-----------------------------------------------------------
Including necessary files
-----------------------------------------------------------
*/
include('forumconfig.inc.php');
include('forumfunction.inc.php');
/*
==============================================================================
MAIN DISPLAY SECTION
==============================================================================
*/
/*
-----------------------------------------------------------
Retrieving forum and forum categorie information
-----------------------------------------------------------
*/
// we are getting all the information about the current forum and forum category.
// note pcool: I tried to use only one sql statement (and function) for this
// but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table
$current_forum=get_forum_information($_GET['forum']); // note: this has to be validated that it is an existing forum.
$current_forum_category=get_forumcategory_information($current_forum['forum_category']);
/*
-----------------------------------------------------------
Header and Breadcrumbs
-----------------------------------------------------------
*/
$interbreadcrumb[]=array("url" => "index.php?search=".Security::remove_XSS($_GET['search']),"name" => $nameTools);
$interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id']."&amp;search=".Security::remove_XSS(urlencode($_GET['search'])),"name" => prepare4display($current_forum_category['cat_title']));
$interbreadcrumb[]=array("url" => "viewforum.php?forum=".Security::remove_XSS($_GET['forum'])."&amp;search=".Security::remove_XSS(urlencode($_GET['search'])),"name" => prepare4display($current_forum['forum_title']));
if($origin=='learnpath')
{
include(api_get_path(INCLUDE_PATH).'reduced_header.inc.php');
} else
{
// the last element of the breadcrumb navigation is already set in interbreadcrumb, so give empty string
Display :: display_header('');
api_display_tool_title($nameTools);
}
//echo '<link href="forumstyles.css" rel="stylesheet" type="text/css" />';
/*
-----------------------------------------------------------
Actions
-----------------------------------------------------------
*/
// Change visibility of a forum or a forum category
if (($_GET['action']=='invisible' OR $_GET['action']=='visible') AND isset($_GET['content']) AND isset($_GET['id']) AND api_is_allowed_to_edit())
{
$message=change_visibility($_GET['content'], $_GET['id'],$_GET['action']);// note: this has to be cleaned first
}
if (($_GET['action']=='lock' OR $_GET['action']=='unlock') AND isset($_GET['content']) AND isset($_GET['id']) AND api_is_allowed_to_edit())
{
$message=change_lock_status($_GET['content'], $_GET['id'],$_GET['action']);// note: this has to be cleaned first
}
if ($_GET['action']=='delete' AND isset($_GET['content']) AND isset($_GET['id']) AND api_is_allowed_to_edit())
{
$message=delete_forum_forumcategory_thread($_GET['content'],$_GET['id']); // note: this has to be cleaned first
}
if ($_GET['action']=='move' and isset($_GET['thread']))
{
$message=move_thread_form();
}
/*
-----------------------------------------------------------
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() AND ($current_forum_category['visibility']==0 OR $current_forum['visibility']==0))
{
forum_not_allowed_here();
}
/*
-----------------------------------------------------------
Display the action messages
-----------------------------------------------------------
*/
if (isset($message))
{
Display :: display_confirmation_message($message);
}
/*
-----------------------------------------------------------
Action Links
-----------------------------------------------------------
*/
echo '<span style="float:right;">'.search_link().'</span>';
// The link should appear when
// 1. the course admin is here
// 2. the course member is here and new threads are allowed
// 3. a visitor is here and new threads AND allowed AND anonymous posts are allowed
if (api_is_allowed_to_edit() OR ($current_forum['allow_new_threads']==1 AND isset($_user['user_id'])) OR ($current_forum['allow_new_threads']==1 AND !isset($_user['user_id']) AND $current_forum['allow_anonymous']==1))
{
if ($current_forum['locked'] <> 1 AND $current_forum['locked'] <> 1)
{
echo '<a href="newthread.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).$origin_string.'">'.Display::return_icon('forumthread_new.gif').' '.get_lang('NewTopic').'</a>';
}
else
{
echo get_lang('ForumLocked');
}
}
/*
-----------------------------------------------------------
Display
-----------------------------------------------------------
*/
echo "<table class=\"data_table\" width='100%'>\n";
// the current forum
if($origin != 'learnpath')
{
echo "\t<tr>\n\t\t<th style=\"padding-left:5px;\" align=\"left\" colspan=\"7\">";
echo '<span class="forum_title">'.prepare4display($current_forum['forum_title']).'</span>';
if (!empty ($current_forum['forum_comment']))
{
echo '<br><span class="forum_description">'.prepare4display($current_forum['forum_comment']).'</span>';
}
if (!empty ($current_forum_category['cat_title']))
{
echo '<br /><span class="forum_low_description">'.prepare4display($current_forum_category['cat_title'])."</span><br />";
}
echo "</th>\n";
echo "\t</tr>\n";
}
echo "</th>\n";
echo "\t</tr>\n";
// The column headers (to do: make this sortable)
echo "\t<tr class=\"forum_threadheader\">\n";
echo "\t\t<td></td>\n";
echo "\t\t<td>".get_lang('Title')."</td>\n";
echo "\t\t<td>".get_lang('Replies')."</td>\n";
echo "\t\t<td>".get_lang('Views')."</td>\n";
echo "\t\t<td>".get_lang('Author')."</td>\n";
echo "\t\t<td>".get_lang('LastPost')."</td>\n";
if (api_is_allowed_to_edit())
{
echo "\t\t<td>".get_lang('Actions')."</td>\n";
}
echo "\t</tr>\n";
// getting al the threads
$threads=get_threads($_GET['forum']); // note: this has to be cleaned first
$whatsnew_post_info=$_SESSION['whatsnew_post_info'];
$counter=0;
if(is_array($threads))
{
foreach ($threads as $row)
{
// thread who have no replies yet and the only post is invisible should not be displayed to students.
if (api_is_allowed_to_edit() OR !($row['thread_replies']=='0' AND $row['visible']=='0'))
{
if($counter%2==0)
{
$class="row_odd";
}
else
{
$class="row_even";
}
echo "\t<tr class=\"$class\">\n";
echo "\t\t<td>";
if (is_array($whatsnew_post_info[$_GET['forum']][$row['thread_id']]) and !empty($whatsnew_post_info[$_GET['forum']][$row['thread_id']]))
{
echo icon('../img/forumthread.gif');
}
else
{
echo icon('../img/forumthread.gif');
}
if ($row['thread_sticky']==1)
{
echo icon('../img/exclamation.gif');
}
echo "</td>\n";
echo "\t\t<td><a href=\"viewthread.php?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".$row['thread_id'].$origin_string."&amp;search=".Security::remove_XSS(urlencode($_GET['search']))."\" ".class_visible_invisible($row['visibility']).">".prepare4display($row['thread_title'])."</a></td>\n";
echo "\t\t<td>".$row['thread_replies']."</td>\n";
if ($row['user_id']=='0')
{
$name=prepare4display($row['thread_poster_name']);
}
else
{
$name=$row['firstname'].' '.$row['lastname'];
}
echo "\t\t<td>".$row['thread_views']."</td>\n";
if ($row['last_poster_user_id']=='0')
{
$name=$row['poster_name'];
}
else
{
$name=$row['last_poster_firstname'].' '.$row['last_poster_lastname'];
}
if($origin != 'learnpath')
{
echo "\t\t<td>".display_user_link($row['user_id'], $name)."</td>\n";
}
else
{
echo "\t\t<td>".$name."</td>\n";
}
// if the last post is invisible and it is not the teacher who is looking then we have to find the last visible post of the thread
if (($row['visible']=='1' OR api_is_allowed_to_edit()) && $origin!='learnpath')
{
$last_post=$row['thread_date']." ".get_lang('By').' '.display_user_link($row['last_poster_user_id'], $name);
}
else if($origin!='learnpath')
{
$last_post_sql="SELECT post.*, user.firstname, user.lastname FROM $table_posts post, $table_users user WHERE post.poster_id=user.user_id AND visible='1' AND thread_id='".$row['thread_id']."' ORDER BY post_id DESC";
$last_post_result=api_sql_query($last_post_sql, __LINE__, __FILE__);
$last_post_row=mysql_fetch_array($last_post_result);
$name=$last_post_row['firstname'].' '.$last_post_row['lastname'];
$last_post=$last_post_row['post_date']." ".get_lang('By').' '.display_user_link($last_post_row['poster_id'], $name);
}
else
{
$last_post_sql="SELECT post.*, user.firstname, user.lastname FROM $table_posts post, $table_users user WHERE post.poster_id=user.user_id AND visible='1' AND thread_id='".$row['thread_id']."' ORDER BY post_id DESC";
$last_post_result=api_sql_query($last_post_sql, __LINE__, __FILE__);
$last_post_row=mysql_fetch_array($last_post_result);
$name=$last_post_row['firstname'].' '.$last_post_row['lastname'];
$last_post=$last_post_row['post_date']." ".get_lang('By').' '.$name;
}
echo "\t\t<td>".$last_post."</td>\n";
if (api_is_allowed_to_edit())
{
echo "\t\t<td>";
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&amp;action=delete&amp;content=thread&amp;id=".$row['thread_id'].$origin_string."\" onclick=\"javascript:if(!confirm('".addslashes(htmlentities(get_lang("DeleteCompleteThread"),ENT_QUOTES,$charset))."')) return false;\">".icon('../img/delete.gif',get_lang('Delete'))."</a>";
display_visible_invisible_icon('thread', $row['thread_id'], $row['visibility'], array("forum"=>$_GET['forum'],'origin'=>$origin));
display_lock_unlock_icon('thread',$row['thread_id'], $row['locked'], array("forum"=>$_GET['forum'],'origin'=>$origin));
echo "<a href=\"viewforum.php?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&amp;action=move&amp;thread=".$row['thread_id'].$origin_string."\">".icon('../img/deplacer_fichier.gif',get_lang('MoveThread'))."</a>";
echo "</td>\n";
}
echo "\t</tr>\n";
}
$counter++;
}
}
echo "</table>";
/*
==============================================================================
FOOTER
==============================================================================
*/
if($origin != 'learnpath')
{
Display :: display_footer();
}
?>
<?php
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2006-2008 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, rue du Corbeau, 108, B-1030 Brussels, Belgium
Mail: info@dokeos.com
==============================================================================
*/
/**
* 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
* are added:
* - 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
* - sticky messages
* - new view option: nested view
* - quoting a message
*
* @Author Patrick Cool <patrick.cool@UGent.be>, 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 file
require ('../inc/global.inc.php');
// notice for unauthorized people.
api_protect_course_script(true);
// the section (tabs)
$this_section=SECTION_COURSES;
// 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');
//are we in a lp ?
$origin = '';
if(isset($_GET['origin']))
{
$origin = Security::remove_XSS($_GET['origin']);
$origin_string = '&origin='.$origin;
}
/*
-----------------------------------------------------------
Including necessary files
-----------------------------------------------------------
*/
include('forumconfig.inc.php');
include('forumfunction.inc.php');
/*
==============================================================================
MAIN DISPLAY SECTION
==============================================================================
*/
/*
-----------------------------------------------------------
Retrieving forum and forum categorie information
-----------------------------------------------------------
*/
// we are getting all the information about the current forum and forum category.
// note pcool: I tried to use only one sql statement (and function) for this
// but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table
$current_forum=get_forum_information($_GET['forum']); // note: this has to be validated that it is an existing forum.
$current_forum_category=get_forumcategory_information($current_forum['forum_category']);
/*
-----------------------------------------------------------
Header and Breadcrumbs
-----------------------------------------------------------
*/
$interbreadcrumb[]=array("url" => "index.php?search=".Security::remove_XSS($_GET['search']),"name" => $nameTools);
$interbreadcrumb[]=array("url" => "viewforumcategory.php?forumcategory=".$current_forum_category['cat_id']."&amp;search=".Security::remove_XSS(urlencode($_GET['search'])),"name" => prepare4display($current_forum_category['cat_title']));
$interbreadcrumb[]=array("url" => "viewforum.php?forum=".Security::remove_XSS($_GET['forum'])."&amp;search=".Security::remove_XSS(urlencode($_GET['search'])),"name" => prepare4display($current_forum['forum_title']));
if($origin=='learnpath')
{
include(api_get_path(INCLUDE_PATH).'reduced_header.inc.php');
} else
{
// the last element of the breadcrumb navigation is already set in interbreadcrumb, so give empty string
Display :: display_header('');
api_display_tool_title($nameTools);
}
//echo '<link href="forumstyles.css" rel="stylesheet" type="text/css" />';
/*
-----------------------------------------------------------
Actions
-----------------------------------------------------------
*/
// Change visibility of a forum or a forum category
if (($_GET['action']=='invisible' OR $_GET['action']=='visible') AND isset($_GET['content']) AND isset($_GET['id']) AND api_is_allowed_to_edit())
{
$message=change_visibility($_GET['content'], $_GET['id'],$_GET['action']);// note: this has to be cleaned first
}
if (($_GET['action']=='lock' OR $_GET['action']=='unlock') AND isset($_GET['content']) AND isset($_GET['id']) AND api_is_allowed_to_edit())
{
$message=change_lock_status($_GET['content'], $_GET['id'],$_GET['action']);// note: this has to be cleaned first
}
if ($_GET['action']=='delete' AND isset($_GET['content']) AND isset($_GET['id']) AND api_is_allowed_to_edit())
{
$message=delete_forum_forumcategory_thread($_GET['content'],$_GET['id']); // note: this has to be cleaned first
}
if ($_GET['action']=='move' and isset($_GET['thread']))
{
$message=move_thread_form();
}
/*
-----------------------------------------------------------
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() AND ($current_forum_category['visibility']==0 OR $current_forum['visibility']==0))
{
forum_not_allowed_here();
}
/*
-----------------------------------------------------------
Display the action messages
-----------------------------------------------------------
*/
if (isset($message))
{
Display :: display_confirmation_message($message);
}
/*
-----------------------------------------------------------
Action Links
-----------------------------------------------------------
*/
echo '<span style="float:right;">'.search_link().'</span>';
// The link should appear when
// 1. the course admin is here
// 2. the course member is here and new threads are allowed
// 3. a visitor is here and new threads AND allowed AND anonymous posts are allowed
if (api_is_allowed_to_edit() OR ($current_forum['allow_new_threads']==1 AND isset($_user['user_id'])) OR ($current_forum['allow_new_threads']==1 AND !isset($_user['user_id']) AND $current_forum['allow_anonymous']==1))
{
if ($current_forum['locked'] <> 1 AND $current_forum['locked'] <> 1)
{
echo '<a href="newthread.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).$origin_string.'">'.Display::return_icon('forumthread_new.gif').' '.get_lang('NewTopic').'</a>';
}
else
{
echo get_lang('ForumLocked');
}
}
/*
-----------------------------------------------------------
Display
-----------------------------------------------------------
*/
echo "<table class=\"data_table\" width='100%'>\n";
// the current forum
if($origin != 'learnpath')
{
echo "\t<tr>\n\t\t<th style=\"padding-left:5px;\" align=\"left\" colspan=\"7\">";
echo '<span class="forum_title">'.prepare4display($current_forum['forum_title']).'</span>';
if (!empty ($current_forum['forum_comment']))
{
echo '<br><span class="forum_description">'.prepare4display($current_forum['forum_comment']).'</span>';
}
if (!empty ($current_forum_category['cat_title']))
{
echo '<br /><span class="forum_low_description">'.prepare4display($current_forum_category['cat_title'])."</span><br />";
}
echo "</th>\n";
echo "\t</tr>\n";
}
echo "</th>\n";
echo "\t</tr>\n";
// The column headers (to do: make this sortable)
echo "\t<tr class=\"forum_threadheader\">\n";
echo "\t\t<td></td>\n";
echo "\t\t<td>".get_lang('Title')."</td>\n";
echo "\t\t<td>".get_lang('Replies')."</td>\n";
echo "\t\t<td>".get_lang('Views')."</td>\n";
echo "\t\t<td>".get_lang('Author')."</td>\n";
echo "\t\t<td>".get_lang('LastPost')."</td>\n";
if (api_is_allowed_to_edit())
{
echo "\t\t<td>".get_lang('Actions')."</td>\n";
}
echo "\t</tr>\n";
// getting al the threads
$threads=get_threads($_GET['forum']); // note: this has to be cleaned first
$whatsnew_post_info=$_SESSION['whatsnew_post_info'];
$counter=0;
if(is_array($threads))
{
foreach ($threads as $row)
{
// thread who have no replies yet and the only post is invisible should not be displayed to students.
if (api_is_allowed_to_edit() OR !($row['thread_replies']=='0' AND $row['visible']=='0'))
{
if($counter%2==0)
{
$class="row_odd";
}
else
{
$class="row_even";
}
echo "\t<tr class=\"$class\">\n";
echo "\t\t<td>";
if (is_array($whatsnew_post_info[$_GET['forum']][$row['thread_id']]) and !empty($whatsnew_post_info[$_GET['forum']][$row['thread_id']]))
{
echo icon('../img/forumthread.gif');
}
else
{
echo icon('../img/forumthread.gif');
}
if ($row['thread_sticky']==1)
{
echo icon('../img/exclamation.gif');
}
echo "</td>\n";
echo "\t\t<td>";
echo "<a href=\"viewthread.php?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".$row['thread_id'].$origin_string."&amp;search=".Security::remove_XSS(urlencode($_GET['search']))."\" ".class_visible_invisible($row['visibility']).">".prepare4display($row['thread_title'])."</a></td>\n";
echo "\t\t<td>".$row['thread_replies']."</td>\n";
if ($row['user_id']=='0')
{
$name=prepare4display($row['thread_poster_name']);
}
else
{
$name=$row['firstname'].' '.$row['lastname'];
}
echo "\t\t<td>".$row['thread_views']."</td>\n";
if ($row['last_poster_user_id']=='0')
{
$name=$row['poster_name'];
}
else
{
$name=$row['last_poster_firstname'].' '.$row['last_poster_lastname'];
}
if($origin != 'learnpath')
{
echo "\t\t<td>".display_user_link($row['user_id'], $name)."</td>\n";
}
else
{
echo "\t\t<td>".$name."</td>\n";
}
// if the last post is invisible and it is not the teacher who is looking then we have to find the last visible post of the thread
if (($row['visible']=='1' OR api_is_allowed_to_edit()) && $origin!='learnpath')
{
$last_post=$row['thread_date']." ".get_lang('By').' '.display_user_link($row['last_poster_user_id'], $name);
}
else if($origin!='learnpath')
{
$last_post_sql="SELECT post.*, user.firstname, user.lastname FROM $table_posts post, $table_users user WHERE post.poster_id=user.user_id AND visible='1' AND thread_id='".$row['thread_id']."' ORDER BY post_id DESC";
$last_post_result=api_sql_query($last_post_sql, __LINE__, __FILE__);
$last_post_row=mysql_fetch_array($last_post_result);
$name=$last_post_row['firstname'].' '.$last_post_row['lastname'];
$last_post=$last_post_row['post_date']." ".get_lang('By').' '.display_user_link($last_post_row['poster_id'], $name);
}
else
{
$last_post_sql="SELECT post.*, user.firstname, user.lastname FROM $table_posts post, $table_users user WHERE post.poster_id=user.user_id AND visible='1' AND thread_id='".$row['thread_id']."' ORDER BY post_id DESC";
$last_post_result=api_sql_query($last_post_sql, __LINE__, __FILE__);
$last_post_row=mysql_fetch_array($last_post_result);
$name=$last_post_row['firstname'].' '.$last_post_row['lastname'];
$last_post=$last_post_row['post_date']." ".get_lang('By').' '.$name;
}
echo "\t\t<td>".$last_post."</td>\n";
if (api_is_allowed_to_edit())
{
echo "\t\t<td>";
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&amp;action=delete&amp;content=thread&amp;id=".$row['thread_id'].$origin_string."\" onclick=\"javascript:if(!confirm('".addslashes(htmlentities(get_lang("DeleteCompleteThread"),ENT_QUOTES,$charset))."')) return false;\">".icon('../img/delete.gif',get_lang('Delete'))."</a>";
display_visible_invisible_icon('thread', $row['thread_id'], $row['visibility'], array("forum"=>$_GET['forum'],'origin'=>$origin));
display_lock_unlock_icon('thread',$row['thread_id'], $row['locked'], array("forum"=>$_GET['forum'],'origin'=>$origin));
echo "<a href=\"viewforum.php?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&amp;action=move&amp;thread=".$row['thread_id'].$origin_string."\">".icon('../img/deplacer_fichier.gif',get_lang('MoveThread'))."</a>";
echo "</td>\n";
}
echo "\t</tr>\n";
}
$counter++;
}
}
echo "</table>";
/*
==============================================================================
FOOTER
==============================================================================
*/
if($origin != 'learnpath')
{
Display :: display_footer();
}
?>

@ -1,189 +1,186 @@
<?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
Mail: info@dokeos.com
==============================================================================
*/
/**
* 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
* are added:
* - 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
* - sticky messages
* - new view option: nested view
* - quoting a message
*
* @Author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @Copyright Ghent University
* @Copyright Patrick Cool
*
* @package dokeos.forum
*/
/**
**************************************************************************
* IMPORTANT NOTICE
* Please do not change anything is this code yet because there are still
* some significant code that need to happen and I do not have the time to
* merge files and test it all over again. So for the moment, please do not
* touch the code
* -- Patrick Cool <patrick.cool@UGent.be>
**************************************************************************
*/
$rows=get_posts($current_thread['thread_id']);
foreach ($rows as $row)
{
echo "<table width=\"100%\" class=\"post\" cellspacing=\"5\" border=\"0\">\n";
// the style depends on the status of the message: approved or not
if ($row['visible']=='0')
{
$titleclass='forum_message_post_title_2_be_approved';
$messageclass='forum_message_post_text_2_be_approved';
$leftclass='forum_message_left_2_be_approved';
}
else
{
$titleclass='forum_message_post_title';
$messageclass='forum_message_post_text';
$leftclass='forum_message_left';
}
echo "\t<tr>\n";
echo "\t\t<td rowspan=\"3\" class=\"$leftclass\">";
if ($row['user_id']=='0')
{
$name=prepare4display($row['poster_name']);
}
else
{
$name=$row['firstname'].' '.$row['lastname'];
<?php
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2008 Dokeos SPRL
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, rue du Corbeau, 108, B-1030 Brussels, Belgium
Mail: info@dokeos.com
==============================================================================
*/
/**
* 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
* are added:
* - 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
* - sticky messages
* - new view option: nested view
* - quoting a message
*
* @Author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @Copyright Ghent University
* @Copyright Patrick Cool
*
* @package dokeos.forum
*/
/**
**************************************************************************
* IMPORTANT NOTICE
* Please do not change anything is this code yet because there are still
* some significant code that need to happen and I do not have the time to
* merge files and test it all over again. So for the moment, please do not
* touch the code
* -- Patrick Cool <patrick.cool@UGent.be>
**************************************************************************
*/
$rows=get_posts($current_thread['thread_id']);
foreach ($rows as $row)
{
echo "<table width=\"100%\" class=\"post\" cellspacing=\"5\" border=\"0\">\n";
// the style depends on the status of the message: approved or not
if ($row['visible']=='0')
{
$titleclass='forum_message_post_title_2_be_approved';
$messageclass='forum_message_post_text_2_be_approved';
$leftclass='forum_message_left_2_be_approved';
}
else
{
$titleclass='forum_message_post_title';
$messageclass='forum_message_post_text';
$leftclass='forum_message_left';
}
echo "\t<tr>\n";
echo "\t\t<td rowspan=\"3\" class=\"$leftclass\">";
if ($row['user_id']=='0')
{
$name=prepare4display($row['poster_name']);
}
else
{
$name=$row['firstname'].' '.$row['lastname'];
}
if($origin!='learnpath')
{
if (api_get_course_setting('allow_user_image_forum')) {
echo '<br />'.display_user_image($row['user_id'],$name).'<br />';
}
{
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).'<br />';
}
else
{
echo $name. '<br />';
}
echo $row['post_date'].'<br /><br />';
// 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 (($current_forum['allow_edit']==1 AND $row['user_id']==$_user['user_id']) or api_is_allowed_to_edit())
{
echo "<a href=\"editpost.php?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".Security::remove_XSS($_GET['thread'])."&amp;post=".$row['post_id']."&origin=".$origin."\">".icon('../img/edit.gif',get_lang('Edit'))."</a>\n";
}
if (api_is_allowed_to_edit())
{
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".Security::remove_XSS($_GET['thread'])."&amp;action=delete&amp;content=post&amp;id=".$row['post_id']."&origin=".$origin."\" onclick=\"javascript:if(!confirm('".addslashes(htmlentities(get_lang("DeletePost"),ENT_QUOTES,$charset))."')) return false;\">".icon('../img/delete.gif',get_lang('Delete'))."</a>\n";
display_visible_invisible_icon('post', $row['post_id'], $row['visible'],array('forum'=>Security::remove_XSS($_GET['forum']),'thread'=>Security::remove_XSS($_GET['thread']), 'origin'=>$origin ));
echo "\n";
echo "<a href=\"viewthread.php?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".Security::remove_XSS($_GET['thread'])."&amp;action=move&amp;post=".$row['post_id']."&origin=".$origin."\">".icon('../img/deplacer_fichier.gif',get_lang('MovePost'))."</a>";
}
echo '<br /><br />';
//if (($current_forum_category['locked']==0 AND $current_forum['locked']==0 AND $current_thread['locked']==0) OR api_is_allowed_to_edit())
if ($current_forum_category['locked']==0 AND $current_forum['locked']==0 AND $current_thread['locked']==0 OR api_is_allowed_to_edit())
{
if ($_user['user_id'] OR ($current_forum['allow_anonymous']==1 AND !$_user['user_id']))
{
echo '<a href="reply.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&amp;thread='.Security::remove_XSS($_GET['thread']).'&amp;post='.$row['post_id'].'&amp;action=replymessage&origin='.$origin.'">'.get_lang('ReplyToMessage').'</a><br />';
echo '<a href="reply.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&amp;thread='.Security::remove_XSS($_GET['thread']).'&amp;post='.$row['post_id'].'&amp;action=quote&origin='.$origin.'">'.get_lang('QuoteMessage').'</a><br /><br />';
}
}
else
{
if ($current_forum_category['locked']==1)
{
echo get_lang('ForumcategoryLocked').'<br />';
}
if ($current_forum['locked']==1)
{
echo get_lang('ForumLocked').'<br />';
}
if ($current_thread['locked']==1)
{
echo get_lang('ThreadLocked').'<br />';
}
}
echo "</td>\n";
// show the
if (isset($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$row['post_id']]) and !empty($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$row['post_id']]) and !empty($whatsnew_post_info[$_GET['forum']][$row['thread_id']]))
{
$post_image=icon('../img/forumpostnew.gif');
}
else
{
$post_image=icon('../img/forumpost.gif');
}
if ($row['post_notification']=='1' AND $row['poster_id']==$_user['user_id'])
{
$post_image.=icon('../img/forumnotification.gif',get_lang('YouWillBeNotified'));
}
// The post title
echo "\t\t<td class=\"$titleclass\">".prepare4display($row['post_title'])."</td>\n";
echo "\t</tr>\n";
// The post message
echo "\t<tr>\n";
echo "\t\t<td class=\"$messageclass\">".prepare4display($row['post_text'])."</td>\n";
echo "\t</tr>\n";
// The added resources
/*
echo "<tr><td>";
if (check_added_resources("forum_post", $row["post_id"]))
{
echo "<i>".get_lang("AddedResources")."</i><br/>";
if ($row['visible']=='0')
{
$addedresource_style="invisible";
}
display_added_resources("forum_post", $row["post_id"], $addedresource_style);
}
echo "</td></tr>";
*/
// The post has been displayed => it can be removed from the what's new array
unset($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$row['post_id']]);
unset($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']]);
unset($_SESSION['whatsnew_post_info'][$current_forum['forum_id']][$current_thread['thread_id']][$row['post_id']]);
unset($_SESSION['whatsnew_post_info'][$current_forum['forum_id']][$current_thread['thread_id']]);
echo "</table>";
}
?>
}
echo $row['post_date'].'<br /><br />';
// 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 (($current_forum['allow_edit']==1 AND $row['user_id']==$_user['user_id']) or api_is_allowed_to_edit())
{
echo "<a href=\"editpost.php?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".Security::remove_XSS($_GET['thread'])."&amp;post=".$row['post_id']."&origin=".$origin."\">".icon('../img/edit.gif',get_lang('Edit'))."</a>\n";
}
if (api_is_allowed_to_edit())
{
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".Security::remove_XSS($_GET['thread'])."&amp;action=delete&amp;content=post&amp;id=".$row['post_id']."&origin=".$origin."\" onclick=\"javascript:if(!confirm('".addslashes(htmlentities(get_lang("DeletePost"),ENT_QUOTES,$charset))."')) return false;\">".icon('../img/delete.gif',get_lang('Delete'))."</a>\n";
display_visible_invisible_icon('post', $row['post_id'], $row['visible'],array('forum'=>Security::remove_XSS($_GET['forum']),'thread'=>Security::remove_XSS($_GET['thread']), 'origin'=>$origin ));
echo "\n";
echo "<a href=\"viewthread.php?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".Security::remove_XSS($_GET['thread'])."&amp;action=move&amp;post=".$row['post_id']."&origin=".$origin."\">".icon('../img/deplacer_fichier.gif',get_lang('MovePost'))."</a>";
}
echo '<br /><br />';
//if (($current_forum_category['locked']==0 AND $current_forum['locked']==0 AND $current_thread['locked']==0) OR api_is_allowed_to_edit())
if ($current_forum_category['locked']==0 AND $current_forum['locked']==0 AND $current_thread['locked']==0 OR api_is_allowed_to_edit())
{
if ($_user['user_id'] OR ($current_forum['allow_anonymous']==1 AND !$_user['user_id']))
{
echo '<a href="reply.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&amp;thread='.Security::remove_XSS($_GET['thread']).'&amp;post='.$row['post_id'].'&amp;action=replymessage&origin='.$origin.'">'.get_lang('ReplyToMessage').'</a><br />';
echo '<a href="reply.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&amp;thread='.Security::remove_XSS($_GET['thread']).'&amp;post='.$row['post_id'].'&amp;action=quote&origin='.$origin.'">'.get_lang('QuoteMessage').'</a><br /><br />';
}
}
else
{
if ($current_forum_category['locked']==1)
{
echo get_lang('ForumcategoryLocked').'<br />';
}
if ($current_forum['locked']==1)
{
echo get_lang('ForumLocked').'<br />';
}
if ($current_thread['locked']==1)
{
echo get_lang('ThreadLocked').'<br />';
}
}
echo "</td>\n";
// show the
if (isset($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$row['post_id']]) and !empty($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$row['post_id']]) and !empty($whatsnew_post_info[$_GET['forum']][$row['thread_id']]))
{
$post_image=icon('../img/forumpostnew.gif');
}
else
{
$post_image=icon('../img/forumpost.gif');
}
if ($row['post_notification']=='1' AND $row['poster_id']==$_user['user_id'])
{
$post_image.=icon('../img/forumnotification.gif',get_lang('YouWillBeNotified'));
}
// The post title
echo "\t\t<td class=\"$titleclass\">".prepare4display($row['post_title'])."</td>\n";
echo "\t</tr>\n";
// The post message
echo "\t<tr>\n";
echo "\t\t<td class=\"$messageclass\">".prepare4display($row['post_text'])."</td>\n";
echo "\t</tr>\n";
// The check if there is an attachment
$attachment_list=get_attachment($row['post_id']);
if (!empty($attachment_list))
{
echo '<tr><td height="50%">';
$realname=$attachment_list['path'];
$user_filename=$attachment_list['filename'];
echo Display::return_icon('attachment.gif',get_lang('attachment'));
echo '<a href="download.php?file=';
echo $realname;
echo ' "> '.$user_filename.' </a>';
echo '<span class="forum_attach_comment" >'.$attachment_list['comment'].'</span><br />';
echo '</td></tr>';
}
// The post has been displayed => it can be removed from the what's new array
unset($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$row['post_id']]);
unset($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']]);
unset($_SESSION['whatsnew_post_info'][$current_forum['forum_id']][$current_thread['thread_id']][$row['post_id']]);
unset($_SESSION['whatsnew_post_info'][$current_forum['forum_id']][$current_thread['thread_id']]);
echo "</table>";
}
?>

@ -57,9 +57,6 @@
$rows=get_posts($_GET['thread']); // note: this has to be cleaned first
$rows=calculate_children($rows);
foreach ($rows as $post)
{
// the style depends on the status of the message: approved or not
@ -153,6 +150,26 @@ foreach ($rows as $post)
echo "\t\t<td class=\"$messageclass\">".prepare4display($post['post_text'])."</td>\n";
echo "\t</tr>\n";
// The check if there is an attachment
$attachment_list=get_attachment($post['post_id']);
if (!empty($attachment_list))
{
echo '<tr><td height="50%">';
$realname=$attachment_list['path'];
$user_filename=$attachment_list['filename'];
echo Display::return_icon('attachment.gif',get_lang('attachment'));
echo '<a href="download.php?file=';
echo $realname;
echo ' "> '.$user_filename.' </a>';
echo '<span class="forum_attach_comment" >'.$attachment_list['comment'].'</span><br />';
echo '</td></tr>';
}
/*
// The added resources
echo "<tr><td>";

@ -281,6 +281,25 @@ echo "\t<tr>\n";
echo "\t\t<td class=\"$messageclass\">".prepare4display($rows[$display_post_id]['post_text'])."</td>\n";
echo "\t</tr>\n";
// The check if there is an attachment
$attachment_list=get_attachment($display_post_id);
if (!empty($attachment_list))
{
echo '<tr><td height="50%">';
$realname=$attachment_list['path'];
$user_filename=$attachment_list['filename'];
echo Display::return_icon('attachment.gif',get_lang('attachment'));
echo '<a href="download.php?file=';
echo $realname;
echo ' "> '.$user_filename.' </a>';
echo '<span class="forum_attach_comment" >'.$attachment_list['comment'].'</span><br />';
echo '</td></tr>';
}
// The post has been displayed => it can be removed from the what's new array
unset($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$row['post_id']]);
unset($_SESSION['whatsnew_post_info'][$current_forum['forum_id']][$current_thread['thread_id']][$row['post_id']]);

@ -3,7 +3,7 @@
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2005 Dokeos S.A.
Copyright (c) 2004-2008 Dokeos SPRL
Copyright (c) various contributors
For a full list of contributors, see "credits.txt".
@ -16,8 +16,8 @@
See the GNU General Public License for more details.
Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
Mail: info@dokeos.com
Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
info@dokeos.com
==============================================================================
*/
/**
@ -304,6 +304,7 @@ function update_Db_course($courseDbName)
$TABLETOOLFORUMTHREAD = $courseDbName . "forum_thread";
$TABLETOOLFORUMPOST = $courseDbName . "forum_post";
$TABLETOOLFORUMMAILCUE = $courseDbName . "forum_mailcue";
$TABLETOOLFORUMATTACHMENT = $courseDbName . "forum_attachment";
// Link
$TABLETOOLLINK = $courseDbName . "link";
@ -350,6 +351,7 @@ function update_Db_course($courseDbName)
$tbl_blogs_rel_user = $courseDbName . 'blog_rel_user';
$tbl_blogs_tasks = $courseDbName . 'blog_task';
$tbl_blogs_tasks_rel_user = $courseDbName . 'blog_task_rel_user';
$tbl_blogs_attachment = $courseDbName . 'blog_attachment';
//Smartblogs permissions (Kevin Van Den Haute :: kevin@develop-it.be)
$tbl_permission_group = $courseDbName . 'permission_group';
@ -535,7 +537,19 @@ function update_Db_course($courseDbName)
) TYPE=MyISAM";
api_sql_query($sql, __FILE__, __LINE__);
// Forum Attachment
$sql = "CREATE TABLE `".$TABLETOOLFORUMATTACHMENT."` (
id int NOT NULL auto_increment,
path varchar(255) NOT NULL,
comment text,
size int NOT NULL default 0,
post_id int NOT NULL,
filename varchar(255) NOT NULL,
PRIMARY KEY (id)
)";
api_sql_query($sql, __FILE__, __LINE__);
/*
-----------------------------------------------------------
@ -1155,6 +1169,26 @@ function update_Db_course($courseDbName)
{
error_log($sql, 0);
}
$sql ="CREATE TABLE `" .$tbl_blogs_attachment."` (
id int unsigned NOT NULL auto_increment,
path varchar(255) NOT NULL COMMENT 'the real filename',
comment text,
size int NOT NULL default '0',
post_id int NOT NULL,
filename varchar(255) NOT NULL COMMENT 'the user s file name',
blog_id int NOT NULL,
comment_id int NOT NULL default '0',
PRIMARY KEY (id)
)";
if(!api_sql_query($sql))
{
error_log($sql, 0);
}
$sql = "
CREATE TABLE `" . $tbl_permission_group . "` (

File diff suppressed because it is too large Load Diff

@ -1,4 +1,4 @@
<?php // $Id: database.lib.php 14674 2008-03-20 12:24:34Z yannoo $
<?php // $Id: database.lib.php 14793 2008-04-08 22:03:04Z juliomontoya $
/* See license terms in /dokeos_license.txt */
/**
==============================================================================
@ -91,6 +91,7 @@ define('TABLE_FORUM_CATEGORY','forum_category');
define('TABLE_FORUM','forum_forum');
define('TABLE_FORUM_THREAD','forum_thread');
define('TABLE_FORUM_POST','forum_post');
define('TABLE_FORUM_ATTACHMENT','forum_attachment');
//course group tables
define('TABLE_GROUP', 'group_info');
define('TABLE_GROUP_USER', 'group_rel_user');
@ -138,6 +139,7 @@ define('TABLE_BLOGS_REL_USER', 'blog_rel_user');
define('TABLE_BLOGS_TASKS', 'blog_task');
define('TABLE_BLOGS_TASKS_REL_USER', 'blog_task_rel_user');
define('TABLE_BLOGS_RATING', 'blog_rating');
define('TABLE_BLOGS_ATTACHMENT', 'blog_attachment');
define('TABLE_BLOGS_TASKS_PERMISSIONS', 'permission_task');
//end of Smartblogs
// user information tables

@ -112,3 +112,6 @@ ALTER TABLE forum_thread ADD INDEX idx_forum_thread_forum_id (forum_id);
ALTER TABLE student_publication ADD COLUMN filetype SET('file','folder') NOT NULL DEFAULT 'file' AFTER sent_date;
ALTER TABLE document ADD readonly TINYINT UNSIGNED NOT NULL ;
ALTER TABLE quiz ADD results_disabled TINYINT UNSIGNED NOT NULL DEFAULT 0;
CREATE TABLE blog_attachment ( id int unsigned NOT NULL auto_increment, path varchar(255) NOT NULL COMMENT 'the real filename', comment text, size int NOT NULL default '0', post_id int NOT NULL, filename varchar(255) NOT NULL COMMENT 'the user s file name', blog_id int NOT NULL, comment_id int NOT NULL default '0', PRIMARY KEY (id));
CREATE TABLE forum_attachment (id int NOT NULL auto_increment, path varchar(255) NOT NULL, comment text, size int NOT NULL default 0, post_id int NOT NULL, filename varchar(255) NOT NULL, PRIMARY KEY (id));

Loading…
Cancel
Save