parent
fa8383b414
commit
38daca6aff
@ -1,194 +1,194 @@ |
|||||||
<?php |
<?php |
||||||
/* |
/* |
||||||
============================================================================== |
============================================================================== |
||||||
Dokeos - elearning and course management software |
Dokeos - elearning and course management software |
||||||
|
|
||||||
Copyright (c) 2006 Dokeos SPRL |
Copyright (c) 2006 Dokeos SPRL |
||||||
Copyright (c) 2006 Ghent University (UGent) |
Copyright (c) 2006 Ghent University (UGent) |
||||||
|
|
||||||
For a full list of contributors, see "credits.txt". |
For a full list of contributors, see "credits.txt". |
||||||
The full license can be read in "license.txt". |
The full license can be read in "license.txt". |
||||||
|
|
||||||
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
||||||
modify it under the terms of the GNU General Public License |
modify it under the terms of the GNU General Public License |
||||||
as published by the Free Software Foundation; either version 2 |
as published by the Free Software Foundation; either version 2 |
||||||
of the License, or (at your option) any later version. |
of the License, or (at your option) any later version. |
||||||
|
|
||||||
See the GNU General Public License for more details. |
See the GNU General Public License for more details. |
||||||
|
|
||||||
Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium |
Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium |
||||||
Mail: info@dokeos.com |
Mail: info@dokeos.com |
||||||
============================================================================== |
============================================================================== |
||||||
*/ |
*/ |
||||||
|
|
||||||
/** |
/** |
||||||
* @Author Patrick Cool <patrick.cool@UGent.be>, Ghent University |
* @Author Patrick Cool <patrick.cool@UGent.be>, Ghent University |
||||||
* @Copyright Ghent University |
* @Copyright Ghent University |
||||||
* @Copyright Patrick Cool |
* @Copyright Patrick Cool |
||||||
* |
* |
||||||
* @package dokeos.forum |
* @package dokeos.forum |
||||||
*/ |
*/ |
||||||
//are we in a lp ? |
//are we in a lp ? |
||||||
$origin = ''; |
$origin = ''; |
||||||
if(isset($_GET['origin'])) |
if(isset($_GET['origin'])) |
||||||
{ |
{ |
||||||
$origin = Security::remove_XSS($_GET['origin']); |
$origin = Security::remove_XSS($_GET['origin']); |
||||||
} |
} |
||||||
|
|
||||||
//delete attachment file |
//delete attachment file |
||||||
if ((isset($_GET['action']) && $_GET['action']=='delete_attach') && isset($_GET['id_attach'])) { |
if ((isset($_GET['action']) && $_GET['action']=='delete_attach') && isset($_GET['id_attach'])) { |
||||||
delete_attachment(0,$_GET['id_attach']); |
delete_attachment(0,$_GET['id_attach']); |
||||||
} |
} |
||||||
|
|
||||||
$rows=get_posts($_GET['thread']); // note: this has to be cleaned first |
$rows=get_posts($_GET['thread']); // note: this has to be cleaned first |
||||||
$rows=calculate_children($rows); |
$rows=calculate_children($rows); |
||||||
$count=0; |
$count=0; |
||||||
foreach ($rows as $post) { |
foreach ($rows as $post) { |
||||||
// the style depends on the status of the message: approved or not |
// 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'; |
$titleclass='forum_message_post_title_2_be_approved'; |
||||||
$messageclass='forum_message_post_text_2_be_approved'; |
$messageclass='forum_message_post_text_2_be_approved'; |
||||||
$leftclass='forum_message_left_2_be_approved'; |
$leftclass='forum_message_left_2_be_approved'; |
||||||
} else { |
} else { |
||||||
$titleclass='forum_message_post_title'; |
$titleclass='forum_message_post_title'; |
||||||
$messageclass='forum_message_post_text'; |
$messageclass='forum_message_post_text'; |
||||||
$leftclass='forum_message_left'; |
$leftclass='forum_message_left'; |
||||||
} |
|
||||||
|
|
||||||
$indent=$post['indent_cnt']*'20'; |
|
||||||
echo "<div style=\"margin-left: ".$indent."px;\">"; |
|
||||||
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') { |
|
||||||
$name=$post['poster_name']; |
|
||||||
} else { |
|
||||||
$name=api_get_person_name($post['firstname'], $post['lastname']); |
|
||||||
} |
} |
||||||
if (api_get_course_setting('allow_user_image_forum')) { |
|
||||||
echo '<br />'.display_user_image($post['user_id'],$name,$origin).'<br />'; |
$indent=$post['indent_cnt']*'20'; |
||||||
} |
echo "<div style=\"margin-left: ".$indent."px;\">"; |
||||||
echo display_user_link($post['user_id'], $name, $origin).'<br />'; |
echo "<table width=\"100%\" class=\"post\" cellspacing=\"5\" border=\"0\">\n"; |
||||||
echo $post['post_date'].'<br /><br />'; |
echo "\t<tr>\n"; |
||||||
// get attach id |
echo "\t\t<td rowspan=\"3\" class=\"$leftclass\">"; |
||||||
$attachment_list=get_attachment($post['post_id']); |
if ($post['user_id']=='0') { |
||||||
$id_attach = !empty($attachment_list)?$attachment_list['id']:''; |
$name=$post['poster_name']; |
||||||
// The user who posted it can edit his thread only if the course admin allowed this in the properties of the forum |
} else { |
||||||
// The course admin him/herself can do this off course always |
$name=api_get_person_name($post['firstname'], $post['lastname']); |
||||||
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'])."&thread=".Security::remove_XSS($_GET['thread'])."&origin=".$origin."&post=".$post['post_id']."&id_attach=".$id_attach."\">".icon('../img/edit.gif',get_lang('Edit'))."</a>\n"; |
if (api_get_course_setting('allow_user_image_forum')) { |
||||||
} |
echo '<br />'.display_user_image($post['user_id'],$name,$origin).'<br />'; |
||||||
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'])."&thread=".Security::remove_XSS($_GET['thread'])."&action=delete&content=post&id=".$post['post_id']."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang("DeletePost"),ENT_QUOTES,$charset))."')) return false;\">".icon('../img/delete.gif',get_lang('Delete'))."</a>\n"; |
echo display_user_link($post['user_id'], $name, $origin).'<br />'; |
||||||
display_visible_invisible_icon('post', $post['post_id'], $post['visible'],array('forum'=>Security::remove_XSS($_GET['forum']),'thread'=>Security::remove_XSS($_GET['thread']) )); |
echo $post['post_date'].'<br /><br />'; |
||||||
echo "\n"; |
// get attach id |
||||||
if ($count>0) { |
$attachment_list=get_attachment($post['post_id']); |
||||||
|
$id_attach = !empty($attachment_list)?$attachment_list['id']:''; |
||||||
|
// 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']))) { |
||||||
|
echo "<a href=\"editpost.php?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&thread=".Security::remove_XSS($_GET['thread'])."&origin=".$origin."&post=".$post['post_id']."&id_attach=".$id_attach."\">".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'])) { |
||||||
|
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&thread=".Security::remove_XSS($_GET['thread'])."&action=delete&content=post&id=".$post['post_id']."\" onclick=\"javascript:if(!confirm('".addslashes(api_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"; |
||||||
|
if ($count>0) { |
||||||
echo "<a href=\"viewthread.php?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&thread=".Security::remove_XSS($_GET['thread'])."&action=move&origin=".$origin."&post=".$post['post_id']."\">".icon('../img/deplacer_fichier.gif',get_lang('MovePost'))."</a>\n"; |
echo "<a href=\"viewthread.php?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&thread=".Security::remove_XSS($_GET['thread'])."&action=move&origin=".$origin."&post=".$post['post_id']."\">".icon('../img/deplacer_fichier.gif',get_lang('MovePost'))."</a>\n"; |
||||||
} |
} |
||||||
} |
} |
||||||
$userinf=api_get_user_info($post['user_id']); |
$userinf=api_get_user_info($post['user_id']); |
||||||
$user_status=api_get_status_of_user_in_course($post['user_id'],api_get_course_id()); |
$user_status=api_get_status_of_user_in_course($post['user_id'],api_get_course_id()); |
||||||
if (api_is_allowed_to_edit()) { |
if (api_is_allowed_to_edit()) { |
||||||
if ($count>0 && $user_status!=1) { |
if ($count>0 && $user_status!=1) { |
||||||
$current_qualify_thread=show_qualify('1',$_GET['cidReq'],$_GET['forum'],$post['user_id'],$_GET['thread']); |
$current_qualify_thread=show_qualify('1',$_GET['cidReq'],$_GET['forum'],$post['user_id'],$_GET['thread']); |
||||||
echo "<a href=\"forumqualify.php?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&thread=".Security::remove_XSS($_GET['thread'])."&action=list&post=".$post['post_id']."&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 "<a href=\"forumqualify.php?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&thread=".Security::remove_XSS($_GET['thread'])."&action=list&post=".$post['post_id']."&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 />'; |
//echo '<br /><br />'; |
||||||
//if (($current_forum_category['locked']==0 AND $current_forum['locked']==0 AND $current_thread['locked']==0) OR api_is_allowed_to_edit()) |
//if (($current_forum_category['locked']==0 AND $current_forum['locked']==0 AND $current_thread['locked']==0) OR api_is_allowed_to_edit()) |
||||||
if ($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)) { |
||||||
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'])) { |
||||||
if (!api_is_anonymous()) { |
if (!api_is_anonymous()) { |
||||||
echo '<a href="reply.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&thread='.Security::remove_XSS($_GET['thread']).'&post='.$post['post_id'].'&action=replymessage&origin='. $origin .'">'.Display :: return_icon('message_reply_forum.png', get_lang('ReplyToMessage'))."</a>\n"; |
echo '<a href="reply.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&thread='.Security::remove_XSS($_GET['thread']).'&post='.$post['post_id'].'&action=replymessage&origin='. $origin .'">'.Display :: return_icon('message_reply_forum.png', get_lang('ReplyToMessage'))."</a>\n"; |
||||||
echo '<a href="reply.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&thread='.Security::remove_XSS($_GET['thread']).'&post='.$post['post_id'].'&action=quote&origin='. $origin .'">'.Display :: return_icon('lp_thread_forum.gif', get_lang('QuoteMessage'))."</a>\n"; |
echo '<a href="reply.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&thread='.Security::remove_XSS($_GET['thread']).'&post='.$post['post_id'].'&action=quote&origin='. $origin .'">'.Display :: return_icon('quote.gif', get_lang('QuoteMessage'))."</a>\n"; |
||||||
} |
} |
||||||
} |
} |
||||||
} else { |
} else { |
||||||
if ($current_forum_category['locked']==1) { |
if ($current_forum_category['locked']==1) { |
||||||
echo get_lang('ForumcategoryLocked').'<br />'; |
echo get_lang('ForumcategoryLocked').'<br />'; |
||||||
} |
} |
||||||
if ($current_forum['locked']==1) { |
if ($current_forum['locked']==1) { |
||||||
echo get_lang('ForumLocked').'<br />'; |
echo get_lang('ForumLocked').'<br />'; |
||||||
} |
} |
||||||
if ($current_thread['locked']==1) { |
if ($current_thread['locked']==1) { |
||||||
echo get_lang('ThreadLocked').'<br />'; |
echo get_lang('ThreadLocked').'<br />'; |
||||||
} |
} |
||||||
} |
} |
||||||
echo "</td>\n"; |
echo "</td>\n"; |
||||||
// note: this can be removed here because it will be displayed in the tree |
// 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'); |
$post_image=icon('../img/forumpostnew.gif'); |
||||||
} else { |
} else { |
||||||
$post_image=icon('../img/forumpost.gif'); |
$post_image=icon('../img/forumpost.gif'); |
||||||
} |
|
||||||
if ($post['post_notification']=='1' AND $post['poster_id']==$_user['user_id']) { |
|
||||||
$post_image.=icon('../img/forumnotification.gif',get_lang('YouWillBeNotified')); |
|
||||||
} |
} |
||||||
// The post title |
if ($post['post_notification']=='1' AND $post['poster_id']==$_user['user_id']) { |
||||||
echo "\t\t<td class=\"$titleclass\">".prepare4display($post['post_title'])."</td>\n"; |
$post_image.=icon('../img/forumnotification.gif',get_lang('YouWillBeNotified')); |
||||||
|
} |
||||||
|
// The post title |
||||||
|
echo "\t\t<td class=\"$titleclass\">".prepare4display($post['post_title'])."</td>\n"; |
||||||
|
echo "\t</tr>\n"; |
||||||
|
|
||||||
|
// The post message |
||||||
|
echo "\t<tr>\n"; |
||||||
|
echo "\t\t<td class=\"$messageclass\">".prepare4display($post['post_text'])."</td>\n"; |
||||||
echo "\t</tr>\n"; |
echo "\t</tr>\n"; |
||||||
|
|
||||||
// The post message |
|
||||||
echo "\t<tr>\n"; |
|
||||||
echo "\t\t<td class=\"$messageclass\">".prepare4display($post['post_text'])."</td>\n"; |
|
||||||
echo "\t</tr>\n"; |
|
||||||
|
|
||||||
|
// The check if there is an attachment |
||||||
// The check if there is an attachment |
|
||||||
$attachment_list=get_attachment($post['post_id']); |
$attachment_list=get_attachment($post['post_id']); |
||||||
|
|
||||||
if (!empty($attachment_list)) { |
if (!empty($attachment_list)) { |
||||||
echo '<tr><td height="50%">'; |
echo '<tr><td height="50%">'; |
||||||
$realname=$attachment_list['path']; |
$realname=$attachment_list['path']; |
||||||
$user_filename=$attachment_list['filename']; |
$user_filename=$attachment_list['filename']; |
||||||
|
|
||||||
echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
||||||
echo '<a href="download.php?file='; |
echo '<a href="download.php?file='; |
||||||
echo $realname; |
echo $realname; |
||||||
echo ' "> '.$user_filename.' </a>'; |
echo ' "> '.$user_filename.' </a>'; |
||||||
echo '<span class="forum_attach_comment" >'.$attachment_list['comment'].'</span>'; |
echo '<span class="forum_attach_comment" >'.$attachment_list['comment'].'</span>'; |
||||||
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="'.api_get_self().'?'.api_get_cidreq().'&origin='.Security::remove_XSS($_GET['origin']).'&action=delete_attach&id_attach='.$attachment_list['id'].'&forum='.Security::remove_XSS($_GET['forum']).'&thread='.Security::remove_XSS($_GET['thread']).'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)).'\')) return false;">'.Display::return_icon('delete.gif',get_lang('Delete')).'</a><br />'; |
echo ' <a href="'.api_get_self().'?'.api_get_cidreq().'&origin='.Security::remove_XSS($_GET['origin']).'&action=delete_attach&id_attach='.$attachment_list['id'].'&forum='.Security::remove_XSS($_GET['forum']).'&thread='.Security::remove_XSS($_GET['thread']).'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)).'\')) return false;">'.Display::return_icon('delete.gif',get_lang('Delete')).'</a><br />'; |
||||||
} |
} |
||||||
echo '</td></tr>'; |
echo '</td></tr>'; |
||||||
} |
} |
||||||
|
|
||||||
// The post has been displayed => it can be removed from the what's new array |
// 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']][$row['post_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']][$row['post_id']]); |
||||||
echo "</table>\n"; |
echo "</table>\n"; |
||||||
echo "</div>"; |
echo "</div>"; |
||||||
$count++; |
$count++; |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* This function builds an array of all the posts in a given thread where the key of the array is the post_id |
* 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 |
* 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 |
* @return an array containing all the information on the posts of a thread |
||||||
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University |
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University |
||||||
*/ |
*/ |
||||||
function calculate_children($rows) { |
function calculate_children($rows) { |
||||||
foreach($rows as $row) { |
foreach($rows as $row) { |
||||||
$rows_with_children[$row["post_id"]]=$row; |
$rows_with_children[$row["post_id"]]=$row; |
||||||
$rows_with_children[$row["post_parent_id"]]["children"][]=$row["post_id"]; |
$rows_with_children[$row["post_parent_id"]]["children"][]=$row["post_id"]; |
||||||
} |
} |
||||||
$rows=$rows_with_children; |
$rows=$rows_with_children; |
||||||
$sorted_rows=array(0=>array()); |
$sorted_rows=array(0=>array()); |
||||||
_phorum_recursive_sort($rows, $sorted_rows); |
_phorum_recursive_sort($rows, $sorted_rows); |
||||||
unset($sorted_rows[0]); |
unset($sorted_rows[0]); |
||||||
return $sorted_rows; |
return $sorted_rows; |
||||||
} |
} |
||||||
|
|
||||||
function _phorum_recursive_sort($rows, &$threads, $seed=0, $indent=0) { |
function _phorum_recursive_sort($rows, &$threads, $seed=0, $indent=0) { |
||||||
if($seed>0) { |
if($seed>0) { |
||||||
$threads[$rows[$seed]["post_id"]]=$rows[$seed]; |
$threads[$rows[$seed]["post_id"]]=$rows[$seed]; |
||||||
$threads[$rows[$seed]["post_id"]]["indent_cnt"]=$indent; |
$threads[$rows[$seed]["post_id"]]["indent_cnt"]=$indent; |
||||||
$indent++; |
$indent++; |
||||||
} |
} |
||||||
|
|
||||||
if(isset($rows[$seed]["children"])) { |
if(isset($rows[$seed]["children"])) { |
||||||
foreach($rows[$seed]["children"] as $child) { |
foreach($rows[$seed]["children"] as $child) { |
||||||
_phorum_recursive_sort($rows, $threads, $child, $indent); |
_phorum_recursive_sort($rows, $threads, $child, $indent); |
||||||
} |
} |
||||||
} |
} |
||||||
} |
} |
||||||
|
@ -1,384 +1,384 @@ |
|||||||
<?php |
<?php |
||||||
/* |
/* |
||||||
============================================================================== |
============================================================================== |
||||||
Dokeos - elearning and course management software |
Dokeos - elearning and course management software |
||||||
|
|
||||||
Copyright (c) 2006-2008 Dokeos SPRL |
Copyright (c) 2006-2008 Dokeos SPRL |
||||||
Copyright (c) 2006 Ghent University (UGent) |
Copyright (c) 2006 Ghent University (UGent) |
||||||
|
|
||||||
For a full list of contributors, see "credits.txt". |
For a full list of contributors, see "credits.txt". |
||||||
The full license can be read in "license.txt". |
The full license can be read in "license.txt". |
||||||
|
|
||||||
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
||||||
modify it under the terms of the GNU General Public License |
modify it under the terms of the GNU General Public License |
||||||
as published by the Free Software Foundation; either version 2 |
as published by the Free Software Foundation; either version 2 |
||||||
of the License, or (at your option) any later version. |
of the License, or (at your option) any later version. |
||||||
|
|
||||||
See the GNU General Public License for more details. |
See the GNU General Public License for more details. |
||||||
|
|
||||||
Contact address: Dokeos, 108 rue du Corbeau, B-1030 Brussels, Belgium |
Contact address: Dokeos, 108 rue du Corbeau, B-1030 Brussels, Belgium |
||||||
Mail: info@dokeos.com |
Mail: info@dokeos.com |
||||||
============================================================================== |
============================================================================== |
||||||
*/ |
*/ |
||||||
|
|
||||||
/** |
/** |
||||||
* These files are a complete rework of the forum. The database structure is |
* 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 |
* based on phpBB but all the code is rewritten. A lot of new functionalities |
||||||
* are added: |
* are added: |
||||||
* - forum categories and forums can be sorted up or down, locked or made invisible |
* - forum categories and forums can be sorted up or down, locked or made invisible |
||||||
* - consistent and integrated forum administration |
* - consistent and integrated forum administration |
||||||
* - forum options: are students allowed to edit their post? |
* - forum options: are students allowed to edit their post? |
||||||
* moderation of posts (approval) |
* moderation of posts (approval) |
||||||
* reply only forums (students cannot create new threads) |
* reply only forums (students cannot create new threads) |
||||||
* multiple forums per group |
* multiple forums per group |
||||||
* - sticky messages |
* - sticky messages |
||||||
* - new view option: nested view |
* - new view option: nested view |
||||||
* - quoting a message |
* - quoting a message |
||||||
* |
* |
||||||
* @Author Patrick Cool <patrick.cool@UGent.be>, Ghent University |
* @Author Patrick Cool <patrick.cool@UGent.be>, Ghent University |
||||||
* @Copyright Ghent University |
* @Copyright Ghent University |
||||||
* @Copyright Patrick Cool |
* @Copyright Patrick Cool |
||||||
* |
* |
||||||
* @package dokeos.forum |
* @package dokeos.forum |
||||||
*/ |
*/ |
||||||
|
|
||||||
/** |
/** |
||||||
************************************************************************** |
************************************************************************** |
||||||
* IMPORTANT NOTICE |
* IMPORTANT NOTICE |
||||||
* Please do not change anything is this code yet because there are still |
* 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 |
* 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 |
* merge files and test it all over again. So for the moment, please do not |
||||||
* touch the code |
* touch the code |
||||||
* -- Patrick Cool <patrick.cool@UGent.be> |
* -- Patrick Cool <patrick.cool@UGent.be> |
||||||
************************************************************************** |
************************************************************************** |
||||||
*/ |
*/ |
||||||
|
|
||||||
$rows=get_posts($_GET['thread']); // note: this has to be cleaned first |
$rows=get_posts($_GET['thread']); // note: this has to be cleaned first |
||||||
$rows=calculate_children($rows); |
$rows=calculate_children($rows); |
||||||
|
|
||||||
if ($_GET['post']) |
if ($_GET['post']) |
||||||
{ |
{ |
||||||
$display_post_id=Security::remove_XSS($_GET['post']); // note: this has to be cleaned first |
$display_post_id=Security::remove_XSS($_GET['post']); // note: this has to be cleaned first |
||||||
} |
} |
||||||
else |
else |
||||||
{ |
{ |
||||||
// we need to display the first post |
// we need to display the first post |
||||||
reset($rows); |
reset($rows); |
||||||
$current=current($rows); |
$current=current($rows); |
||||||
$display_post_id=$current['post_id']; |
$display_post_id=$current['post_id']; |
||||||
} |
} |
||||||
|
|
||||||
//are we in a lp ? |
//are we in a lp ? |
||||||
$origin = ''; |
$origin = ''; |
||||||
if(isset($_GET['origin'])) |
if(isset($_GET['origin'])) |
||||||
{ |
{ |
||||||
$origin = Security::remove_XSS($_GET['origin']); |
$origin = Security::remove_XSS($_GET['origin']); |
||||||
} |
} |
||||||
|
|
||||||
//delete attachment file |
//delete attachment file |
||||||
if ((isset($_GET['action']) && $_GET['action']=='delete_attach') && isset($_GET['id_attach'])) { |
if ((isset($_GET['action']) && $_GET['action']=='delete_attach') && isset($_GET['id_attach'])) { |
||||||
delete_attachment(0,$_GET['id_attach']); |
delete_attachment(0,$_GET['id_attach']); |
||||||
} |
} |
||||||
// -------------------------------------- |
// -------------------------------------- |
||||||
// Displaying the thread (structure) |
// Displaying the thread (structure) |
||||||
// -------------------------------------- |
// -------------------------------------- |
||||||
$thread_structure="<div class=\"structure\">".get_lang('Structure')."</div>"; |
$thread_structure="<div class=\"structure\">".get_lang('Structure')."</div>"; |
||||||
$counter=0; |
$counter=0; |
||||||
$count=0; |
$count=0; |
||||||
$prev_next_array=array(); |
$prev_next_array=array(); |
||||||
foreach ($rows as $post) |
foreach ($rows as $post) |
||||||
{ |
{ |
||||||
$counter++; |
$counter++; |
||||||
$indent=$post['indent_cnt']*'20'; |
$indent=$post['indent_cnt']*'20'; |
||||||
$thread_structure.= "<div style=\"margin-left: ".$indent."px;\">"; |
$thread_structure.= "<div style=\"margin-left: ".$indent."px;\">"; |
||||||
|
|
||||||
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'); |
$post_image=icon('../img/forumpostnew.gif'); |
||||||
} |
} |
||||||
else |
else |
||||||
{ |
{ |
||||||
$post_image=icon('../img/forumpost.gif'); |
$post_image=icon('../img/forumpost.gif'); |
||||||
} |
} |
||||||
$thread_structure.= $post_image; |
$thread_structure.= $post_image; |
||||||
if ($_GET['post']==$post['post_id'] OR ($counter==1 AND !isset($_GET['post']))) |
if ($_GET['post']==$post['post_id'] OR ($counter==1 AND !isset($_GET['post']))) |
||||||
{ |
{ |
||||||
$thread_structure.='<strong>'.prepare4display($post['post_title']).'</strong></div>'; |
$thread_structure.='<strong>'.prepare4display($post['post_title']).'</strong></div>'; |
||||||
$prev_next_array[]=$post['post_id']; |
$prev_next_array[]=$post['post_id']; |
||||||
} |
} |
||||||
else |
else |
||||||
{ |
{ |
||||||
if ($post['visible']=='0') |
if ($post['visible']=='0') |
||||||
{ |
{ |
||||||
$class=' class="invisible"'; |
$class=' class="invisible"'; |
||||||
} |
} |
||||||
else |
else |
||||||
{ |
{ |
||||||
$class=''; |
$class=''; |
||||||
} |
} |
||||||
$count_loop=($count==0)?'&id=1' : ''; |
$count_loop=($count==0)?'&id=1' : ''; |
||||||
$thread_structure.= "<a href=\"viewthread.php?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&thread=".Security::remove_XSS($_GET['thread'])."&post=".$post['post_id']."&origin=$origin$count_loop\" $class>".prepare4display($post['post_title'])."</a></div>\n"; |
$thread_structure.= "<a href=\"viewthread.php?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&thread=".Security::remove_XSS($_GET['thread'])."&post=".$post['post_id']."&origin=$origin$count_loop\" $class>".prepare4display($post['post_title'])."</a></div>\n"; |
||||||
$prev_next_array[]=$post['post_id']; |
$prev_next_array[]=$post['post_id']; |
||||||
} |
} |
||||||
$count++; |
$count++; |
||||||
} |
} |
||||||
|
|
||||||
/*-------------------------------------------------- |
/*-------------------------------------------------- |
||||||
NAVIGATION CONTROLS |
NAVIGATION CONTROLS |
||||||
---------------------------------------------------- |
---------------------------------------------------- |
||||||
*/ |
*/ |
||||||
|
|
||||||
$current_id=array_search($display_post_id,$prev_next_array); |
$current_id=array_search($display_post_id,$prev_next_array); |
||||||
$max=count($prev_next_array); |
$max=count($prev_next_array); |
||||||
$next_id=$current_id+1; |
$next_id=$current_id+1; |
||||||
$prev_id=$current_id-1; |
$prev_id=$current_id-1; |
||||||
|
|
||||||
// text |
// text |
||||||
$first_message=get_lang('FirstMessage'); |
$first_message=get_lang('FirstMessage'); |
||||||
$last_message=get_lang('LastMessage'); |
$last_message=get_lang('LastMessage'); |
||||||
$next_message=get_lang('NextMessage'); |
$next_message=get_lang('NextMessage'); |
||||||
$prev_message=get_lang('PrevMessage'); |
$prev_message=get_lang('PrevMessage'); |
||||||
|
|
||||||
// images |
// images |
||||||
$first_img = Display::return_icon('first.png',get_lang(''),array('style'=>'vertical-align: middle;')); |
$first_img = Display::return_icon('first.png',get_lang(''),array('style'=>'vertical-align: middle;')); |
||||||
$last_img = Display::return_icon('last.png',get_lang(''),array('style'=>'vertical-align: middle;')); |
$last_img = Display::return_icon('last.png',get_lang(''),array('style'=>'vertical-align: middle;')); |
||||||
$prev_img = Display::return_icon('prev.png',get_lang(''),array('style'=>'vertical-align: middle;')); |
$prev_img = Display::return_icon('prev.png',get_lang(''),array('style'=>'vertical-align: middle;')); |
||||||
$next_img = Display::return_icon('next.png',get_lang(''),array('style'=>'vertical-align: middle;')); |
$next_img = Display::return_icon('next.png',get_lang(''),array('style'=>'vertical-align: middle;')); |
||||||
|
|
||||||
// links |
// links |
||||||
$first_href = 'viewthread.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&thread='.Security::remove_XSS($_GET['thread']).'&gradebook='.$gradebook.'&origin='.$origin.'&id=1&post='.$prev_next_array[0]; |
$first_href = 'viewthread.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&thread='.Security::remove_XSS($_GET['thread']).'&gradebook='.$gradebook.'&origin='.$origin.'&id=1&post='.$prev_next_array[0]; |
||||||
$last_href = 'viewthread.php?'.api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&thread=".Security::remove_XSS($_GET['thread'])."&gradebook='.$gradebook.'&origin=".$origin."&post=".$prev_next_array[$max-1]; |
$last_href = 'viewthread.php?'.api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&thread=".Security::remove_XSS($_GET['thread'])."&gradebook='.$gradebook.'&origin=".$origin."&post=".$prev_next_array[$max-1]; |
||||||
$prev_href = 'viewthread.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&thread='.Security::remove_XSS($_GET['thread']).'&gradebook='.$gradebook.'&origin='.$origin.'&post='.$prev_next_array[$prev_id]; |
$prev_href = 'viewthread.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&thread='.Security::remove_XSS($_GET['thread']).'&gradebook='.$gradebook.'&origin='.$origin.'&post='.$prev_next_array[$prev_id]; |
||||||
$next_href = 'viewthread.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&thread='.Security::remove_XSS($_GET['thread']).'&gradebook='.$gradebook.'&origin='.$origin.'&post='.$prev_next_array[$next_id]; |
$next_href = 'viewthread.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&thread='.Security::remove_XSS($_GET['thread']).'&gradebook='.$gradebook.'&origin='.$origin.'&post='.$prev_next_array[$next_id]; |
||||||
|
|
||||||
echo '<center>'; |
echo '<center>'; |
||||||
//go to: first and previous |
//go to: first and previous |
||||||
if ((int)$current_id > 0) |
if ((int)$current_id > 0) |
||||||
{ |
{ |
||||||
echo '<a href="'.$first_href.'" '.$class.' title='.$first_message.'>'.$first_img.' '.$first_message.'</a>'; |
echo '<a href="'.$first_href.'" '.$class.' title='.$first_message.'>'.$first_img.' '.$first_message.'</a>'; |
||||||
echo '<a href="'.$prev_href.'" '.$class_prev.' title='.$prev_message.'>'.$prev_img.' '.$prev_message.'</a>'; |
echo '<a href="'.$prev_href.'" '.$class_prev.' title='.$prev_message.'>'.$prev_img.' '.$prev_message.'</a>'; |
||||||
} |
} |
||||||
|
else |
||||||
|
{ |
||||||
|
echo '<b><span class="invisible">'.$first_img.' '.$first_message.'</b></span>'; |
||||||
|
echo '<b><span class="invisible">'.$prev_img.' '.$prev_message.'</b></span>'; |
||||||
|
} |
||||||
|
|
||||||
|
// current counter |
||||||
|
echo ' [ '.($current_id+1).' / '.$max.' ] '; |
||||||
|
|
||||||
|
// go to: next and last |
||||||
|
if (($current_id+1) < $max) |
||||||
|
{ |
||||||
|
echo '<a href="'.$next_href.'" '.$class_next.' title='.$next_message.'>'.$next_message.' '.$next_img.'</a>'; |
||||||
|
echo '<a href="'.$last_href.'" '.$class.' title='.$last_message.'>'.$last_message.' '.$last_img.'</a>'; |
||||||
|
} |
||||||
else |
else |
||||||
{ |
{ |
||||||
echo '<b><span class="invisible">'.$first_img.' '.$first_message.'</b></span>'; |
echo '<b><span class="invisible">'.$next_message.' '.$next_img.'</b></span>'; |
||||||
echo '<b><span class="invisible">'.$prev_img.' '.$prev_message.'</b></span>'; |
echo '<b><span class="invisible">'.$last_message.' '.$last_img.'</b></span>'; |
||||||
} |
} |
||||||
|
echo '</center>'; |
||||||
// current counter |
|
||||||
echo ' [ '.($current_id+1).' / '.$max.' ] '; |
//-------------------------------------------------------------------------------------------- |
||||||
|
|
||||||
// go to: next and last |
// the style depends on the status of the message: approved or not |
||||||
if (($current_id+1) < $max) |
if ($rows[$display_post_id]['visible']=='0') |
||||||
{ |
{ |
||||||
echo '<a href="'.$next_href.'" '.$class_next.' title='.$next_message.'>'.$next_message.' '.$next_img.'</a>'; |
$titleclass='forum_message_post_title_2_be_approved'; |
||||||
echo '<a href="'.$last_href.'" '.$class.' title='.$last_message.'>'.$last_message.' '.$last_img.'</a>'; |
$messageclass='forum_message_post_text_2_be_approved'; |
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
echo '<b><span class="invisible">'.$next_message.' '.$next_img.'</b></span>'; |
|
||||||
echo '<b><span class="invisible">'.$last_message.' '.$last_img.'</b></span>'; |
|
||||||
} |
|
||||||
echo '</center>'; |
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------------- |
|
||||||
|
|
||||||
// the style depends on the status of the message: approved or not |
|
||||||
if ($rows[$display_post_id]['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'; |
$leftclass='forum_message_left_2_be_approved'; |
||||||
} |
} |
||||||
else |
else |
||||||
{ |
{ |
||||||
$titleclass='forum_message_post_title'; |
$titleclass='forum_message_post_title'; |
||||||
$messageclass='forum_message_post_text'; |
$messageclass='forum_message_post_text'; |
||||||
$leftclass='forum_message_left'; |
$leftclass='forum_message_left'; |
||||||
} |
} |
||||||
|
|
||||||
// -------------------------------------- |
// -------------------------------------- |
||||||
// Displaying the message |
// Displaying the message |
||||||
// -------------------------------------- |
// -------------------------------------- |
||||||
|
|
||||||
// we mark the image we are displaying as set |
// we mark the image we are displaying as set |
||||||
unset($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$rows[$display_post_id]['post_id']]); |
unset($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$rows[$display_post_id]['post_id']]); |
||||||
|
|
||||||
echo "<table width=\"100%\" class=\"post\" cellspacing=\"5\" border=\"0\">\n"; |
echo "<table width=\"100%\" class=\"post\" cellspacing=\"5\" border=\"0\">\n"; |
||||||
echo "\t<tr>\n"; |
echo "\t<tr>\n"; |
||||||
echo "\t\t<td rowspan=\"3\" class=\"$leftclass\">"; |
echo "\t\t<td rowspan=\"3\" class=\"$leftclass\">"; |
||||||
if ($rows[$display_post_id]['user_id']=='0') |
if ($rows[$display_post_id]['user_id']=='0') |
||||||
{ |
{ |
||||||
$name=prepare4display($rows[$display_post_id]['poster_name']); |
$name=prepare4display($rows[$display_post_id]['poster_name']); |
||||||
} |
} |
||||||
else |
else |
||||||
{ |
{ |
||||||
$name=api_get_person_name($rows[$display_post_id]['firstname'], $rows[$display_post_id]['lastname']); |
$name=api_get_person_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, $origin).'<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 display_user_link($rows[$display_post_id]['user_id'], $name, $origin).'<br />'; |
||||||
echo $rows[$display_post_id]['post_date'].'<br /><br />'; |
echo $rows[$display_post_id]['post_date'].'<br /><br />'; |
||||||
// get attach id |
// get attach id |
||||||
$attachment_list=get_attachment($display_post_id); |
$attachment_list=get_attachment($display_post_id); |
||||||
$id_attach = !empty($attachment_list)?$attachment_list['id']:''; |
$id_attach = !empty($attachment_list)?$attachment_list['id']:''; |
||||||
|
|
||||||
// The user who posted it can edit his thread only if the course admin allowed this in the properties of the forum |
// 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 |
// The course admin him/herself can do this off course always |
||||||
if (($current_forum['allow_edit']==1 AND $rows[$display_post_id]['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 $rows[$display_post_id]['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'])."&thread=".Security::remove_XSS($_GET['thread'])."&origin=".$origin."&post=".$rows[$display_post_id]['post_id']."&id_attach=".$id_attach."\">".icon('../img/edit.gif',get_lang('Edit'))."</a>\n"; |
echo "<a href=\"editpost.php?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&thread=".Security::remove_XSS($_GET['thread'])."&origin=".$origin."&post=".$rows[$display_post_id]['post_id']."&id_attach=".$id_attach."\">".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'])."&thread=".Security::remove_XSS($_GET['thread'])."&action=delete&content=post&id=".$rows[$display_post_id]['post_id']."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang("DeletePost"),ENT_QUOTES,$charset))."')) return false;\">".icon('../img/delete.gif',get_lang('Delete'))."</a>\n"; |
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&thread=".Security::remove_XSS($_GET['thread'])."&action=delete&content=post&id=".$rows[$display_post_id]['post_id']."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang("DeletePost"),ENT_QUOTES,$charset))."')) return false;\">".icon('../img/delete.gif',get_lang('Delete'))."</a>\n"; |
||||||
display_visible_invisible_icon('post', $rows[$display_post_id]['post_id'], $rows[$display_post_id]['visible'],array('forum'=>Security::remove_XSS($_GET['forum']),'thread'=>Security::remove_XSS($_GET['thread']), 'post'=>Security::remove_XSS($_GET['post']) )); |
display_visible_invisible_icon('post', $rows[$display_post_id]['post_id'], $rows[$display_post_id]['visible'],array('forum'=>Security::remove_XSS($_GET['forum']),'thread'=>Security::remove_XSS($_GET['thread']), 'post'=>Security::remove_XSS($_GET['post']) )); |
||||||
echo "\n"; |
echo "\n"; |
||||||
//verified the post minor |
//verified the post minor |
||||||
$my_post=get_posts($_GET['thread']); |
$my_post=get_posts($_GET['thread']); |
||||||
$id_posts=array(); |
$id_posts=array(); |
||||||
|
|
||||||
foreach ($my_post as $post_value) { |
foreach ($my_post as $post_value) { |
||||||
$id_posts[]=$post_value['post_id']; |
$id_posts[]=$post_value['post_id']; |
||||||
} |
} |
||||||
|
|
||||||
sort($id_posts,SORT_NUMERIC); |
sort($id_posts,SORT_NUMERIC); |
||||||
reset($id_posts); |
reset($id_posts); |
||||||
//the post minor |
//the post minor |
||||||
$post_minor=(int)$id_posts[0]; |
$post_minor=(int)$id_posts[0]; |
||||||
$post_id = isset($_GET['post'])?(int)$_GET['post']:0; |
$post_id = isset($_GET['post'])?(int)$_GET['post']:0; |
||||||
if (!isset($_GET['id']) && $post_id>$post_minor) { |
if (!isset($_GET['id']) && $post_id>$post_minor) { |
||||||
echo "<a href=\"viewthread.php?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&thread=".Security::remove_XSS($_GET['thread'])."&origin=".$origin."&action=move&post=".$rows[$display_post_id]['post_id']."\">".icon('../img/deplacer_fichier.gif',get_lang('MovePost'))."</a>\n"; |
echo "<a href=\"viewthread.php?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&thread=".Security::remove_XSS($_GET['thread'])."&origin=".$origin."&action=move&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']); |
$userinf=api_get_user_info($rows[$display_post_id]['user_id']); |
||||||
$user_status=api_get_status_of_user_in_course($rows[$display_post_id]['user_id'],api_get_course_id()); |
$user_status=api_get_status_of_user_in_course($rows[$display_post_id]['user_id'],api_get_course_id()); |
||||||
if (api_is_allowed_to_edit()) { |
if (api_is_allowed_to_edit()) { |
||||||
if($post_id>$post_minor ) |
if($post_id>$post_minor ) |
||||||
{ |
{ |
||||||
if($user_status!=1) |
if($user_status!=1) |
||||||
{ |
{ |
||||||
$current_qualify_thread=show_qualify('1',$_GET['cidReq'],$_GET['forum'],$rows[$display_post_id]['user_id'],$_GET['thread']); |
$current_qualify_thread=show_qualify('1',$_GET['cidReq'],$_GET['forum'],$rows[$display_post_id]['user_id'],$_GET['thread']); |
||||||
echo "<a href=\"forumqualify.php?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&thread=".Security::remove_XSS($_GET['thread'])."&action=list&post=".$rows[$display_post_id]['post_id']."&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 "<a href=\"forumqualify.php?".api_get_cidreq()."&forum=".Security::remove_XSS($_GET['forum'])."&thread=".Security::remove_XSS($_GET['thread'])."&action=list&post=".$rows[$display_post_id]['post_id']."&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 />'; |
//echo '<br /><br />'; |
||||||
//if (($current_forum_category['locked']==0 AND $current_forum['locked']==0 AND $current_thread['locked']==0) OR api_is_allowed_to_edit()) |
//if (($current_forum_category['locked']==0 AND $current_forum['locked']==0 AND $current_thread['locked']==0) OR api_is_allowed_to_edit()) |
||||||
if ($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)) |
||||||
{ |
{ |
||||||
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'])) |
||||||
{ |
{ |
||||||
if (!api_is_anonymous()) { |
if (!api_is_anonymous()) { |
||||||
echo '<a href="reply.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&thread='.Security::remove_XSS($_GET['thread']).'&post='.$rows[$display_post_id]['post_id'].'&action=replymessage&origin='. $origin .'">'.Display :: return_icon('message_reply_forum.png', get_lang('ReplyToMessage'))."</a>\n"; |
echo '<a href="reply.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&thread='.Security::remove_XSS($_GET['thread']).'&post='.$rows[$display_post_id]['post_id'].'&action=replymessage&origin='. $origin .'">'.Display :: return_icon('message_reply_forum.png', get_lang('ReplyToMessage'))."</a>\n"; |
||||||
echo '<a href="reply.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&thread='.Security::remove_XSS($_GET['thread']).'&post='.$rows[$display_post_id]['post_id'].'&action=quote&origin='. $origin .'">'.Display :: return_icon('lp_thread_forum.gif', get_lang('QuoteMessage'))."</a>\n"; |
echo '<a href="reply.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&thread='.Security::remove_XSS($_GET['thread']).'&post='.$rows[$display_post_id]['post_id'].'&action=quote&origin='. $origin .'">'.Display :: return_icon('quote.gif', get_lang('QuoteMessage'))."</a>\n"; |
||||||
} |
} |
||||||
} |
} |
||||||
} |
} |
||||||
else |
else |
||||||
{ |
{ |
||||||
if ($current_forum_category['locked']==1) |
if ($current_forum_category['locked']==1) |
||||||
{ |
{ |
||||||
echo get_lang('ForumcategoryLocked').'<br />'; |
echo get_lang('ForumcategoryLocked').'<br />'; |
||||||
} |
} |
||||||
if ($current_forum['locked']==1) |
if ($current_forum['locked']==1) |
||||||
{ |
{ |
||||||
echo get_lang('ForumLocked').'<br />'; |
echo get_lang('ForumLocked').'<br />'; |
||||||
} |
} |
||||||
if ($current_thread['locked']==1) |
if ($current_thread['locked']==1) |
||||||
{ |
{ |
||||||
echo get_lang('ThreadLocked').'<br />'; |
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']][$rows[$display_post_id]['post_id']]) and !empty($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$rows[$display_post_id]['post_id']]) and !empty($whatsnew_post_info[$_GET['forum']][$rows[$display_post_id]['thread_id']])) |
||||||
|
{ |
||||||
|
$post_image=icon('../img/forumpostnew.gif'); |
||||||
} |
} |
||||||
} |
|
||||||
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']][$rows[$display_post_id]['post_id']]) and !empty($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$rows[$display_post_id]['post_id']]) and !empty($whatsnew_post_info[$_GET['forum']][$rows[$display_post_id]['thread_id']])) |
|
||||||
{ |
|
||||||
$post_image=icon('../img/forumpostnew.gif'); |
|
||||||
} |
|
||||||
else |
else |
||||||
{ |
{ |
||||||
$post_image=icon('../img/forumpost.gif'); |
$post_image=icon('../img/forumpost.gif'); |
||||||
} |
} |
||||||
if ($rows[$display_post_id]['post_notification']=='1' AND $rows[$display_post_id]['poster_id']==$_user['user_id']) |
if ($rows[$display_post_id]['post_notification']=='1' AND $rows[$display_post_id]['poster_id']==$_user['user_id']) |
||||||
{ |
{ |
||||||
$post_image.=icon('../img/forumnotification.gif',get_lang('YouWillBeNotified')); |
$post_image.=icon('../img/forumnotification.gif',get_lang('YouWillBeNotified')); |
||||||
} |
} |
||||||
// The post title |
// The post title |
||||||
echo "\t\t<td class=\"$titleclass\">".prepare4display($rows[$display_post_id]['post_title'])."</td>\n"; |
echo "\t\t<td class=\"$titleclass\">".prepare4display($rows[$display_post_id]['post_title'])."</td>\n"; |
||||||
echo "\t</tr>\n"; |
echo "\t</tr>\n"; |
||||||
|
|
||||||
// The post message |
// The post message |
||||||
echo "\t<tr>\n"; |
echo "\t<tr>\n"; |
||||||
echo "\t\t<td class=\"$messageclass\">".prepare4display($rows[$display_post_id]['post_text'])."</td>\n"; |
echo "\t\t<td class=\"$messageclass\">".prepare4display($rows[$display_post_id]['post_text'])."</td>\n"; |
||||||
echo "\t</tr>\n"; |
echo "\t</tr>\n"; |
||||||
|
|
||||||
// The check if there is an attachment |
// The check if there is an attachment |
||||||
$attachment_list=get_attachment($display_post_id); |
$attachment_list=get_attachment($display_post_id); |
||||||
|
|
||||||
if (!empty($attachment_list)) |
if (!empty($attachment_list)) |
||||||
{ |
{ |
||||||
echo '<tr><td height="50%">'; |
echo '<tr><td height="50%">'; |
||||||
$realname=$attachment_list['path']; |
$realname=$attachment_list['path']; |
||||||
$user_filename=$attachment_list['filename']; |
$user_filename=$attachment_list['filename']; |
||||||
|
|
||||||
echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
||||||
echo '<a href="download.php?file='; |
echo '<a href="download.php?file='; |
||||||
echo $realname; |
echo $realname; |
||||||
echo ' "> '.$user_filename.' </a>'; |
echo ' "> '.$user_filename.' </a>'; |
||||||
echo '<span class="forum_attach_comment" >'.$attachment_list['comment'].'</span>'; |
echo '<span class="forum_attach_comment" >'.$attachment_list['comment'].'</span>'; |
||||||
if (($current_forum['allow_edit']==1 AND $rows[$display_post_id]['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 $rows[$display_post_id]['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="'.api_get_self().'?'.api_get_cidreq().'&origin='.Security::remove_XSS($_GET['origin']).'&action=delete_attach&id_attach='.$attachment_list['id'].'&forum='.Security::remove_XSS($_GET['forum']).'&thread='.Security::remove_XSS($_GET['thread']).'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)).'\')) return false;">'.Display::return_icon('delete.gif',get_lang('Delete')).'</a><br />'; |
echo ' <a href="'.api_get_self().'?'.api_get_cidreq().'&origin='.Security::remove_XSS($_GET['origin']).'&action=delete_attach&id_attach='.$attachment_list['id'].'&forum='.Security::remove_XSS($_GET['forum']).'&thread='.Security::remove_XSS($_GET['thread']).'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)).'\')) return false;">'.Display::return_icon('delete.gif',get_lang('Delete')).'</a><br />'; |
||||||
} |
} |
||||||
echo '</td></tr>'; |
echo '</td></tr>'; |
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// The post has been displayed => it can be removed from the what's new array |
// 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']][$row['post_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']][$row['post_id']]); |
||||||
echo "</table>"; |
echo "</table>"; |
||||||
|
|
||||||
// -------------------------------------- |
// -------------------------------------- |
||||||
// Displaying the thread (structure) |
// Displaying the thread (structure) |
||||||
// -------------------------------------- |
// -------------------------------------- |
||||||
|
|
||||||
echo $thread_structure; |
echo $thread_structure; |
||||||
|
|
||||||
|
|
||||||
/** |
/** |
||||||
* This function builds an array of all the posts in a given thread where the key of the array is the post_id |
* 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 |
* 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 |
* @return an array containing all the information on the posts of a thread |
||||||
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University |
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University |
||||||
*/ |
*/ |
||||||
function calculate_children($rows) |
function calculate_children($rows) |
||||||
{ |
{ |
||||||
foreach($rows as $row) |
foreach($rows as $row) |
||||||
{ |
{ |
||||||
$rows_with_children[$row["post_id"]]=$row; |
$rows_with_children[$row["post_id"]]=$row; |
||||||
$rows_with_children[$row["post_parent_id"]]["children"][]=$row["post_id"]; |
$rows_with_children[$row["post_parent_id"]]["children"][]=$row["post_id"]; |
||||||
} |
} |
||||||
$rows=$rows_with_children; |
$rows=$rows_with_children; |
||||||
$sorted_rows=array(0=>array()); |
$sorted_rows=array(0=>array()); |
||||||
_phorum_recursive_sort($rows, $sorted_rows); |
_phorum_recursive_sort($rows, $sorted_rows); |
||||||
unset($sorted_rows[0]); |
unset($sorted_rows[0]); |
||||||
return $sorted_rows; |
return $sorted_rows; |
||||||
} |
} |
||||||
|
|
||||||
function _phorum_recursive_sort($rows, &$threads, $seed=0, $indent=0) |
function _phorum_recursive_sort($rows, &$threads, $seed=0, $indent=0) |
||||||
{ |
{ |
||||||
if($seed>0) |
if($seed>0) |
||||||
{ |
{ |
||||||
$threads[$rows[$seed]["post_id"]]=$rows[$seed]; |
$threads[$rows[$seed]["post_id"]]=$rows[$seed]; |
||||||
$threads[$rows[$seed]["post_id"]]["indent_cnt"]=$indent; |
$threads[$rows[$seed]["post_id"]]["indent_cnt"]=$indent; |
||||||
$indent++; |
$indent++; |
||||||
} |
} |
||||||
|
|
||||||
if(isset($rows[$seed]["children"])) |
if(isset($rows[$seed]["children"])) |
||||||
{ |
{ |
||||||
foreach($rows[$seed]["children"] as $child) |
foreach($rows[$seed]["children"] as $child) |
||||||
{ |
{ |
||||||
_phorum_recursive_sort($rows, $threads, $child, $indent); |
_phorum_recursive_sort($rows, $threads, $child, $indent); |
||||||
} |
} |
||||||
} |
} |
||||||
} |
} |
||||||
|
After Width: | Height: | Size: 330 B |
Loading…
Reference in new issue