Browse Source

[svn r16696] Implemented gradebook integration (ranking by user by thread) from development for USIL (private task FS#3176)
Code refactoring - Improve PEAR coding conventions matching (brackets and spacing)
Needs testing.
Initial work by cfasanando, iflores, jhinojosa, integration by cfasanando, ywarnier

Yannick Warnier 16 năm trước cách đây
mục cha
commit
c0b6274e38

+ 22 - 12
main/forum/editpost.php

@@ -63,7 +63,11 @@ $language_file = 'forum';
 
 // including the global dokeos file
 require ('../inc/global.inc.php');
-
+require_once('../gradebook/lib/gradebook_functions.inc.php');
+require_once('../gradebook/lib/be/gradebookitem.class.php');
+require_once('../gradebook/lib/be/evaluation.class.php');
+require_once('../gradebook/lib/be/abstractlink.class.php');
+require_once('../gradebook/lib/gradebook_functions.inc.php');
 // the section (tabs)
 $this_section=SECTION_COURSES;
 // notice for unauthorized people.
@@ -77,14 +81,11 @@ $fck_attribute['ToolbarSet'] = 'Middle';
 $fck_attribute['Config']['IMUploadPath'] = 'upload/forum/';
 $fck_attribute['Config']['FlashUploadPath'] = 'upload/forum/';
 
-$fck_attribute['Config']['InDocument'] = false;		
-$fck_attribute['Config']['CreateDocumentDir'] = '../../courses/'.api_get_course_path().'/document/';
-
 // 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');
 
-if(!api_is_allowed_to_edit(false,true))
+if(!api_is_allowed_to_edit())
 {
 	$fck_attribute['Config']['UserStatus'] = 'student';
 }
@@ -161,32 +162,29 @@ api_display_tool_title($nameTools);
 // The only exception is the course manager
 // I have split this is several pieces for clarity.
 //if (!api_is_allowed_to_edit() AND (($current_forum_category['visibility']==0 OR $current_forum['visibility']==0) OR ($current_forum_category['locked']<>0 OR $current_forum['locked']<>0 OR $current_thread['locked']<>0)))
-if (!api_is_allowed_to_edit(false,true) AND (($current_forum_category['visibility']==0 OR $current_forum['visibility']==0)))
+if (!api_is_allowed_to_edit() AND (($current_forum_category['visibility']==0 OR $current_forum['visibility']==0)))
 {
 	forum_not_allowed_here();
 }
-if (!api_is_allowed_to_edit(false,true) AND ($current_forum_category['locked']<>0 OR $current_forum['locked']<>0 OR $current_thread['locked']<>0))
+if (!api_is_allowed_to_edit() AND ($current_forum_category['locked']<>0 OR $current_forum['locked']<>0 OR $current_thread['locked']<>0))
 {
 	forum_not_allowed_here();
 }
 if (!$_user['user_id'] AND $current_forum['allow_anonymous']==0)
 {
-	forum_not_allowed_here(false,true);
+	forum_not_allowed_here();
 }
-if (!api_is_allowed_to_edit(false,true) AND $current_forum['allow_edit']==0)
+if (!api_is_allowed_to_edit() AND $current_forum['allow_edit']==0)
 {
 	forum_not_allowed_here();
 }
 
-
 /*
 -----------------------------------------------------------
 	Display Forum Category and the Forum information
 -----------------------------------------------------------
 */
 echo "<table class=\"data_table\" width='100%'>\n";
-
-
 // the forum category
 echo "\t<tr>\n\t\t<th style=\"padding-left:5px;\" align=\"left\" colspan=\"2\">";
 echo '<a href="viewforum.php?forum='.$current_forum['forum_id'].'" '.class_visible_invisible($current_forum['visibility']).'>'.prepare4display($current_forum['forum_title']).'</a><br />';
@@ -200,6 +198,18 @@ $values=show_edit_post_form($current_post, $current_thread, $current_forum, $_SE
 if (!empty($values) and $_POST['SubmitPost'])
 {
 	store_edit_post($values);
+	//add gradebook function
+	$option_chek=$values['thread_qualify_gradebook'];// values 1 or 0
+	//var_dump($values);
+		if($option_chek==1){
+		$id=$values['thread_id'];// last id from 
+		$title_gradebook=$values['calification_notebook_title'];
+		$value_calification=$values['numeric_calification'];
+		$description="";
+		//add_resource_to_course_gradebook(api_get_course_id(), 5, $id, $title, 0, $_POST['qualification_value'], Database::escape_string($_POST['description']), "'".date('Y-m-d H:i:s')."'", 1);
+		add_resource_to_course_gradebook(api_get_course_id(), 5, $id, $title_gradebook, 0,$value_calification,$description, "'".date('Y-m-d H:i:s')."'",api_get_session_id());
+	}
+	
 }
 
 /*

+ 42 - 0
main/forum/forumbody.inc.php

@@ -0,0 +1,42 @@
+<?php
+
+$current_thread=get_thread_information($_GET['thread']);
+$my_cid_req = Security::remove_XSS($_GET['cidReq']);
+$my_forum = Security::remove_XSS($_GET['forum']);
+$my_thread = Security::remove_XSS($_GET['thread']);
+$my_user_id = Security::remove_XSS($_GET['user_id']);
+$my_idtextqualify = Security::remove_XSS($_REQUEST['idtextqualify']);
+$output = <<<FIN
+<div class="forum-body-form">
+ 	<table>
+ 		<form id="forum-thread-qualify" name="forum-thread-qualify" action="forumqualify.php"> 		
+ 		<input type="hidden" name="cidReq" value="{$my_cid_req}">
+ 		<input type="hidden" name="forum" value="{$my_forum}">
+ 		<input type="hidden" name="thread" value="{$my_thread}">
+ 		<input type="hidden" name="user_id" value="{$my_user_id}">
+    	<tr>
+FIN;
+$output .= '
+			<td width="10%">'.get_lang('User').'&nbsp;:</td >
+        	<td width="90%"><div align="left">'.get_name_user_by_id($userid).'</div></td>
+        </tr>
+        <tr>
+    		<td width="10%">'.get_lang('Thread').'&nbsp;:</td >
+            <td  width="90%">
+                <div align="left">'.$current_thread['thread_title'].'</div>
+            </td>
+        </tr>
+        <tr>
+            <td width="10%"><div align="left">'.get_lang('Qualification').'&nbsp;:</div></td >
+            <td  width="90%"><div align="left">
+            	<input type="text" maxlength="4" id="idtextqualify" style="width:40px;" name="idtextqualify" value="'.$my_idtextqualify.'"/>&nbsp;&nbsp;'.get_lang('MaxScore').'&nbsp;: '.$max_qualify.'</div>
+            </td>
+        </tr>
+    	<tr>
+            <td width="10%"></td>
+            <td width="90%"><div align="left"><input type="button" id="idbutton_qualify" name="idbutton_qualify"  value="'.get_lang('QualifyThisThread').'" onclick="javascript:if(document.getElementById(\'idtextqualify\').value>=0){if(confirm(\''.get_lang('ConfirmUserQualification').'\')){document.getElementById(\'forum-thread-qualify\').submit();}else{return false;};}else{alert(\''.get_lang('InsertQualificationCorrespondingToMaxScore').'\')};" /></div></td>
+        </tr>
+        </form>
+    </table>
+</div>';
+echo $output;

+ 13 - 10
main/forum/forumconfig.inc.php

@@ -14,11 +14,13 @@
 	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_categories 		= Database :: get_course_table(TABLE_FORUM_CATEGORY);
+$table_forums 			= Database :: get_course_table(TABLE_FORUM);
+$table_threads 			= Database :: get_course_table(TABLE_FORUM_THREAD);
+$table_posts 			= Database :: get_course_table(TABLE_FORUM_POST);
+$table_mailcue			= Database :: get_course_table(TABLE_FORUM_MAIL_QUEUE);
+$table_threads_qualify  = Database :: get_course_table(TABLE_FORUM_THREAD_QUALIFY);
+$table_threads_qualify_historical  = Database :: get_course_table(TABLE_FORUM_THREAD_QUALIFY_LOG);
  
 $forum_table_attachment = Database :: get_course_table(TABLE_FORUM_ATTACHMENT);
 $table_item_property 	= Database :: get_course_table(TABLE_ITEM_PROPERTY);
@@ -29,11 +31,12 @@ $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');
-define("TOOL_FORUM_ATTACH",'forum_attachment');
+define('TOOL_FORUM_CATEGORY','forum_category');
+define('TOOL_FORUM','forum');
+define('TOOL_FORUM_THREAD','forum_thread');
+define('TOOL_FORUM_POST','forum_post');
+define('TOOL_FORUM_ATTACH','forum_attachment');
+define('TOOL_FORUM_THREAD_QUALIFY','forum_thread_qualify');
 /*
 -----------------------------------------------------------
 	Some configuration settings 

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 421 - 144
main/forum/forumfunction.inc.php


+ 119 - 0
main/forum/forumqualify.php

@@ -0,0 +1,119 @@
+<?php
+/*
+==============================================================================
+	Dokeos - elearning and course management software
+
+	Copyright (c) 2008 Dokeos Latinoamerica SAC
+
+	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, 108, ru du Corbeau, B-1030 Brussels, Belgium
+	Mail: info@dokeos.com
+==============================================================================
+*/
+/**
+* 	@package dokeos.forum
+*/
+$language_file=array('admin','user','forum');
+require_once '../inc/global.inc.php';
+require 'forumconfig.inc.php';
+require_once 'forumfunction.inc.php';
+$nameTools = get_lang('Forum');
+$this_section = SECTION_COURSES;
+
+$current_thread=get_thread_information($_GET['thread']); // note: this has to be validated that it is an existing thread
+$current_forum=get_forum_information($current_thread['forum_id']); // note: this has to be validated that it is an existing forum.
+$current_forum_category=get_forumcategory_information($current_forum['forum_category']);
+$whatsnew_post_info=$_SESSION['whatsnew_post_info'];
+$interbreadcrumb[]=array("url" => "index.php?search=".Security::remove_XSS(urlencode($_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 ($message<>'PostDeletedSpecial') {
+	$interbreadcrumb[]=array("url" => "viewthread.php?forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".Security::remove_XSS($_GET['thread']),"name" => prepare4display($current_thread['thread_title']));
+}
+
+Display::display_header();
+		
+$userinf=api_get_user_info(api_get_user_id());
+if ($userinf['status']=='1') {
+	echo "<strong>".get_lang('ThreadQualification')."</strong>";
+	echo "<br />";
+	$current_thread=get_thread_information($_GET['thread']);	
+	$userid=(int)$_GET['user_id'];
+	$threadid=$current_thread['thread_id'];
+	$qualify=(int)$_REQUEST['idtextqualify'];	
+	//return current qualify thread
+	$current_qualify_thread=show_qualify('1',$_GET['cidReq'],$_GET['forum'],$userid,$threadid);
+	
+	//return Max qualify thread
+	$max_qualify=show_qualify('2',$_GET['cidReq'],$_GET['forum'],$userid,$threadid);
+	require_once 'forumbody.inc.php';
+	
+	if(!empty($_REQUEST['idtextqualify'])) {
+		$value_return=store_theme_qualify($userid,$threadid,$qualify,'',date("Y-m-d H:i:s"),'');
+		$url="cidReq=".Security::remove_XSS($_GET['cidReq'])."&forum=".Security::remove_XSS($_GET['forum'])."&thread=".Security::remove_XSS($_GET['thread'])."&post=".Security::remove_XSS($_GET['post'])."&user_id=".Security::remove_XSS($_GET['user_id']);
+		$current_qualify_thread=show_qualify('1',$_GET['cidReq'],$_GET['forum'],$userid,$threadid);
+		//header('location:forumqualify.php?'.$url.'&idtextqualify='.$current_qualify_thread);
+		if($value_return[0]!=$_REQUEST['idtextqualify'] && $value_return[1]=='update')
+		{		
+			store_qualify_historical('1','',$_GET['forum'],$userid,$threadid,$_REQUEST['idtextqualify'],api_get_user_id());
+		}
+	}
+	
+	if(!empty($_REQUEST['idtextqualify']) && $_REQUEST['idtextqualify'] > $max_qualify) { 
+		$return_message = get_lang('QualificationNotBeGreaterThanMaxScore');	
+		Display :: display_error_message($return_message,false);
+	}
+		
+	// show qualifications history
+	$user_id_thread = (int)$_GET['user_id'];
+	$opt=Database::escape_string($_GET['type']);
+	$qualify_historic = get_historical_qualify($user_id_thread, $threadid, $opt);	
+	$counter= count($qualify_historic);	
+	if($counter>0)
+	{
+		echo '<h4>'.get_lang('QualificationChangesHistory').'</h4>';	
+		if($_GET['type'] == 'false') {
+			echo '<div style="float:left; clear:left">'.get_lang('OrderBy').'&nbsp;:<a href="forumqualify.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&thread='.$threadid.'&user_id='.Security::remove_XSS($_GET['user_id']).'&type=true">'.get_lang('MoreRecent').'</a>&nbsp;|
+					'.get_lang('Older').'
+				  </div>';
+		} else {
+			echo '<div style="float:left; clear:left">'.get_lang('OrderBy').'&nbsp;:'.get_lang('MoreRecent').' |
+					<a href="forumqualify.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&thread='.$threadid.'&user_id='.Security::remove_XSS($_GET['user_id']).'&type=false">'.get_lang('Older').'</a>&nbsp;
+				  </div>';
+		}				
+		$table_list.= '<br /><br /><table class="data_table" style="width:50%">';	
+		$table_list.= '<tr>';
+		$table_list.= '<th>'.get_lang('WhoChanged').'</th>';
+		$table_list.= '<th>'.get_lang('NoteChanged').'</th>';				
+		$table_list.= '<th>'.get_lang('DateChanged').'</th>';	
+		$table_list.= '</tr>';						
+		foreach ($qualify_historic as $row1) {
+			    $my_user_info=api_get_user_info($row1['qualify_user_id']);
+				$name = $my_user_info['firstName']." ".$my_user_info['lastName'];					
+				$table_list.= '<tr class="$class"><td>'.$name.'</td>';			
+				$table_list.= '<td>'.$row1['qualify'].'</td>';
+				$table_list.= '<td>'.$row1['qualify_time'].'</td></tr>';			
+		}						
+		$table_list.= '</table>';
+		echo $table_list;
+	}
+	else
+	{
+		echo get_lang('NotChanged');
+	}			
+}
+else
+{
+	//return false;
+	api_not_allowed();	
+}
+Display::display_footer();

+ 18 - 40
main/forum/iframe_thread.php

@@ -3,7 +3,7 @@
 ==============================================================================
 	Dokeos - elearning and course management software
 
-	Copyright (c) 2006 Dokeos S.A.
+	Copyright (c) 2006 Dokeos SPRL
 	Copyright (c) 2006 Ghent University (UGent)
 
 	For a full list of contributors, see "credits.txt".
@@ -16,7 +16,7 @@
 
 	See the GNU General Public License for more details.
 
-	Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
+	Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
 	Mail: info@dokeos.com
 ==============================================================================
 */
@@ -58,11 +58,6 @@
 		INIT SECTION
 ==============================================================================
 */
-	include('../inc/global.inc.php');
-	$this_section=SECTION_COURSES;
-	/* ------------	ACCESS RIGHTS ------------ */
-	// notice for unauthorized people.
-	api_protect_course_script(true);
 /*
 -----------------------------------------------------------
 	Language Initialisation
@@ -70,7 +65,12 @@
 */
 // name of the language file that needs to be included
 $language_file = 'forum';
-require ('../inc/global.inc.php');
+$this_section=SECTION_COURSES;
+require_once '../inc/global.inc.php';
+/* ------------	ACCESS RIGHTS ------------ */
+// notice for unauthorized people.
+api_protect_course_script(true);
+
 require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
 include_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php');
 
@@ -79,8 +79,9 @@ $fck_attribute['Height'] = '400';
 $fck_attribute['ToolbarSet'] = 'Middle';
 $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';
-
+if (!api_is_allowed_to_edit(false,true)) {
+	$fck_attribute['Config']['UserStatus'] = 'student';
+}
 
 $nameTools=get_lang('Forum');
 ?>
@@ -104,8 +105,8 @@ $nameTools=get_lang('Forum');
 	Including necessary files
 -----------------------------------------------------------
 */
-include('forumconfig.inc.php');
-include('forumfunction.inc.php');
+require 'forumconfig.inc.php';
+require_once 'forumfunction.inc.php';
 
 
 /*
@@ -132,8 +133,7 @@ $current_forum_category=get_forumcategory_information($current_forum['forum_cate
 */
 // 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['visibility']==0 OR $current_thread['visibility']==0))
-{
+if (!api_is_allowed_to_edit(false,true) AND ($current_forum['visibility']==0 OR $current_thread['visibility']==0)) {
 	forum_not_allowed_here();
 }
 
@@ -145,24 +145,6 @@ if (!api_is_allowed_to_edit(false,true) AND ($current_forum['visibility']==0 OR
 // 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
-/*
-echo "<table width='100%'>\n";
-
-// the forum category
-echo "\t<tr class=\"forum_category\">\n\t\t<td colspan=\"6\">";
-echo '<a href="index.php" '.class_visible_invisible($current_forum_category['visibility']).'>'.$current_forum_category['cat_title'].'</a><br />';
-echo '<span>'.$current_forum_category['cat_comment'].'</span>';
-echo "</td>\n";
-echo "\t</tr>\n";
-
-// the forum
-echo "\t<tr class=\"forum_header\">\n";
-echo "\t\t<td colspan=\"6\"><a href=\"viewforum.php?forum=".$current_forum['forum_id']."\" ".class_visible_invisible($current_forum['visibility']).">".$current_forum['forum_title']."</a><br />";
-echo '<span>'.$current_forum['forum_comment'].'</span>';
-echo "</td>\n";
-echo "\t</tr>\n";
-echo "</table>";
-*/
 
 $sql="SELECT * FROM $table_posts posts, $table_users users
 		WHERE posts.thread_id='".$current_thread['thread_id']."'
@@ -171,16 +153,12 @@ $sql="SELECT * FROM $table_posts posts, $table_users users
 $result=api_sql_query($sql, __FILE__, __LINE__);
 
 echo "<table width=\"100%\" cellspacing=\"5\" border=\"0\">\n";
-while ($row=mysql_fetch_array($result))
-{
+while ($row=Database::fetch_array($result)) {
 	echo "\t<tr>\n";
 	echo "\t\t<td rowspan=\"2\" class=\"forum_message_left\">";
-	if ($row['user_id']=='0')
-	{
+	if ($row['user_id']=='0') {
 		$name=$row['poster_name'];
-	}
-	else
-	{
+	} else {
 		$name=$row['firstname'].' '.$row['lastname'];
 	}
 	echo display_user_link($row['user_id'], $name).'<br />';
@@ -198,4 +176,4 @@ echo "</table>";
 
 ?>
 </body>
-</html>
+</html>

+ 67 - 132
main/forum/index.php

@@ -3,7 +3,7 @@
 ==============================================================================
 	Dokeos - elearning and course management software
 
-	Copyright (c) 2006 Dokeos S.A.
+	Copyright (c) 2006 Dokeos SPRL
 	Copyright (c) 2006 Ghent University (UGent)
 
 	For a full list of contributors, see "credits.txt".
@@ -16,7 +16,7 @@
 
 	See the GNU General Public License for more details.
 
-	Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
+	Contact address: Dokeos, 108, rue du Corbeau, B-1030 Brussels, Belgium
 	Mail: info@dokeos.com
 ==============================================================================
 */
@@ -46,8 +46,12 @@
 $language_file = 'forum';
 
 // including the global dokeos file
-require ('../inc/global.inc.php');
-
+require '../inc/global.inc.php';
+$htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/jquery.js" ></script>';
+$htmlHeadXtra[] = '<script language="javascript">
+	$(document).ready(function(){ $(\'.hide-me\').slideUp() });
+	function hidecontent(content){ $(content).slideToggle(\'normal\'); } 
+	</script>';
 // the section (tabs)
 $this_section=SECTION_COURSES;
 
@@ -56,7 +60,7 @@ 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');
+require_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php');
 $nameTools=get_lang('Forum');
 
 /*
@@ -64,8 +68,8 @@ $nameTools=get_lang('Forum');
 	Including necessary files
 -----------------------------------------------------------
 */
-include('forumconfig.inc.php');
-include('forumfunction.inc.php');
+require 'forumconfig.inc.php';
+require_once 'forumfunction.inc.php';
 
 $fck_attribute['Width'] = '100%';
 $fck_attribute['Height'] = '175';
@@ -75,9 +79,10 @@ $fck_attribute['Config']['FlashUploadPath'] = 'upload/forum/';
 $fck_attribute['Config']['InDocument'] = false;		
 $fck_attribute['Config']['CreateDocumentDir'] = '../../courses/'.api_get_course_path().'/document/';
 
-if(!api_is_allowed_to_edit(false,true)) $fck_attribute['Config']['UserStatus'] = 'student';
+if(!api_is_allowed_to_edit(false,true)) {
+	$fck_attribute['Config']['UserStatus'] = 'student';
+}
 
-//error_reporting(E_ALL);
 /*
 ==============================================================================
 		MAIN DISPLAY SECTION
@@ -92,10 +97,10 @@ $interbreadcrumb[]=array("url" => "index.php?search=".Security::remove_XSS($_GET
 
 if ($_GET['action']=='add' ) {
 		
-	switch ($_GET['content']){	
+	switch ($_GET['content']) {
 		case 'forum':	$interbreadcrumb[] = array ("url" => api_get_self().'?'.api_get_cidreq().'&action=add&amp;content=forum', 'name' => get_lang('AddForum')); break;
 		case 'forumcategory':$interbreadcrumb[] = array ("url" => api_get_self().'?'.api_get_cidreq().'&action=add&amp;content=forumcategory', 'name' => get_lang('AddForumCategory'));break;
-		default: break;  
+		default: break;
 	}
 }
  
@@ -112,21 +117,18 @@ Display::display_introduction_section(TOOL_FORUM);
 	ACTIONS
 ------------------------------------------------------------------------------------------------------
 */
-if (api_is_allowed_to_edit(false,true))
-{
+if (api_is_allowed_to_edit(false,true)) {
 	$fck_attribute['ToolbarSet'] = 'ForumLight';
 	handle_forum_and_forumcategories();
 }
 
 // notification
-if ($_GET['action'] == 'notify' AND isset($_GET['content']) AND isset($_GET['id']))
-{
+if ($_GET['action'] == '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 ($_GET['action']!='add' && $_GET['action']!='edit' )
-{
+if ($_GET['action']!='add' && $_GET['action']!='edit' ) {
 	get_whats_new();
 	$whatsnew_post_info = array();
 	$whatsnew_post_info = $_SESSION['whatsnew_post_info'];
@@ -166,10 +168,8 @@ if ($_GET['action']!='add' && $_GET['action']!='edit' )
 	$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)
-		{
+	if(is_array($all_groups)) {
+		foreach ($all_groups as $group) {
 			$all_groups[$group['id']]=$group;
 		}
 	}
@@ -181,11 +181,9 @@ if ($_GET['action']!='add' && $_GET['action']!='edit' )
 	*/
 	//if (api_is_allowed_to_edit() and !$_GET['action'])
 	echo '<span style="float:right;">'.search_link().'</span>';
-	if (api_is_allowed_to_edit(false,true))
-	{
+	if (api_is_allowed_to_edit(false,true)) {
 		echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=add&amp;content=forumcategory"> '.Display::return_icon('forum_category_new.gif').' '.get_lang('AddForumCategory').'</a> ';
-		if (is_array($forum_categories_list))
-		{
+		if (is_array($forum_categories_list)) {
 			echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=add&amp;content=forum"> '.Display::return_icon('forum_new.gif').' '.get_lang('AddForum').'</a>';
 		}
 		//echo ' | <a href="forum_migration.php">'.get_lang('MigrateForum').'</a>';
@@ -198,30 +196,24 @@ if ($_GET['action']!='add' && $_GET['action']!='edit' )
 	*/
 	echo '<table class="data_table" width="100%">'."\n";
 	// Step 3: we display the forum_categories first
-	if(is_array($forum_categories_list))
-	{
-		foreach ($forum_categories_list as $forum_category_key => $forum_category)
-		{
-			if((!isset($_SESSION['id_session']) || $_SESSION['id_session']==0) && !empty($forum_category['session_name']))
-			{
+	if(is_array($forum_categories_list)) {
+		foreach ($forum_categories_list as $forum_category_key => $forum_category) {
+			if((!isset($_SESSION['id_session']) || $_SESSION['id_session']==0) && !empty($forum_category['session_name'])) {
 				$session_displayed = ' ('.$forum_category['session_name'].')';
-			}
-			else
+			} else {
 				$session_displayed = '';
+			}
 			
 			echo "\t<tr>\n\t\t<th style=\"padding-left:5px;\" align=\"left\" colspan=\"6\">";
 			echo '<a href="viewforumcategory.php?'.api_get_cidreq().'&forumcategory='.prepare4display($forum_category['cat_id']).'" '.class_visible_invisible(prepare4display($forum_category['visibility'])).'>'.prepare4display($forum_category['cat_title']).$session_displayed.'</a><br />';
 			
-			if ($forum_category['cat_comment']<>'' AND trim($forum_category['cat_comment'])<>'&nbsp;')
-			{  
+			if ($forum_category['cat_comment']<>'' AND trim($forum_category['cat_comment'])<>'&nbsp;') {  
 				echo '<span class="forum_description">'.prepare4display($forum_category['cat_comment']).'</span>';
 			}			
 			echo "</th>\n";
 			
 			echo '<th style="padding: 5px; vertical-align: top;" align="center" >';
-			if (api_is_allowed_to_edit(false,true) && !($forum_category['session_id']==0 && intval($_SESSION['id_session'])!=0))
-			
-			{
+			if (api_is_allowed_to_edit(false,true) && !($forum_category['session_id']==0 && intval($_SESSION['id_session'])!=0)) {
 				echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=edit&amp;content=forumcategory&amp;id=".prepare4display($forum_category['cat_id'])."\">".icon('../img/edit.gif',get_lang('Edit'))."</a>";
 				echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=delete&amp;content=forumcategory&amp;id=".prepare4display($forum_category['cat_id'])."\" onclick=\"javascript:if(!confirm('".addslashes(htmlentities(get_lang("DeleteForumCategory"),ENT_QUOTES,$charset))."')) return false;\">".icon('../img/delete.gif',get_lang('Delete'))."</a>";
 				display_visible_invisible_icon('forumcategory', prepare4display($forum_category['cat_id']), prepare4display($forum_category['visibility']));
@@ -233,12 +225,11 @@ if ($_GET['action']!='add' && $_GET['action']!='edit' )
 		
 			// step 4: the interim headers (for the forum)
 			echo "\t<tr class=\"forum_header\">\n";
-			
-			echo "\t\t<td colspan='3'>".get_lang('Forum')."</td>\n";
+			echo "\t\t<td colspan=\"3\">".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";
+			echo "\t\t<td>".get_lang('Actions')."</td>\n";
 			echo "\t</tr>\n";
 		
 			// the forums in this category
@@ -247,16 +238,12 @@ if ($_GET['action']!='add' && $_GET['action']!='edit' )
 			// step 5: we display all the forums in this category.
 			$forum_count=0;			
 			
-			foreach ($forum_list as $key=>$forum)
-			{
+			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]))
-						{
+				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]);
 						}
@@ -264,8 +251,7 @@ if ($_GET['action']!='add' && $_GET['action']!='edit' )
 				}
 										
 				// note: this can be speeded up if we transform the $forum_list to an array that uses the forum_category as the key.
-				if (prepare4display($forum['forum_category'])==prepare4display($forum_category['cat_id']))
-				{ 
+				if (prepare4display($forum['forum_category'])==prepare4display($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)
@@ -278,43 +264,30 @@ if ($_GET['action']!='add' && $_GET['action']!='edit' )
 					// SHOULD WE SHOW THIS PARTICULAR FORUM
 					// you are teacher => show forum
 		
-					if (api_is_allowed_to_edit(false,true))
-					{
+					if (api_is_allowed_to_edit(false,true)) {
 						//echo 'teacher';
 						$show_forum=true;
-					}
-					// you are not a teacher
-					else
-					{
+					} 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')
-						{
+						if ($forum['forum_of_group']=='0') {
 							//echo '-gewoon forum';
 							$show_forum=true;
-						}
-						// it is a group forum
-						else
-						{
+						} 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')
-							{
+							if ($forum['forum_group_public_private']=='public') {
 								$show_forum=true;
 								//echo '-publiek';
-							}
-							// it is a group forum and it is private
-							else
-							{
+							} 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))
-								{
+								if (in_array($forum['forum_of_group'],$groups_of_user)) {
 									//echo '-is lid';
 									$show_forum=true;
-								}
-								else
-								{
+								} else {
 									//echo '-is GEEN lid';
 									$show_forum=false;
 								}
@@ -326,11 +299,7 @@ if ($_GET['action']!='add' && $_GET['action']!='edit' )
 					
 					//echo '<hr>';
 		
-		
-				
-					
-					if ($show_forum)
-					{
+					if ($show_forum) {
 						$form_count++;
 						echo "\t<tr class=\"forum\">\n";
 						
@@ -341,92 +310,64 @@ if ($_GET['action']!='add' && $_GET['action']!='edit' )
 					
 					
 						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']]))
-							{
+						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');
-							}
-							else
-							{
+							} else {
 								echo icon('../img/forumgroup.gif');
 							}
-						}
-						else
-						{	
-								
-							if (is_array($whatsnew_post_info[$forum['forum_id']]) and !empty($whatsnew_post_info[$forum['forum_id']]))
-							{
+						} else {
+							if (is_array($whatsnew_post_info[$forum['forum_id']]) and !empty($whatsnew_post_info[$forum['forum_id']])) {
 								echo icon('../img/forum.gif');
-								
-							}
-							else
-							{
+							} else {
 								echo icon('../img/forum.gif');
-								
 							}
-		
 						}
 						echo "</td>\n";
-						if ($forum['forum_of_group']<>'0')
-						{
+						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>)';
-						}
-						else
-						{
+						} else {
 							$forum_title_group_addition='';
 						}
 						
-						if((!isset($_SESSION['id_session']) || $_SESSION['id_session']==0) && !empty($forum['session_name']))
-						{
+						if((!isset($_SESSION['id_session']) || $_SESSION['id_session']==0) && !empty($forum['session_name'])) {
 							$session_displayed = ' ('.$forum['session_name'].')';
-						}
-						else
+						} else {
 							$session_displayed = '';
-							
+						}
 						echo "\t\t<td><a href=\"viewforum.php?".api_get_cidreq()."&forum=".prepare4display($forum['forum_id'])."\" ".class_visible_invisible(prepare4display($forum['visibility'])).">".prepare4display($forum['forum_title']).$session_displayed.'</a>'.$forum_title_group_addition.'<br />'.prepare4display($forum['forum_comment'])."</td>\n";
 						//$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']<>'')
-						{
+						if ($forum['last_poster_name']<>'') {
 							$name=$forum['last_poster_name'];
 							$poster_id=0;
-						}
-						else
-						{
+						} else {
 							$name=$forum['last_poster_firstname'].' '.$forum['last_poster_lastname'];
 							$poster_id=$forum['last_poster_id'];
 						}
 						echo "\t\t<td NOWRAP>";
 						
-						if (!empty($forum['last_post_id']))
-						{
+						if (!empty($forum['last_post_id'])) {
 							echo $forum['last_post_date']."<br /> ".get_lang('By').' '.display_user_link($poster_id, $name);
 						}
 						echo "</td>\n";
 		
 		
 						echo "\t\t<td NOWRAP align='center'>";
-						if (api_is_allowed_to_edit(false,true) && !($forum['session_id']==0 && intval($_SESSION['id_session'])!=0))
-						{
+						if (api_is_allowed_to_edit(false,true) && !($forum['session_id']==0 && intval($_SESSION['id_session'])!=0)) {
 							echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=edit&amp;content=forum&amp;id=".$forum['forum_id']."\">".icon('../img/edit.gif',get_lang('Edit'))."</a>";
 							echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=delete&amp;content=forum&amp;id=".$forum['forum_id']."\" onclick=\"javascript:if(!confirm('".addslashes(htmlentities(get_lang("DeleteForum"),ENT_QUOTES,$charset))."')) return false;\">".icon('../img/delete.gif',get_lang('Delete'))."</a>";
 							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';
-						if (is_array($_SESSION['forum_notification']['forum']))
-						{
-							if (in_array($forum['forum_id'],$_SESSION['forum_notification']['forum']))
-							{
+						if (is_array($_SESSION['forum_notification']['forum'])) {
+							if (in_array($forum['forum_id'],$_SESSION['forum_notification']['forum'])) {
 								$iconnotify = 'send_mail_checked.gif';
 							}
 						}
@@ -437,8 +378,7 @@ if ($_GET['action']!='add' && $_GET['action']!='edit' )
 				}					
 			}
 			
-			if (count($forum_list)==0)
-			{
+			if (count($forum_list)==0) {
 				echo "\t<tr><td>".get_lang('NoForumInThisCategory')."</td>".(api_is_allowed_to_edit(false,true)?'<td colspan="5"></td>':'<td colspan="4"></td>')."</tr>\n";
 			}
 		}
@@ -450,9 +390,4 @@ if ($_GET['action']!='add' && $_GET['action']!='edit' )
 		FOOTER
 ==============================================================================
 */
-
-Display :: display_footer();
-?>
-
-
-
+Display :: display_footer();

+ 23 - 39
main/forum/newthread.php

@@ -3,7 +3,7 @@
 ==============================================================================
 	Dokeos - elearning and course management software
 
-	Copyright (c) 2006-2008 Dokeos S.A.
+	Copyright (c) 2006-2008 Dokeos SPRL
 	Copyright (c) 2006 Ghent University (UGent)
 
 	For a full list of contributors, see "credits.txt".
@@ -16,7 +16,7 @@
 
 	See the GNU General Public License for more details.
 
-	Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
+	Contact address: Dokeos, 108 rue du Corbeau, B-1030 Brussels, Belgium
 	Mail: info@dokeos.com
 ==============================================================================
 */
@@ -46,8 +46,8 @@
 $language_file = array('forum','document');
 
 // including the global dokeos file
-require ('../inc/global.inc.php');
-
+require_once '../inc/global.inc.php';
+require_once '../gradebook/lib/gradebook_functions.inc.php';
 // the section (tabs)
 $this_section=SECTION_COURSES;
 
@@ -70,8 +70,7 @@ $fck_attribute['Config']['InDocument'] = false;
 $fck_attribute['Config']['CreateDocumentDir'] = '../../courses/'.api_get_course_path().'/document/';
 
 		
-if(!api_is_allowed_to_edit(false,true))
-{
+if(!api_is_allowed_to_edit(false,true)) {
 	$fck_attribute['Config']['UserStatus'] = 'student';
 }
 /*
@@ -82,15 +81,12 @@ if(!api_is_allowed_to_edit(false,true))
 include('forumconfig.inc.php');
 include('forumfunction.inc.php');
 
-
 //are we in a lp ?
 $origin = '';
-if(isset($_GET['origin']))
-{
+if(isset($_GET['origin'])) {
 	$origin =  Security::remove_XSS($_GET['origin']);
 }
 
-
 /*
 ==============================================================================
 		MAIN DISPLAY SECTION
@@ -119,8 +115,7 @@ $interbreadcrumb[]=array("url" => "newthread.php?forum=".Security::remove_XSS($_
 	Resource Linker
 -----------------------------------------------------------
 */
-if (isset($_POST['add_resources']) AND $_POST['add_resources']==get_lang('Resources'))
-{
+if (isset($_POST['add_resources']) AND $_POST['add_resources']==get_lang('Resources')) {
 	$_SESSION['formelements']=$_POST;
 	$_SESSION['origin']=$_SERVER['REQUEST_URI'];
 	$_SESSION['breadcrumbs']=$interbreadcrumb;
@@ -132,15 +127,12 @@ if (isset($_POST['add_resources']) AND $_POST['add_resources']==get_lang('Resour
 	Header
 -----------------------------------------------------------
 */
-if($origin=='learnpath')
-{
+if($origin=='learnpath') {
 	include(api_get_path(INCLUDE_PATH).'reduced_header.inc.php');
-} else
-{
+} else {
 	Display :: display_header(null);
 	api_display_tool_title($nameTools);
 }
-//echo '<link href="forumstyles.css" rel="stylesheet" type="text/css" />';
 /*
 -----------------------------------------------------------
 	Is the user allowed here?
@@ -153,23 +145,19 @@ if($origin=='learnpath')
 // 4. anonymous posts are not allowed and the user is not logged in
 // I have split this is several pieces for clarity.
 
-if (!api_is_allowed_to_edit(false,true) AND (($current_forum_category['visibility']==0 OR $current_forum['visibility']==0)))
-{
+if (!api_is_allowed_to_edit(false,true) AND (($current_forum_category['visibility']==0 OR $current_forum['visibility']==0))) {
 	forum_not_allowed_here();
 }
 // 2. the forumcategory or forum is locked (locked <>0) and the user is not a course manager
-if (!api_is_allowed_to_edit(false,true) AND ($current_forum_category['locked']<>0 OR $current_forum['locked']<>0))
-{
+if (!api_is_allowed_to_edit(false,true) AND ($current_forum_category['locked']<>0 OR $current_forum['locked']<>0)) {
 	forum_not_allowed_here();
 }
 // 3. new threads are not allowed and the user is not a course manager
-if (!api_is_allowed_to_edit(false,true) AND $current_forum['allow_new_threads']<>1)
-{
+if (!api_is_allowed_to_edit(false,true) AND $current_forum['allow_new_threads']<>1) {
 	forum_not_allowed_here();
 }
 // 4. anonymous posts are not allowed and the user is not logged in
-if (!$_user['user_id']  AND $current_forum['allow_anonymous']<>1)
-{
+if (!$_user['user_id']  AND $current_forum['allow_anonymous']<>1) {
 	forum_not_allowed_here();
 }
 
@@ -187,29 +175,27 @@ handle_forum_and_forumcategories();
 */
 echo "<table class=\"data_table\" width='100%'>\n";
 
-if($origin != 'learnpath')
-{
+if ($origin != 'learnpath') {
 	echo "\t<tr>\n\t\t<th style=\"padding-left:5px;\" align=\"left\"  colspan=\"2\">";
 	
 	echo '<span class="forum_title">'.prepare4display($current_forum['forum_title']).'</span>';
-		
-	if (!empty ($current_forum['forum_comment'])) 
-	{
+
+	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'])) 
-	{
+
+	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 '</table>';
 
 $values=show_add_post_form('newthread','', $_SESSION['formelements']);
-if (!empty($values) and isset($values['SubmitPost']))
-{
+
+if (!empty($values) and isset($values['SubmitPost'])) {
+	//add new thread in table forum_thread
 	store_thread($values);
 }
 
@@ -218,6 +204,4 @@ if (!empty($values) and isset($values['SubmitPost']))
 		FOOTER
 ==============================================================================
 */
-
-Display :: display_footer();
-?>
+Display :: display_footer();

+ 19 - 43
main/forum/reply.php

@@ -3,7 +3,7 @@
 ==============================================================================
 	Dokeos - elearning and course management software
 
-	Copyright (c) 2006-2008 Dokeos S.A.
+	Copyright (c) 2006-2008 Dokeos SPRL
 	Copyright (c) 2006 Ghent University (UGent)
 
 	For a full list of contributors, see "credits.txt".
@@ -16,7 +16,7 @@
 
 	See the GNU General Public License for more details.
 
-	Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
+	Contact address: Dokeos, 108 rue du Corbeau, B-1030 Brussels, Belgium
 	Mail: info@dokeos.com
 ==============================================================================
 */
@@ -46,7 +46,7 @@
 $language_file = array('forum','document');
 
 // including the global dokeos file
-require ('../inc/global.inc.php');
+require '../inc/global.inc.php';
 
 // the section (tabs)
 $this_section=SECTION_COURSES;
@@ -64,8 +64,7 @@ $fck_attribute['Config']['FlashUploadPath'] = 'upload/forum/';
 $fck_attribute['Config']['InDocument'] = false;		
 $fck_attribute['Config']['CreateDocumentDir'] = '../../courses/'.api_get_course_path().'/document/';
 
-if(!api_is_allowed_to_edit(false,true))
-{
+if(!api_is_allowed_to_edit(false,true)) {
 	$fck_attribute['Config']['UserStatus'] = 'student';
 }
 
@@ -75,8 +74,7 @@ include_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php');
 $nameTools=get_lang('Forum');
 
 $origin = '';
-if(isset($_GET['origin']))
-{
+if(isset($_GET['origin'])) {
 	$origin =  Security::remove_XSS($_GET['origin']);
 	$origin_string = '&origin='.$origin;
 }
@@ -86,8 +84,8 @@ if(isset($_GET['origin']))
 	Including necessary files
 -----------------------------------------------------------
 */
-include('forumconfig.inc.php');
-include('forumfunction.inc.php');
+require 'forumconfig.inc.php';
+require_once 'forumfunction.inc.php';
 
 /*
 ==============================================================================
@@ -122,66 +120,50 @@ $interbreadcrumb[]=array("url" => "reply.php?forum=".Security::remove_XSS($_GET[
 	Resource Linker
 -----------------------------------------------------------
 */
-if (isset($_POST['add_resources']) AND $_POST['add_resources']==get_lang('Resources'))
-{
+if (isset($_POST['add_resources']) AND $_POST['add_resources']==get_lang('Resources')) {
 	$_SESSION['formelements']=$_POST;
 	$_SESSION['origin']=$_SERVER['REQUEST_URI'];
 	$_SESSION['breadcrumbs']=$interbreadcrumb;
 	header("Location: ../resourcelinker/resourcelinker.php");
 }
-
-
-
 /*
 -----------------------------------------------------------
 	Header
 -----------------------------------------------------------
 */
-if($origin=='learnpath')
-{
+if($origin=='learnpath') {
 	include(api_get_path(INCLUDE_PATH).'reduced_header.inc.php');
-}
-else
-{
+} 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" />';
-
 /*
 -----------------------------------------------------------
 	Is the user allowed here?
 -----------------------------------------------------------
 */
-// the user is not allowed here if
+// The user is not allowed here if
 // 1. the forumcategory, forum or thread is invisible (visibility==0
 // 2. the forumcategory, forum or thread is locked (locked <>0)
 // 3. if anonymous posts are not allowed
 // The only exception is the course manager
 // I have split this is several pieces for clarity.
 //if (!api_is_allowed_to_edit() AND (($current_forum_category['visibility']==0 OR $current_forum['visibility']==0) OR ($current_forum_category['locked']<>0 OR $current_forum['locked']<>0 OR $current_thread['locked']<>0)))
-if (!api_is_allowed_to_edit(false,true) AND (($current_forum_category['visibility']==0 OR $current_forum['visibility']==0)))
-{
+if (!api_is_allowed_to_edit(false,true) AND (($current_forum_category['visibility']==0 OR $current_forum['visibility']==0))) {
 	forum_not_allowed_here();
 }
-if (!api_is_allowed_to_edit(false,true) AND ($current_forum_category['locked']<>0 OR $current_forum['locked']<>0 OR $current_thread['locked']<>0))
-{
+if (!api_is_allowed_to_edit(false,true) AND ($current_forum_category['locked']<>0 OR $current_forum['locked']<>0 OR $current_thread['locked']<>0)) {
 	forum_not_allowed_here();
 }
-if (!$_user['user_id'] AND $current_forum['allow_anonymous']==0)
-{
+if (!$_user['user_id'] AND $current_forum['allow_anonymous']==0) {
 	forum_not_allowed_here();
 }
-
-
 /*
 -----------------------------------------------------------
 	Display forms / Feedback Messages
 -----------------------------------------------------------
 */
-//handle_forum_and_forumcategories();
-
 /*
 -----------------------------------------------------------
 	Display Forum Category and the Forum information
@@ -194,8 +176,7 @@ echo "\t<tr>\n\t\t<th style=\"padding-left:5px;\" align=\"left\" colspan=\"2\">"
 
 echo '<span class="forum_title">'.prepare4display($current_thread['thread_title']).'</span><br />';
 
-if (!empty ($current_forum_category['cat_title'])) 
-{
+if (!empty ($current_forum_category['cat_title'])) {
 	echo '<span class="forum_low_description">'.prepare4display($current_forum_category['cat_title'])." - </span>";
 }
 	
@@ -206,8 +187,8 @@ echo '</table>';
 
 // the form for the reply
 $values=show_add_post_form($_GET['action'], $_GET['post'], $_SESSION['formelements']); // note: this has to be cleaned first
-if (!empty($values) AND $_POST['SubmitPost'])
-{
+
+if (!empty($values) AND $_POST['SubmitPost']) {
 	store_reply($values);
 }
 
@@ -216,11 +197,6 @@ if (!empty($values) AND $_POST['SubmitPost'])
 		FOOTER
 ==============================================================================
 */
-if($origin!='learnpath')
-{
+if($origin!='learnpath') {
 	Display :: display_footer();
-}
-?>
-
-
-
+}

+ 130 - 102
main/forum/viewforum.php

@@ -3,7 +3,7 @@
 ==============================================================================
 	Dokeos - elearning and course management software
 
-	Copyright (c) 2006-2008 Dokeos S.A.
+	Copyright (c) 2006-2008 Dokeos SPRL
 	Copyright (c) 2006 Ghent University (UGent)
 
 	For a full list of contributors, see "credits.txt".
@@ -46,7 +46,7 @@
 $language_file = 'forum';
 
 // including the global dokeos file
-require ('../inc/global.inc.php');
+require '../inc/global.inc.php';
 
 // notice for unauthorized people.
 api_protect_course_script(true);
@@ -62,8 +62,7 @@ $nameTools=get_lang('Forum');
 
 //are we in a lp ?
 $origin = '';
-if(isset($_GET['origin']))
-{
+if(isset($_GET['origin'])) {
 	$origin =  Security::remove_XSS($_GET['origin']);
 	$origin_string = '&origin='.$origin;
 }
@@ -73,9 +72,11 @@ if(isset($_GET['origin']))
 	Including necessary files
 -----------------------------------------------------------
 */
-include('forumconfig.inc.php');
-include('forumfunction.inc.php');
+require 'forumconfig.inc.php';
+require_once 'forumfunction.inc.php';
 
+$userid=api_get_user_id();
+$userinf=api_get_user_info($userid);
 
 /*
 ==============================================================================
@@ -105,50 +106,117 @@ $current_forum_category=get_forumcategory_information($current_forum['forum_cate
 $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')
-{
+
+if($origin=='learnpath') {
 	include(api_get_path(INCLUDE_PATH).'reduced_header.inc.php');
-} else
-{
+} 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(false,true))
-{
+if (($_GET['action']=='invisible' OR $_GET['action']=='visible') AND isset($_GET['content']) AND isset($_GET['id']) AND api_is_allowed_to_edit(false,true)) {
 	$message=change_visibility($_GET['content'], $_GET['id'],$_GET['action']);// note: this has to be cleaned first
 }
 // locking and unlocking
-if (($_GET['action']=='lock' OR $_GET['action']=='unlock') AND isset($_GET['content']) AND isset($_GET['id']) AND api_is_allowed_to_edit(false,true))
-{
+if (($_GET['action']=='lock' OR $_GET['action']=='unlock') AND isset($_GET['content']) AND isset($_GET['id']) AND api_is_allowed_to_edit(false,true)) {
 	$message=change_lock_status($_GET['content'], $_GET['id'],$_GET['action']);// note: this has to be cleaned first
 }
 // deleting
-if ($_GET['action']=='delete'  AND isset($_GET['content']) AND isset($_GET['id']) AND api_is_allowed_to_edit(false,true))
-{
+if ($_GET['action']=='delete'  AND isset($_GET['content']) AND isset($_GET['id']) AND api_is_allowed_to_edit(false,true)) {
 	$message=delete_forum_forumcategory_thread($_GET['content'],$_GET['id']); // note: this has to be cleaned first
 }
 // moving
-if ($_GET['action']=='move' and isset($_GET['thread']) AND api_is_allowed_to_edit(false,true))
-{
+if ($_GET['action']=='move' and isset($_GET['thread']) AND api_is_allowed_to_edit(false,true)) {
 	$message=move_thread_form();
 }
 // notification
-if ($_GET['action'] == 'notify' AND isset($_GET['content']) AND isset($_GET['id']))
-{
+if ($_GET['action'] == 'notify' AND isset($_GET['content']) AND isset($_GET['id'])) {
 	$return_message = set_notification($_GET['content'],$_GET['id']);
 	Display :: display_confirmation_message($return_message,false);
 }
 
+// student list 
+
+if ($_GET['action'] == 'liststd' AND isset($_GET['content']) AND isset($_GET['id']) AND $userinf['status']=='1') {
+	
+	switch($_GET['list']) {	
+		case "qualify":
+			$student_list=get_thread_users_qualify($_GET['id']);			
+			$nrorow3 =-2;
+			break;
+		case "notqualify":
+			$student_list=get_thread_users_not_qualify($_GET['id']);				
+			$nrorow3 =-2;				
+			break;
+		default:
+			$student_list=get_thread_users_details($_GET['id']);
+			$nrorow3 = Database::num_rows($student_list);
+			break;			
+	}	
+	$table_list = '<p><br /><h3>'.get_lang('ThreadUsersList').'&nbsp;:'.get_name_thread_by_id($_GET['id']).'</h3>';
+	if ($nrorow3>0 || $nrorow3==-2) {		
+		$url = 'cidReq='.Security::remove_XSS($_GET['cidReq']).'&forum='.Security::remove_XSS($_GET['forum']).'&action='.Security::remove_XSS($_GET['action']).'&content='.Security::remove_XSS($_GET['content']).'&id='.Security::remove_XSS($_GET['id']);
+		$table_list.= '<br />
+				 <div style="width:50%">
+				 <table class="data_table" border="0">
+					<tr>
+						<th height="22"><a href="viewforum.php?'.$url.'&list=all">'.get_lang('AllStudents').'</a></th>
+						<th><a href="viewforum.php?'.$url.'&list=qualify">'.get_lang('StudentsQualified').'</a></th>
+						<th><a href="viewforum.php?'.$url.'&list=notqualify">'.get_lang('StudentsNotQualified').'</a></th>					
+					</tr>
+				 </table></div>
+				 <div style="border:1px solid gray; width:99%; margin-top:5px; padding:4px; float:left">
+				 ';
+				 
+		$icon_qualify = 'blog_new.gif';		
+		$table_list.= '<center><br /><table class="data_table" style="width:50%">';
+		// The column headers (to do: make this sortable)
+		$table_list.= '<tr >';
+		$table_list.= '<th height="24">'.get_lang('NamesAndFirstNames').'</th>';
+	
+		if ($_GET['list']=='qualify') {		
+			$table_list.= '<th>'.get_lang('Qualify').'</th>';
+		}		
+		if ($userinf['status']=='1') {
+			$table_list.= '<th>'.get_lang('Qualify').'</th>';
+		}	
+		$table_list.= '</tr>';
+		$max_qualify=show_qualify('2',$_GET['cidReq'],$_GET['forum'],$userid,$_GET['id']);
+		$counter_stdlist=0;	
+		while ($row_student_list=Database::fetch_array($student_list)) {
+			if ($counter_stdlist%2==0) {
+					 $class_stdlist="row_odd";
+			} else {
+					$class_stdlist="row_even";
+			}
+			$name_user_theme = 	$row_student_list['firstname'].' '.$row_student_list['lastname'];					
+			$table_list.= '<tr class="$class_stdlist"><td><a href="../user/userInfo.php?uInfo='.$row_student_list['user_id'].'&tipo=sdtlist&'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).$origin_string.'">'.$name_user_theme.'</a></td>';
+			if ($_GET['list']=='qualify') {
+				$table_list.= '<td>'.$row_student_list['qualify'].'/'.$max_qualify.'</td>';
+			}
+			if ($userinf['status']=='1') {
+				$current_qualify_thread=show_qualify('1',$_GET['cidReq'],$_GET['forum'],$row_student_list['user_id'],$_GET['id']);					
+				$table_list.= '<td><a href="forumqualify.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&thread='.Security::remove_XSS($_GET['id']).'&user_id='.$row_student_list['user_id'].'&idtextqualify='.$current_qualify_thread.'">'.icon('../img/'.$icon_qualify,get_lang('Qualify')).'</a></td></tr>';
+			}
+			$counter_stdlist++;
+		}	
+							
+		$table_list.= '</table></center>';
+		$table_list .= '<br /></div>';
+	}
+	else 
+	{
+		$table_list .= get_lang('NoParticipation');
+	}
+}
+
 /*
 -----------------------------------------------------------
 	Is the user allowed here?
@@ -156,22 +224,19 @@ if ($_GET['action'] == 'notify' AND isset($_GET['content']) AND isset($_GET['id'
 */
 // 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 OR $current_forum['visibility']==0))
-{
+if (!api_is_allowed_to_edit(false,true) AND ($current_forum_category['visibility']==0 OR $current_forum['visibility']==0)) {
 	forum_not_allowed_here();
 }
 
+
 /*
 -----------------------------------------------------------
 	Display the action messages
 -----------------------------------------------------------
 */
-if (isset($message))
-{
+if (!empty($message)) {
 	Display :: display_confirmation_message($message);
 }
-
-
 /*
 -----------------------------------------------------------
 	Action Links
@@ -182,14 +247,10 @@ echo '<span style="float:right;">'.search_link().'</span>';
 // 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(false,true) 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
-	{
+if (api_is_allowed_to_edit(false,true) 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');
 	}
 }
@@ -202,21 +263,17 @@ if (api_is_allowed_to_edit(false,true) OR ($current_forum['allow_new_threads']==
 echo "<table class=\"data_table\" width='100%'>\n";
 
 // the current forum 
-if($origin != 'learnpath')
-{
+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'])) 
-	{
+	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'])) 
-	{
+	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";
 }
@@ -241,83 +298,58 @@ $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)
-	{
+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(false,true) OR  !($row['thread_replies']=='0' AND $row['visible']=='0'))
-		{
-			if($counter%2==0)
-			{
+		if (api_is_allowed_to_edit(false,true) OR  !($row['thread_replies']=='0' AND $row['visible']=='0')) {
+			if($counter%2==0) {
 				 $class="row_odd";
-			}
-			else
-			{
+			} 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']]))
-			{
+			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
-			{
+			} else {
 				echo icon('../img/forumthread.gif');
 			}
 	
-			if ($row['thread_sticky']==1)
-			{
+			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')
-			{
+			if ($row['user_id']=='0') {
 				$name=prepare4display($row['thread_poster_name']);
-			}
-			else
-			{
+			} else {
 				$name=$row['firstname'].' '.$row['lastname'];
 			}			
 			echo "\t\t<td>".$row['thread_views']."</td>\n";
-			
-			if ($row['last_poster_user_id']=='0')
-			{
+			if ($row['last_poster_user_id']=='0') {
 				$name=$row['poster_name'];  
-			}
-			else
-			{
+			} else {
 				$name=$row['last_poster_firstname'].' '.$row['last_poster_lastname'];
 			}
 			
-			if($origin != 'learnpath')
-			{
+			if($origin != 'learnpath') {
 				echo "\t\t<td>".display_user_link($row['user_id'], $name)."</td>\n";
-			}
-			else
-			{
+			} 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(false,true)) && $origin!='learnpath')
-			{
+			if (($row['visible']=='1' OR api_is_allowed_to_edit(false,true)) && $origin!='learnpath') {
 				$last_post=$row['thread_date']." ".get_lang('By').' '.display_user_link($row['last_poster_user_id'], $name);
-			}
-			else if($origin!='learnpath')
-			{
+			} elseif ($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
-			{
+			} 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);
@@ -326,22 +358,24 @@ if(is_array($threads))
 			}
 			echo "\t\t<td>".$last_post."</td>\n";
 			echo "\t\t<td>";	
-			if (api_is_allowed_to_edit(false,true) && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session']))
-			{
+			if (api_is_allowed_to_edit(false,true) && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session'])) {
+				echo "<a href=\"editpost.php?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".Security::remove_XSS($row['thread_id'])."&amp;post=".$row['post_id']."&origin=".$origin."\">".icon('../img/edit.gif',get_lang('Edit'))."</a>\n";
 				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>";
 			}
 			$iconnotify = 'send_mail.gif';
-			if (is_array($_SESSION['forum_notification']['thread']))
-			{
-				if (in_array($row['thread_id'],$_SESSION['forum_notification']['thread']))
-				{
+			if (is_array($_SESSION['forum_notification']['thread'])) {
+				if (in_array($row['thread_id'],$_SESSION['forum_notification']['thread'])) {
 					$iconnotify = 'send_mail_checked.gif';
 				}
 			}
-			echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&amp;forum=".Security::remove_XSS($_GET['forum'])."&amp;action=notify&amp;content=thread&amp;id=".$row['thread_id']."\">".icon('../img/'.$iconnotify,get_lang('NotifyMe'))."</a>";			
+			$icon_liststd = 'group.gif';
+			echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&amp;forum=".Security::remove_XSS($_GET['forum'])."&amp;action=notify&amp;content=thread&amp;id=".$row['thread_id']."\">".icon('../img/'.$iconnotify,get_lang('NotifyMe'))."</a>";
+			if ($userinf['status']=='1') {
+				echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($_GET['forum']).'&amp;action=liststd&amp;content=thread&amp;id='.$row['thread_id'].'">'.icon('../img/'.$icon_liststd,get_lang('StudentList')).'</a>';			
+			}
 			echo "</td>\n";
 			echo "\t</tr>\n";
 		}
@@ -350,19 +384,13 @@ if(is_array($threads))
 
 	}
 }
-
 echo "</table>";
-
+echo $table_list;
 /*
 ==============================================================================
 		FOOTER
 ==============================================================================
 */
-if($origin != 'learnpath')
-{
+if ($origin != 'learnpath') {
 	Display :: display_footer();
-}
-?>
-
-
-
+}

+ 162 - 213
main/forum/viewforumcategory.php

@@ -3,7 +3,7 @@
 ==============================================================================
 	Dokeos - elearning and course management software
 
-	Copyright (c) 2006-2008 Dokeos S.A.
+	Copyright (c) 2006-2008 Dokeos SPRL
 	Copyright (c) 2006 Ghent University (UGent)
 
 	For a full list of contributors, see "credits.txt".
@@ -16,7 +16,7 @@
 
 	See the GNU General Public License for more details.
 
-	Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
+	Contact address: Dokeos, 108 rue du Corbeau, B-1030 Brussels, Belgium
 	Mail: info@dokeos.com
 ==============================================================================
 */
@@ -46,7 +46,7 @@
 $language_file = 'forum';
 
 // including the global dokeos file
-require ('../inc/global.inc.php');
+require '../inc/global.inc.php';
 
 // the section (tabs)
 $this_section=SECTION_COURSES;
@@ -64,8 +64,8 @@ $nameTools=get_lang('Forum');
 	Including necessary files
 -----------------------------------------------------------
 */
-include('forumconfig.inc.php');
-include('forumfunction.inc.php');
+require 'forumconfig.inc.php';
+require_once 'forumfunction.inc.php';
 
 
 /*
@@ -79,8 +79,7 @@ $fck_attribute['Height'] = '300';
 $fck_attribute['ToolbarSet'] = 'Middle';
 $fck_attribute['Config']['IMUploadPath'] = 'upload/forum/';
 $fck_attribute['Config']['FlashUploadPath'] = 'upload/forum/';
-if(!api_is_allowed_to_edit(false,true))
-{
+if(!api_is_allowed_to_edit(false,true)) {
 	$fck_attribute['Config']['UserStatus'] = 'student';
 }
 
@@ -94,10 +93,8 @@ $interbreadcrumb[]=array("url" => "index.php?search=".Security::remove_XSS(urlen
 $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']));
 
 
-if (!empty($_GET['action']) && !empty($_GET['content'])) 
-{	  
-	if ($_GET['action']=='add' && $_GET['content']=='forum' ) 
-	{		
+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&amp;content=forum', 'name' => get_lang('AddForum'));	  
 	}
 }
@@ -119,8 +116,7 @@ $whatsnew_post_info=$_SESSION['whatsnew_post_info'];
 */
 // 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)
-{
+if (!api_is_allowed_to_edit(false,true) AND $current_forum_category['visibility']==0) {
 	forum_not_allowed_here();
 }
 
@@ -129,57 +125,50 @@ if (!api_is_allowed_to_edit(false,true) AND $current_forum_category['visibility'
 	ACTIONS
 ------------------------------------------------------------------------------------------------------
 */
-if (api_is_allowed_to_edit(false,true))
-{
+if (api_is_allowed_to_edit(false,true)) {
 	handle_forum_and_forumcategories();
 }
 
 // notification
-if ($_GET['action'] == 'notify' AND isset($_GET['content']) AND isset($_GET['id']))
-{
+if ($_GET['action'] == '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 ($_GET['action']!='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 OF THE USER
-------------------------------------------------------------------------------------------------------
-*/
-$groups_of_user=array();
-$groups_of_user=GroupManager::get_group_ids($_course['dbName'], $_user['user_id']);
-//my_print_r($groups_of_user);
-
-
-
-/*
------------------------------------------------------------
-	Action Links
------------------------------------------------------------
-*/
-echo '<span style="float:right;">'.search_link().'</span>';
-if (api_is_allowed_to_edit(false,true))
-{
-	//echo '<a href="'.api_get_self().'?forumcategory='.$_GET['forumcategory'].'&amp;action=add&amp;content=forumcategory">'.get_lang('AddForumCategory').'</a> | ';
-	echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&forumcategory='.Security::remove_XSS($_GET['forumcategory']).'&amp;action=add&amp;content=forum">'.Display::return_icon('forum_new.gif').' '.get_lang('AddForum').'</a>';
-}
-
-/*
+if ($_GET['action']!='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 OF THE USER
+	------------------------------------------------------------------------------------------------------
+	*/
+	$groups_of_user=array();
+	$groups_of_user=GroupManager::get_group_ids($_course['dbName'], $_user['user_id']);
+	//my_print_r($groups_of_user);
+	/*
+	-----------------------------------------------------------
+		Action Links
+	-----------------------------------------------------------
+	*/
+	echo '<span style="float:right;">'.search_link().'</span>';
+	if (api_is_allowed_to_edit(false,true)) {
+		//echo '<a href="'.api_get_self().'?forumcategory='.$_GET['forumcategory'].'&amp;action=add&amp;content=forumcategory">'.get_lang('AddForumCategory').'</a> | ';
+		echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&forumcategory='.Security::remove_XSS($_GET['forumcategory']).'&amp;action=add&amp;content=forum">'.Display::return_icon('forum_new.gif').' '.get_lang('AddForum').'</a>';
+	}
+	
+	/*
 	-----------------------------------------------------------
 		Display Forum Categories and the Forums in it
 	-----------------------------------------------------------
@@ -190,9 +179,7 @@ if (api_is_allowed_to_edit(false,true))
 	echo '<span class="forum_title">'.prepare4display($forum_category['cat_title']).'</span><br />';
 	echo '<span class="forum_description">'.prepare4display($forum_category['cat_comment']).'</span>';
 	echo "</th>\n";
-	if (api_is_allowed_to_edit(false,true) && !($forum_category['session_id']==0 && intval($_SESSION['id_session'])!=0))
-	{
-		
+	if (api_is_allowed_to_edit(false,true) && !($forum_category['session_id']==0 && intval($_SESSION['id_session'])!=0)) {
 		echo '<th style="padding: 5px; vertical-align: top;" align="center" >';			
 		echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&forumcategory=".Security::remove_XSS($_GET['forumcategory'])."&amp;action=edit&amp;content=forumcategory&amp;id=".$forum_category['cat_id']."\">".icon('../img/edit.gif',get_lang('Edit'))."</a>";
 		echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&forumcategory=".Security::remove_XSS($_GET['forumcategory'])."&amp;action=delete&amp;content=forumcategory&amp;amp;id=".$forum_category['cat_id']."\" onclick=\"javascript:if(!confirm('".addslashes(htmlentities(get_lang("DeleteForumCategory"),ENT_QUOTES,$charset))."')) return false;\">".icon('../img/delete.gif',get_lang('Delete'))."</a>";
@@ -202,176 +189,138 @@ if (api_is_allowed_to_edit(false,true))
 		echo "</th>\n";
 	}
 	echo "\t</tr>\n";
-
-// step 3: 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";
-echo "\t</tr>\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;
-		}
-		// you are not a teacher
-		else
-		{
-			//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';
+	
+	// step 3: 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";
+	echo "\t</tr>\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;
-			}
-			// it is a group forum
-			else
-			{
-				//echo '-groepsforum';
-				// it is a group forum but it is public => show
-				if ($forum['forum_group_public_private']=='public')
-				{
+			} 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;
-					//echo '-publiek';
-				}
-				// it is a group forum and it is private
-				else
-				{
-					//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';
+				} 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;
+						}
 					}
-					else
-					{
-						//echo '-is GEEN lid';
-						$show_forum=false;
-					}
+	
 				}
-
 			}
-		}
-		//echo '<hr>';
-
-		if ($show_forum)
-		{
-			$form_count++;
-			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 '<hr>';
+	
+			if ($show_forum === true) {
+				$form_count++;
+				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');
+					} else {
+						echo icon('../img/forumgroup.gif');
+					}
+				} else {
+					if (is_array($whatsnew_post_info[$forum['forum_id']]) and !empty($whatsnew_post_info[$forum['forum_id']])) {
+						echo icon('../img/forum.gif');
+					} else {
+						echo icon('../img/forum.gif');
+					}
 				}
-				else
-				{
-					echo icon('../img/forumgroup.gif');
+				echo "</td>\n";
+				if((!isset($_SESSION['id_session']) || $_SESSION['id_session']==0) && !empty($forum['session_name'])) {
+					$session_displayed = ' ('.$forum['session_name'].')';
+				} else {
+					$session_displayed = '';
 				}
-			}
-			else
-			{
-				if (is_array($whatsnew_post_info[$forum['forum_id']]) and !empty($whatsnew_post_info[$forum['forum_id']]))
-				{
-					echo icon('../img/forum.gif');
+				echo "\t\t<td><a href=\"viewforum.php?".api_get_cidreq()."&forum=".$forum['forum_id']."&amp;search=".Security::remove_XSS(urlencode($_GET['search']))."\" ".class_visible_invisible($forum['visibility']).">".prepare4display($forum['forum_title']).$session_displayed.'</a><br />'.prepare4display($forum['forum_comment'])."</td>\n";
+				//$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'];
+					$poster_id=0;
+				} else {
+					$name=$forum['last_poster_firstname'].' '.$forum['last_poster_lastname'];
+					$poster_id=$forum['last_poster_id'];
 				}
-				else
-				{
-					echo icon('../img/forum.gif');
+				echo "\t\t<td>";
+				if (!empty($forum['last_post_id'])) {
+					echo $forum['last_post_date']." ".get_lang('By').' '.display_user_link($poster_id, $name);
 				}
-			}
-			echo "</td>\n";
-			if((!isset($_SESSION['id_session']) || $_SESSION['id_session']==0) && !empty($forum['session_name']))
-			{
-				$session_displayed = ' ('.$forum['session_name'].')';
-			}
-			else
-				$session_displayed = '';
-			echo "\t\t<td><a href=\"viewforum.php?".api_get_cidreq()."&forum=".$forum['forum_id']."&amp;search=".Security::remove_XSS(urlencode($_GET['search']))."\" ".class_visible_invisible($forum['visibility']).">".prepare4display($forum['forum_title']).$session_displayed.'</a><br />'.prepare4display($forum['forum_comment'])."</td>\n";
-			//$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'];
-				$poster_id=0;
-			}
-			else
-			{
-				$name=$forum['last_poster_firstname'].' '.$forum['last_poster_lastname'];
-				$poster_id=$forum['last_poster_id'];
-			}
-			echo "\t\t<td>";
-			if (!empty($forum['last_post_id']))
-			{
-				echo $forum['last_post_date']." ".get_lang('By').' '.display_user_link($poster_id, $name);
-			}
-			echo "</td>\n";
-			echo "\t\t<td NOWRAP align='center'>";
-			if (api_is_allowed_to_edit(false,true) && !($forum['session_id']==0 && intval($_SESSION['id_session'])!=0))
-			{
-				echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&forumcategory=".Security::remove_XSS($_GET['forumcategory'])."&amp;action=edit&amp;content=forum&amp;id=".$forum['forum_id']."\">".icon('../img/edit.gif',get_lang('Edit'))."</a>";
-				echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&forumcategory=".Security::remove_XSS($_GET['forumcategory'])."&amp;action=delete&amp;content=forum&amp;id=".$forum['forum_id']."\" onclick=\"javascript:if(!confirm('".addslashes(htmlentities(get_lang("DeleteForum"),ENT_QUOTES,$charset))."')) return false;\">".icon('../img/delete.gif',get_lang('Delete'))."</a>";
-				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($_SESSION['forum_notification']['forum']))
-			{
-				if (in_array($forum['forum_id'],$_SESSION['forum_notification']['forum']))
-				{
-					$iconnotify = 'send_mail_checked.gif';
+				echo "</td>\n";
+				echo "\t\t<td NOWRAP align='center'>";
+				if (api_is_allowed_to_edit(false,true) && !($forum['session_id']==0 && intval($_SESSION['id_session'])!=0)) {
+					echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&forumcategory=".Security::remove_XSS($_GET['forumcategory'])."&amp;action=edit&amp;content=forum&amp;id=".$forum['forum_id']."\">".icon('../img/edit.gif',get_lang('Edit'))."</a>";
+					echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&forumcategory=".Security::remove_XSS($_GET['forumcategory'])."&amp;action=delete&amp;content=forum&amp;id=".$forum['forum_id']."\" onclick=\"javascript:if(!confirm('".addslashes(htmlentities(get_lang("DeleteForum"),ENT_QUOTES,$charset))."')) return false;\">".icon('../img/delete.gif',get_lang('Delete'))."</a>";
+					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($_SESSION['forum_notification']['forum']))	{
+					if (in_array($forum['forum_id'],$_SESSION['forum_notification']['forum'])) {
+						$iconnotify = 'send_mail_checked.gif';
+					}
 				}
+				echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&amp;forumcategory=".Security::remove_XSS($_GET['forumcategory'])."&amp;action=notify&amp;content=forum&amp;id=".$forum['forum_id']."\">".icon('../img/'.$iconnotify,get_lang('NotifyMe'))."</a>";
+				echo "</td>\n";
+				echo "\t</tr>";
 			}
-			echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&amp;forumcategory=".Security::remove_XSS($_GET['forumcategory'])."&amp;action=notify&amp;content=forum&amp;id=".$forum['forum_id']."\">".icon('../img/'.$iconnotify,get_lang('NotifyMe'))."</a>";
-			echo "</td>\n";
-			echo "\t</tr>";
 		}
 	}
-}
-if (count($forum_list)==0)
-{
-	echo "\t<tr><td>".get_lang('NoForumInThisCategory')."</td></tr>\n";
-}
-
-echo "</table>\n";
+	if (count($forum_list) == 0) {
+		echo "\t<tr><td>".get_lang('NoForumInThisCategory')."</td></tr>\n";
+	}
+	
+	echo "</table>\n";
 }
 /*
 ==============================================================================
 		FOOTER
 ==============================================================================
 */
-
-Display :: display_footer();
-?>
-
-
-
+Display :: display_footer();

+ 134 - 0
main/forum/viewpost.inc.php

@@ -0,0 +1,134 @@
+<?php
+/*
+==============================================================================
+	Dokeos - elearning and course management software
+
+	Copyright (c) 2008 Dokeos Latinoamerica SAC
+
+	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
+==============================================================================
+*/
+/**
+* 	@package dokeos.forum
+*/
+$rows = get_thread_user_post($current_thread['thread_id'], $_GET['user']);
+$sw = true;
+
+foreach ($rows as $row) {	
+	if ($row['status']=='0') {
+		$style =" id = 'post".$post_en."' class=\"hide-me\" style=\"border:1px solid red; display:none; background-color:#F7F7F7; width:95%; margin: 0px 0px 4px 40px; \" ";
+		$url_post ='';
+	} else {
+		$style = "";
+		$post_en = $row['post_parent_id'];
+		$url_post = '<a href="javascript:;" onclick="javascript:hidecontent(\'#post'.$row['post_parent_id'].'\')"> '.get_lang('ViewComentPost').'</a> ';
+	}
+	
+	if ($row['user_id']=='0') {
+		$name=prepare4display($row['poster_name']);
+	} else {
+		$name=$row['firstname'].' '.$row['lastname'];
+	}
+	if($sw === true) {
+		echo "<div style=\"border: 1px solid #000000; padding: 4px 0px 0px 4px; margin-top:5px;\" > <h3> $name </h3> </div>";
+		$sw = false;
+	}
+	echo "<div ".$style."><table width=\"100%\" class=\"post\" cellspacing=\"5\" border=\"0\" >\n";
+	// the style depends on the status of the message: approved or not
+	//echo 'dd'.$row['status'];
+	
+		 
+	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\">";
+	
+	echo '<br /><b>'.$row['post_date'].'</b><br />';
+	
+	if (api_is_allowed_to_edit()) {	
+		echo $url_post;
+	}
+	
+	echo "</td>\n";
+	
+	// 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></div>";
+}
+
+$userid = (int)$_GET['user_id'];
+$userinf=api_get_user_info($userid);
+$current_thread = get_thread_information($_GET['thread']);
+$threadid = $current_thread['thread_id'];
+$qualify = (int)$_POST['idtextqualify'];
+//return Max qualify thread
+$max_qualify=show_qualify('2',$_GET['cidReq'],$_GET['forum'],$userid,$threadid);
+$current_qualify_thread=show_qualify('1',$_GET['cidReq'],$_GET['forum'],$userid,$threadid);	
+if(isset($_POST['idtextqualify']))
+{	
+	store_theme_qualify($userid,$threadid,$qualify,$_SESSION['_user']['user_id'],date('Y-m-d H:i:s'),'');
+}
+ 
+$result = get_statistical_information($current_thread['thread_id'], $_GET['user'], $_GET['cidReq']);
+if($userinf['status']!='1') {
+	echo '<div class="forum-qualification-input-box">';
+	require_once 'forumbody.inc.php';
+	echo '<a href="forumqualify.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&thread='.Security::remove_XSS($_GET['thread']).'&user_id='.$userid.'">'.get_lang('ViewHistoryChange').'</a>';
+	echo '</div>';
+}
+echo '<div class="forum-qualification-stats-box">
+		  <b>'.get_lang('StatisticalForum').':<br>
+			---------------------<br>			
+			'.get_lang('UserCourse').' : '.$result['user_course'].' <br/>
+			'.get_lang('NumberPosts').' : '.$result['post'].' <br/>		 
+			'.get_lang('NumberUserPost').' : '.$result['user_post'].' <br/>
+			'.get_lang('PromedioPostUser').' : '.$result['user_post']/$result['post'].' <br/>
+			</b></div>
+		 ';

+ 222 - 0
main/forum/viewpost.php

@@ -0,0 +1,222 @@
+<?php
+/*
+==============================================================================
+	Dokeos - elearning and course management software
+
+	Copyright (c) 2008 Dokeos Latinoamerica SAC
+	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, 108 rue du Corbeau, B-1030 Brussels, Belgium
+	Mail: info@dokeos.com
+==============================================================================
+*/
+/**
+* 	@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';
+// 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');
+//require_once (api_get_path(LIBRARY_PATH).'resourcelinker.lib.php');
+$nameTools=get_lang('Forum');
+
+/*
+-----------------------------------------------------------
+	Including necessary files
+-----------------------------------------------------------
+*/
+require 'forumconfig.inc.php';
+require_once 'forumfunction.inc.php';
+$htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_CODE_PATH).'inc/lib/javascript/jquery.js" ></script>';
+$htmlHeadXtra[] = '<script language="javascript">
+										$(document).ready(function(){ $(\'.hide-me\').slideUp() });
+									function hidecontent(content){ $(content).slideToggle(\'normal\'); } 
+									</script>';
+
+//are we in a lp ?
+$origin = '';
+if(isset($_GET['origin'])) {
+	$origin =  Security::remove_XSS($_GET['origin']);
+}
+/*
+==============================================================================
+		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_thread=get_thread_information($_GET['thread']); // note: this has to be validated that it is an existing thread
+$current_forum=get_forum_information($current_thread['forum_id']); // note: this has to be validated that it is an existing forum.
+$current_forum_category=get_forumcategory_information($current_forum['forum_category']);
+$whatsnew_post_info=$_SESSION['whatsnew_post_info'];
+/*
+-----------------------------------------------------------
+	Header and Breadcrumbs
+-----------------------------------------------------------
+*/
+if($origin=='learnpath') {
+	include(api_get_path(INCLUDE_PATH).'reduced_header.inc.php');
+} else {
+	$interbreadcrumb[]=array("url" => "index.php?search=".Security::remove_XSS(urlencode($_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 ($message<>'PostDeletedSpecial') {
+		$interbreadcrumb[]=array("url" => "viewthread.php?forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".Security::remove_XSS($_GET['thread']),"name" => prepare4display($current_thread['thread_title']));
+	}
+	// the last element of the breadcrumb navigation is already set in interbreadcrumb, so give empty string
+	Display :: display_header('');
+	api_display_tool_title($nameTools);
+}
+
+/*
+-----------------------------------------------------------
+	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['visibility']==0 OR $current_thread['visibility']==0)) {
+	forum_not_allowed_here();
+}
+
+/*
+-----------------------------------------------------------
+	Actions
+-----------------------------------------------------------
+*/
+if ($_GET['action']=='delete' AND isset($_GET['content']) AND isset($_GET['id']) AND api_is_allowed_to_edit(false,true)) {
+	$message=delete_post($_GET['id']); // note: this has to be cleaned first
+}
+if (($_GET['action']=='invisible' OR $_GET['action']=='visible') AND isset($_GET['id']) AND api_is_allowed_to_edit(false,true)) {
+	$message=approve_post($_GET['id'],$_GET['action']); // note: this has to be cleaned first
+}
+if ($_GET['action']=='move' and isset($_GET['post'])) {
+	$message=move_post_form();
+}
+
+/*
+-----------------------------------------------------------
+	Display the action messages
+-----------------------------------------------------------
+*/
+if (!empty($message)) {
+	Display :: display_confirmation_message(get_lang($message));
+}
+
+if ($message<>'PostDeletedSpecial') {// in this case the first and only post of the thread is removed
+	// this increases the number of times the thread has been viewed
+	increase_thread_view($_GET['thread']);
+
+	/*
+	-----------------------------------------------------------
+		Action Links
+	-----------------------------------------------------------
+	*/
+	echo '<div style="float:right;">';
+	$my_url = '<a href="viewthread.php?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($_GET['forum']).'&amp;thread='.Security::remove_XSS($_GET['thread']).'&amp;search='.Security::remove_XSS(urlencode($_GET['search']));
+	echo $my_url.'&amp;view=flat&origin='.$origin.'">'.get_lang('FlatView').'</a> | ';
+	echo $my_url.'&amp;view=threaded&origin='.$origin.'">'.get_lang('ThreadedView').'</a> | ';
+	echo $my_url.'&amp;view=nested&origin='.$origin.'">'.get_lang('NestedView').'</a>';
+	$my_url = null;
+	echo '</div>';
+	// the reply to thread link should only appear when the forum_category is not locked AND the forum is not locked AND the thread is not locked.
+	// if one of the three levels is locked then the link should not be displayed
+	if ($current_forum_category['locked']==0 AND $current_forum['locked']==0 AND $current_thread['locked']==0 OR api_is_allowed_to_edit(false,true)) {
+		// The link should only appear when the user is logged in or when anonymous posts are allowed.
+		if ($_user['user_id'] OR ($current_forum['allow_anonymous']==1 AND !$_user['user_id'])) {
+			//reply link
+			echo '<a href="reply.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&amp;thread='.Security::remove_XSS($_GET['thread']).'&amp;action=replythread&origin='.$origin.'">'.get_lang('ReplyToThread').'</a>';
+			
+			//new thread link
+			if (api_is_allowed_to_edit(false,true) 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 '&nbsp;&nbsp;'; 
+					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');
+				}
+			}
+		}
+	}
+	// note: this is to prevent that some browsers display the links over the table (FF does it but Opera doesn't)
+	echo '&nbsp;';
+	
+	/*
+	-----------------------------------------------------------
+		Display Forum Category and the Forum information
+	-----------------------------------------------------------
+	*/
+	if (!$_SESSION['view']) {
+		$viewmode=$current_forum['default_view'];
+	} else {
+		$viewmode=$_SESSION['view'];
+	}
+
+	$viewmode_whitelist=array('flat', 'threaded', 'nested');
+	if (isset($_GET['view']) and in_array($_GET['view'],$viewmode_whitelist)) {
+		$viewmode=Database::escape_string($_GET['view']);
+		$_SESSION['view']=$viewmode;
+	} 
+	if(empty($viewmode)) {
+		$viewmode = 'flat';
+	}
+
+	/*
+	-----------------------------------------------------------
+		Display Forum Category and the Forum 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
+	echo "<table class=\"data_table\" width=\"100%\">\n";
+
+	// the thread	
+	echo "\t<tr>\n\t\t<th style=\"padding-left:5px;\" align=\"left\" colspan=\"6\">";		
+	echo '<span class="forum_title">'.prepare4display($current_thread['thread_title']).'</span><br />';
+	
+	if($origin!='learnpath')
+	{		
+		echo '<span class="forum_low_description">'.prepare4display($current_forum_category['cat_title']).' - ';				
+	}
+		
+	echo prepare4display($current_forum['forum_title']).'<br />';						
+	echo "</th>\n";
+	echo "\t</tr>\n";		
+	echo '<span>'.prepare4display($current_thread['thread_comment']).'</span>';	
+	echo "</table>";
+		
+	include_once('viewpost.inc.php');
+} // if ($message<>'PostDeletedSpecial') // in this case the first and only post of the thread is removed
+
+/*
+==============================================================================
+		FOOTER
+==============================================================================
+*/
+if($origin!='learnpath') {
+	Display :: display_footer();
+}

+ 39 - 96
main/forum/viewthread.php

@@ -3,7 +3,7 @@
 ==============================================================================
 	Dokeos - elearning and course management software
 
-	Copyright (c) 2006-2008 Dokeos S.A.
+	Copyright (c) 2006-2008 Dokeos SPRL
 	Copyright (c) 2006 Ghent University (UGent)
 
 	For a full list of contributors, see "credits.txt".
@@ -16,48 +16,22 @@
 
 	See the GNU General Public License for more details.
 
-	Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
+	Contact address: Dokeos, 108 rue du Corbeau, 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>
- **************************************************************************
- */
-
 // name of the language file that needs to be included
 $language_file = 'forum';
 
 // including the global dokeos file
-require ('../inc/global.inc.php');
+require '../inc/global.inc.php';
 
 // the section (tabs)
 $this_section=SECTION_COURSES;
@@ -67,7 +41,7 @@ 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');
+require_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php');
 //require_once (api_get_path(LIBRARY_PATH).'resourcelinker.lib.php');
 $nameTools=get_lang('Forum');
 
@@ -76,14 +50,13 @@ $nameTools=get_lang('Forum');
 	Including necessary files
 -----------------------------------------------------------
 */
-include('forumconfig.inc.php');
-include('forumfunction.inc.php');
+require 'forumconfig.inc.php';
+require_once 'forumfunction.inc.php';
 
 
 //are we in a lp ?
 $origin = '';
-if(isset($_GET['origin']))
-{
+if(isset($_GET['origin'])) {
 	$origin =  Security::remove_XSS($_GET['origin']);
 }
 
@@ -112,25 +85,26 @@ $whatsnew_post_info=$_SESSION['whatsnew_post_info'];
 	Header and Breadcrumbs
 -----------------------------------------------------------
 */
-if($origin=='learnpath')
-{
+if (!empty($_GET['gradebook'])) {
+		$interbreadcrumb[]= array (
+			'url' => '../gradebook/index.php',
+			'name' => get_lang('Gradebook')
+		);
+}
+if ($origin=='learnpath') {
 	include(api_get_path(INCLUDE_PATH).'reduced_header.inc.php');
-} else
-{
+} else {
 
 	$interbreadcrumb[]=array("url" => "index.php?search=".Security::remove_XSS(urlencode($_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 ($message<>'PostDeletedSpecial')
-	{
+	if ($message<>'PostDeletedSpecial') {
 		$interbreadcrumb[]=array("url" => "viewthread.php?forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".Security::remove_XSS($_GET['thread']),"name" => prepare4display($current_thread['thread_title']));
 	}
 	// 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" />';
 
 /*
 -----------------------------------------------------------
@@ -139,8 +113,7 @@ if($origin=='learnpath')
 */
 // 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['visibility']==0 OR $current_thread['visibility']==0))
-{
+if (!api_is_allowed_to_edit(false,true) AND ($current_forum['visibility']==0 OR $current_thread['visibility']==0)) {
 	forum_not_allowed_here();
 }
 
@@ -149,16 +122,13 @@ if (!api_is_allowed_to_edit(false,true) AND ($current_forum['visibility']==0 OR
 	Actions
 -----------------------------------------------------------
 */
-if ($_GET['action']=='delete' AND isset($_GET['content']) AND isset($_GET['id']) AND api_is_allowed_to_edit(false,true))
-{
+if ($_GET['action']=='delete' AND isset($_GET['content']) AND isset($_GET['id']) AND api_is_allowed_to_edit(false,true)) {
 	$message=delete_post($_GET['id']); // note: this has to be cleaned first
 }
-if (($_GET['action']=='invisible' OR $_GET['action']=='visible') AND isset($_GET['id']) AND api_is_allowed_to_edit(false,true))
-{
+if (($_GET['action']=='invisible' OR $_GET['action']=='visible') AND isset($_GET['id']) AND api_is_allowed_to_edit(false,true)) {
 	$message=approve_post($_GET['id'],$_GET['action']); // note: this has to be cleaned first
 }
-if ($_GET['action']=='move' and isset($_GET['post']))
-{
+if ($_GET['action']=='move' and isset($_GET['post'])) {
 	$message=move_post_form();
 }
 
@@ -167,20 +137,14 @@ if ($_GET['action']=='move' and isset($_GET['post']))
 	Display the action messages
 -----------------------------------------------------------
 */
-if (isset($message))
-{
+if (isset($message)) {
 	Display :: display_confirmation_message(get_lang($message));
 }
 
-
-if ($message<>'PostDeletedSpecial') // in this case the first and only post of the thread is removed
-{
-
+if ($message<>'PostDeletedSpecial') { 
+	// in this case the first and only post of the thread is removed
 	// this increases the number of times the thread has been viewed
 	increase_thread_view($_GET['thread']);
-
-
-
 	/*
 	-----------------------------------------------------------
 		Action Links
@@ -195,59 +159,43 @@ if ($message<>'PostDeletedSpecial') // in this case the first and only post of t
 	echo '</div>';
 	// the reply to thread link should only appear when the forum_category is not locked AND the forum is not locked AND the thread is not locked.
 	// if one of the three levels is locked then the link should not be displayed
-	if ($current_forum_category['locked']==0 AND $current_forum['locked']==0 AND $current_thread['locked']==0 OR api_is_allowed_to_edit(false,true))
-	{
+	if ($current_forum_category['locked']==0 AND $current_forum['locked']==0 AND $current_thread['locked']==0 OR api_is_allowed_to_edit(false,true)) {
 		// The link should only appear when the user is logged in or when anonymous posts are allowed.
-		if ($_user['user_id'] OR ($current_forum['allow_anonymous']==1 AND !$_user['user_id']))
-		{
+		if ($_user['user_id'] OR ($current_forum['allow_anonymous']==1 AND !$_user['user_id'])) {
 			//reply link
 			echo '<a href="reply.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&amp;thread='.Security::remove_XSS($_GET['thread']).'&amp;action=replythread&origin='.$origin.'">'.get_lang('ReplyToThread').'</a>';
 			
 			//new thread link
-			if ((api_is_allowed_to_edit(false,true) && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session'])) 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 '&nbsp;&nbsp;'; 
-				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
-				{
+			if ((api_is_allowed_to_edit(false,true) && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session'])) 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 '&nbsp;&nbsp;'; 
+					echo '<a href="newthread.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&origin='.$origin.'">'.Display::return_icon('forumthread_new.gif').' '.get_lang('NewTopic').'</a>';
+				} else {
 					echo get_lang('ForumLocked');
 				}
 			}
-
-
-			
 		}
 	}
 	// note: this is to prevent that some browsers display the links over the table (FF does it but Opera doesn't)
 	echo '&nbsp;';
-
-
 	/*
 	-----------------------------------------------------------
 		Display Forum Category and the Forum information
 	-----------------------------------------------------------
 	*/
 
-	if (!$_SESSION['view'])
-	{
+	if (!$_SESSION['view'])	{
 		$viewmode=$current_forum['default_view'];
-	}
-	else
-	{
+	} else {
 		$viewmode=$_SESSION['view'];
 	}
 
 	$viewmode_whitelist=array('flat', 'threaded', 'nested');
-	if (isset($_GET['view']) and in_array($_GET['view'],$viewmode_whitelist))
-	{
+	if (isset($_GET['view']) and in_array($_GET['view'],$viewmode_whitelist)) {
 		$viewmode=$_GET['view'];
 		$_SESSION['view']=$viewmode;
 	}
-	if(empty($viewmode))
-	{
+	if(empty($viewmode)) {
 		$viewmode = 'flat';
 	}
 
@@ -265,19 +213,17 @@ if ($message<>'PostDeletedSpecial') // in this case the first and only post of t
 	echo "\t<tr>\n\t\t<th style=\"padding-left:5px;\" align=\"left\" colspan=\"6\">";		
 	echo '<span class="forum_title">'.prepare4display($current_thread['thread_title']).'</span><br />';
 	
-	if($origin!='learnpath')
-	{		
+	if($origin!='learnpath') {		
 		echo '<span class="forum_low_description">'.prepare4display($current_forum_category['cat_title']).' - ';				
 	}
 		
-	echo prepare4display($current_forum['forum_title']).'<br />';						
+	echo prepare4display($current_forum['forum_title']).'<br />';					
 	echo "</th>\n";
 	echo "\t</tr>\n";		
 	echo '<span>'.prepare4display($current_thread['thread_comment']).'</span>';	
 	echo "</table>";
 	
-	switch ($viewmode)
-	{
+	switch ($viewmode) {
 		case 'flat':
 			include_once('viewthread_flat.inc.php');
 			break;
@@ -293,14 +239,11 @@ if ($message<>'PostDeletedSpecial') // in this case the first and only post of t
 	}
 } // if ($message<>'PostDeletedSpecial') // in this case the first and only post of the thread is removed
 
-	
-
-
 /*
 ==============================================================================
 		FOOTER
 ==============================================================================
 */
-if($origin!='learnpath')
+if($origin!='learnpath') {
 	Display :: display_footer();
-?>
+}

+ 33 - 85
main/forum/viewthread_flat.inc.php

@@ -20,55 +20,18 @@
 	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)
-{
+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')
-	{
+	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 
-	{
+	} else {
 		$titleclass='forum_message_post_title';
 		$messageclass='forum_message_post_text';
 		$leftclass='forum_message_left';		
@@ -76,80 +39,67 @@ foreach ($rows as $row)
 	
 	echo "\t<tr>\n";
 	echo "\t\t<td rowspan=\"3\" class=\"$leftclass\">";
-	if ($row['user_id']=='0')
-	{
+	if ($row['user_id']=='0') {
 		$name=prepare4display($row['poster_name']);
-	}
-	else 
-	{
+	} else {
 		$name=$row['firstname'].' '.$row['lastname'];
 	}
-	if($origin!='learnpath')
-	{
-	
+	if($origin!='learnpath') {	
 		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 
-	{
+	} 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(false,true)  && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session'])))
-	{
-		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 (($current_forum['allow_edit']==1 AND $row['user_id']==$_user['user_id']) or (api_is_allowed_to_edit(false,true)  && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session']))) {
+		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."&edit=edition\">".icon('../img/edit.gif',get_lang('Edit'))."</a>\n";
 	}
-	if (api_is_allowed_to_edit(false,true)  && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session']))
-	{
+	if (api_is_allowed_to_edit(false,true)  && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session'])) {
 		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>";
 	}
+
+	$userinf=api_get_user_info($row['user_id']);
+	if($userinf['status']!='1')	{
+		if(api_is_allowed_to_edit()) {						
+			$current_qualify_thread=show_qualify('1',$_GET['cidReq'],$_GET['forum'],$row['poster_id'],$_GET['thread']);
+			echo "<a href=\"viewpost.php?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".Security::remove_XSS($_GET['thread'])."&amp;action=list&amp;post=".$row['post_id']."&amp;user=".$row['poster_id']."&user_id=".$row['poster_id']."&origin=".$origin."&idtextqualify=".$current_qualify_thread."\" >".icon('../img/new_test_small.gif',get_lang('Qualify'))."</a>\n";		
+		}	
+	}
 	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(false,true))
-	{
-		if ($_user['user_id'] OR ($current_forum['allow_anonymous']==1 AND !$_user['user_id']))
-		{
+	if ($current_forum_category['locked']==0 AND $current_forum['locked']==0 AND $current_thread['locked']==0 OR api_is_allowed_to_edit(false,true)) {
+		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)
-		{
+	} else {
+		if ($current_forum_category['locked']==1) {
 			echo get_lang('ForumcategoryLocked').'<br />';
 		}
-		if ($current_forum['locked']==1)
-		{
+		if ($current_forum['locked']==1) {
 			echo get_lang('ForumLocked').'<br />';
 		}
-		if ($current_thread['locked']==1)
-		{
+		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']]))
-	{
+	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 
-	{
+	} else {
 		$post_image=icon('../img/forumpost.gif');
 	}
-	if ($row['post_notification']=='1' AND $row['poster_id']==$_user['user_id'])
-	{
+	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";	
@@ -162,12 +112,11 @@ foreach ($rows as $row)
 	// The check if there is an attachment
 	$attachment_list=get_attachment($row['post_id']);	
 	
-	if (!empty($attachment_list))
-	{
+	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;
@@ -182,5 +131,4 @@ foreach ($rows as $row)
 	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>";
-}
-?>
+}

+ 46 - 106
main/forum/viewthread_nested.inc.php

@@ -3,7 +3,7 @@
 ==============================================================================
 	Dokeos - elearning and course management software
 
-	Copyright (c) 2006 Dokeos S.A.
+	Copyright (c) 2006 Dokeos SPRL
 	Copyright (c) 2006 Ghent University (UGent)
 
 	For a full list of contributors, see "credits.txt".
@@ -22,52 +22,29 @@
 */
 
 /**
-*	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>
- ************************************************************************** 
- */
-
+//are we in a lp ?
+$origin = '';
+if(isset($_GET['origin']))
+{
+    $origin =  Security::remove_XSS($_GET['origin']);
+}
 
 $rows=get_posts($_GET['thread']); // note: this has to be cleaned first
 $rows=calculate_children($rows);
 
-foreach ($rows as $post)
-{
+foreach ($rows as $post) {
 	// the style depends on the status of the message: approved or not
-	if ($post['visible']=='0')
-	{
+	if ($post['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 
-	{
+	} else {
 		$titleclass='forum_message_post_title';
 		$messageclass='forum_message_post_text';
 		$leftclass='forum_message_left';		
@@ -78,67 +55,60 @@ foreach ($rows as $post)
 	echo "<table width=\"100%\"  class=\"post\" cellspacing=\"5\" border=\"0\">\n";
 	echo "\t<tr>\n";
 	echo "\t\t<td rowspan=\"3\" class=\"$leftclass\">";
-	if ($post['user_id']=='0')
-	{
+	if ($post['user_id']=='0') {
 		$name=$post['poster_name'];
-	}
-	else 
-	{
+	} else {
 		$name=$post['firstname'].' '.$post['lastname'];
 	}	
-	if (api_get_course_setting('allow_user_image_forum')) {echo '<br />'.display_user_image($post['user_id'],$name,false,true).'<br />';	}
-	echo display_user_link($post['user_id'], $name).'<br />';
+	if (api_get_course_setting('allow_user_image_forum')) {
+		echo '<br />'.display_user_image($post['user_id'],$name,$origin).'<br />';
+	}
+	echo display_user_link($post['user_id'], $name, $origin).'<br />';
 	echo $post['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 $post['user_id']==$_user['user_id']) or (api_is_allowed_to_edit(false,true) && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session'])))
-	{
+	if (($current_forum['allow_edit']==1 AND $post['user_id']==$_user['user_id']) or (api_is_allowed_to_edit(false,true) && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session']))) {
 		echo "<a href=\"editpost.php?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".Security::remove_XSS($_GET['thread'])."&amp;post=".$post['post_id']."\">".icon('../img/edit.gif',get_lang('Edit'))."</a>\n";
 	}
-	if (api_is_allowed_to_edit(false,true)  && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session']))
-	{
+	if (api_is_allowed_to_edit(false,true)  && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session'])) {
 		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=".$post['post_id']."\" 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', $post['post_id'], $post['visible'],array('forum'=>Security::remove_XSS($_GET['forum']),'thread'=>Security::remove_XSS($_GET['thread']) ));
 		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=".$post['post_id']."\">".icon('../img/deplacer_fichier.gif',get_lang('MovePost'))."</a>";
 	}
+	$userinf=api_get_user_info($post['user_id']);
+	if($userinf['status']!='1')	{
+		if(api_is_allowed_to_edit()) {						
+			$current_qualify_thread=show_qualify('1',$_GET['cidReq'],$_GET['forum'],$post['user_id'],$_GET['thread']);
+			echo "<a href=\"viewpost.php?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".Security::remove_XSS($_GET['thread'])."&amp;action=list&amp;post=".$post['post_id']."&amp;user=".$post['user_id']."&user_id=".$post['user_id']."&origin=".$origin."&idtextqualify=".$current_qualify_thread."\" >".icon('../img/new_test_small.gif',get_lang('Qualify'))."</a>\n";			
+		}
+	}
 	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(false,true))
-	{
-		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='.$post['post_id'].'&amp;action=replymessage">'.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='.$post['post_id'].'&amp;action=quote">'.get_lang('QuoteMessage').'</a><br /><br />';
+	if ($current_forum_category['locked']==0 AND $current_forum['locked']==0 AND $current_thread['locked']==0 OR api_is_allowed_to_edit(false,true)) {
+		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='.$post['post_id'].'&amp;action=replymessage&amp;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='.$post['post_id'].'&amp;action=quote&amp;origin='. $origin .'">'.get_lang('QuoteMessage').'</a><br /><br />';
 		}
-	}
-	else 
-	{
-		if ($current_forum_category['locked']==1)
-	{
+	} else {
+		if ($current_forum_category['locked']==1) {
 			echo get_lang('ForumcategoryLocked').'<br />';
 		}
-		if ($current_forum['locked']==1)
-		{
+		if ($current_forum['locked']==1) {
 			echo get_lang('ForumLocked').'<br />';
-	}
-		if ($current_thread['locked']==1)
-		{
+		}
+		if ($current_thread['locked']==1) {
 			echo get_lang('ThreadLocked').'<br />';
-	}				
+		}
 	}
 	echo "</td>\n";
 	// note: this can be removed here because it will be displayed in the tree
-	if (isset($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$post['post_id']]) and !empty($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$post['post_id']]) and !empty($whatsnew_post_info[$_GET['forum']][$post['thread_id']]))
-	{
+	if (isset($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$post['post_id']]) and !empty($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$post['post_id']]) and !empty($whatsnew_post_info[$_GET['forum']][$post['thread_id']])) {
 		$post_image=icon('../img/forumpostnew.gif');
-	}
-	else 
-	{
+	} else {
 		$post_image=icon('../img/forumpost.gif');
 	}
-	if ($post['post_notification']=='1' AND $post['poster_id']==$_user['user_id'])
-	{
+	if ($post['post_notification']=='1' AND $post['poster_id']==$_user['user_id']) {
 		$post_image.=icon('../img/forumnotification.gif',get_lang('YouWillBeNotified'));
 	}		
 	// The post title
@@ -154,8 +124,7 @@ foreach ($rows as $post)
 	// The check if there is an attachment
 	$attachment_list=get_attachment($post['post_id']);	
 	
-	if (!empty($attachment_list))
-	{
+	if (!empty($attachment_list)) {
 		echo '<tr><td height="50%">';	
 		$realname=$attachment_list['path'];			
 		$user_filename=$attachment_list['filename'];
@@ -168,25 +137,6 @@ foreach ($rows as $post)
 		echo '</td></tr>';		
 	}
 	
-	
-	
-	/*
-	// The added resources
-	echo "<tr><td>";
-	if (check_added_resources("forum_post", $post["post_id"]))
-	{
-		
-		echo "<i>".get_lang("AddedResources")."</i><br/>";
-		if ($post['visible']=='0')
-		{
-			$addedresource_style="invisible";
-		}
-		display_added_resources("forum_post", $post["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($_SESSION['whatsnew_post_info'][$current_forum['forum_id']][$current_thread['thread_id']][$row['post_id']]);
@@ -194,18 +144,14 @@ foreach ($rows as $post)
 	echo "</div>";
 }
 
-
-
 /**
 * This function builds an array of all the posts in a given thread where the key of the array is the post_id
 * It also adds an element children to the array which itself is an array that contains all the id's of the first-level children
 * @return an array containing all the information on the posts of a thread
 * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
 */
-function calculate_children($rows)
-{
-	foreach($rows as $row)
-	{
+function calculate_children($rows) {
+	foreach($rows as $row) {
 		$rows_with_children[$row["post_id"]]=$row;
 		$rows_with_children[$row["post_parent_id"]]["children"][]=$row["post_id"];
 	}
@@ -216,22 +162,16 @@ function calculate_children($rows)
 	return $sorted_rows;
 }
 
-function _phorum_recursive_sort($rows, &$threads, $seed=0, $indent=0)
-{
-	if($seed>0)
-	{
+function _phorum_recursive_sort($rows, &$threads, $seed=0, $indent=0) {
+	if($seed>0) {
 		$threads[$rows[$seed]["post_id"]]=$rows[$seed];
 		$threads[$rows[$seed]["post_id"]]["indent_cnt"]=$indent;
 		$indent++;
 	}
 
-	if(isset($rows[$seed]["children"]))
-	{
-		foreach($rows[$seed]["children"] as $child)
-		{
+	if(isset($rows[$seed]["children"])) {
+		foreach($rows[$seed]["children"] as $child) {
 			_phorum_recursive_sort($rows, $threads, $child, $indent);
 		}
 	}
-}
-
-?>
+}

+ 26 - 11
main/forum/viewthread_threaded.inc.php

@@ -3,7 +3,7 @@
 ==============================================================================
 	Dokeos - elearning and course management software
 
-	Copyright (c) 2006-2008 Dokeos S.A.
+	Copyright (c) 2006-2008 Dokeos SPRL
 	Copyright (c) 2006 Ghent University (UGent)
 
 	For a full list of contributors, see "credits.txt".
@@ -16,7 +16,7 @@
 
 	See the GNU General Public License for more details.
 
-	Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
+	Contact address: Dokeos, 108 rue du Corbeau, B-1030 Brussels, Belgium
 	Mail: info@dokeos.com
 ==============================================================================
 */
@@ -68,6 +68,13 @@ else
 	$display_post_id=$current['post_id'];
 }
 
+//are we in a lp ?
+$origin = '';
+if(isset($_GET['origin']))
+{
+    $origin =  Security::remove_XSS($_GET['origin']);
+}
+
 // --------------------------------------
 // 		Displaying the thread (structure)
 // --------------------------------------
@@ -104,7 +111,7 @@ foreach ($rows as $post)
 		{
 			$class='';
 		}
-		$thread_structure.= "<a href=\"viewthread.php?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".Security::remove_XSS($_GET['thread'])."&amp;post=".$post['post_id']."\" $class>".prepare4display($post['post_title'])."</a></div>\n";
+		$thread_structure.= "<a href=\"viewthread.php?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".Security::remove_XSS($_GET['thread'])."&amp;post=".$post['post_id']."&amp;origin=$origin\" $class>".prepare4display($post['post_title'])."</a></div>\n";
 		$prev_next_array[]=$post['post_id'];
 	}	
 }
@@ -131,8 +138,8 @@ $next_img = '<img src="'.api_get_path(WEB_CODE_PATH).'img/next.png"  style="vert
 $first_page_text = '<img src="'.api_get_path(WEB_CODE_PATH).'img/first.png"  style="vertical-align: middle;"/>';
 $last_page_text	 = '<img src="'.api_get_path(WEB_CODE_PATH).'img/last.png"  style="vertical-align: middle;"/>';
 
-$href_prev='"viewthread.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&amp;thread='.Security::remove_XSS($_GET['thread']).'&amp;post='.$prev_next_array[$prev_id].'"';
-$href_next='"viewthread.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&amp;thread='.Security::remove_XSS($_GET['thread']).'&amp;post='.$prev_next_array[$next_id].'"';
+$href_prev='"viewthread.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&amp;thread='.Security::remove_XSS($_GET['thread']).'&amp;post='.$prev_next_array[$prev_id].'&amp;origin='. $origin .'"';
+$href_next='"viewthread.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&amp;thread='.Security::remove_XSS($_GET['thread']).'&amp;post='.$prev_next_array[$next_id].'&amp;origin='. $origin .'"';
 
 // the last message
 if ($next_id>=$max) 
@@ -217,8 +224,8 @@ else
 {
 	$name=$rows[$display_post_id]['firstname'].' '.$rows[$display_post_id]['lastname'];
 }
-if (api_get_course_setting('allow_user_image_forum')) {echo '<br />'.display_user_image($rows[$display_post_id]['user_id'],$name,false,true).'<br />';	}
-echo display_user_link($rows[$display_post_id]['user_id'], $name).'<br />';
+if (api_get_course_setting('allow_user_image_forum')) {echo '<br />'.display_user_image($rows[$display_post_id]['user_id'],$name, $origin).'<br />';	}
+echo display_user_link($rows[$display_post_id]['user_id'], $name, $origin).'<br />';
 echo $rows[$display_post_id]['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
@@ -233,14 +240,23 @@ if (api_is_allowed_to_edit(false,true)  && !(api_is_course_coach() && $current_f
 	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=".$rows[$display_post_id]['post_id']."\">".icon('../img/deplacer_fichier.gif',get_lang('MovePost'))."</a>\n";
 }
+$userinf=api_get_user_info($rows[$display_post_id]['user_id']);
+	if($userinf['status']!='1')
+	{
+		if(api_is_allowed_to_edit())
+		{			
+			$current_qualify_thread=show_qualify('1',$_GET['cidReq'],$_GET['forum'],$rows[$display_post_id]['user_id'],$_GET['thread']);
+			echo "<a href=\"viewpost.php?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&amp;thread=".Security::remove_XSS($_GET['thread'])."&amp;action=list&amp;post=".$rows[$display_post_id]['post_id']."&amp;user=".$rows[$display_post_id]['user_id']."&user_id=".$rows[$display_post_id]['user_id']."&origin=".$origin."&idtextqualify=".$current_qualify_thread."\" >".icon('../img/new_test_small.gif',get_lang('Qualify'))."</a>\n";			
+		}	
+	}
 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(false,true))
 {
 	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='.$rows[$display_post_id]['post_id'].'&amp;action=replymessage">'.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='.$rows[$display_post_id]['post_id'].'&amp;action=quote">'.get_lang('QuoteMessage').'</a><br /><br />';
+		echo '<a href="reply.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&amp;thread='.Security::remove_XSS($_GET['thread']).'&amp;post='.$rows[$display_post_id]['post_id'].'&amp;action=replymessage&amp;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='.$rows[$display_post_id]['post_id'].'&amp;action=quote&amp;origin='. $origin .'">'.get_lang('QuoteMessage').'</a><br /><br />';
 	}
 }
 else 
@@ -348,5 +364,4 @@ function _phorum_recursive_sort($rows, &$threads, $seed=0, $indent=0)
 			_phorum_recursive_sort($rows, $threads, $child, $indent);
 		}
 	}
-}
-?>
+}

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác