Minor - fixing PHP warnings, format code.

1.9.x
Julio Montoya 11 years ago
parent 65bebfba32
commit 1e6e4d37f5
  1. 78
      main/forum/viewforum.php
  2. 4
      main/forum/viewpost.inc.php
  3. 2
      main/forum/viewpost.php
  4. 8
      main/forum/viewthread.php
  5. 37
      main/forum/viewthread_nested.inc.php
  6. 69
      main/forum/viewthread_threaded.inc.php

@ -24,7 +24,6 @@
use \ChamiloSession as Session;
// Language files that need to be included.
$language_file = array('forum', 'group');
@ -56,7 +55,7 @@ $userid = api_get_user_id();
/* MAIN DISPLAY SECTION */
$group_id = api_get_group_id();
$groupId = api_get_group_id();
$my_forum = isset($_GET['forum']) ? $_GET['forum'] : '';
// Note: This has to be validated that it is an existing forum.
$current_forum = get_forum_information($my_forum);
@ -66,21 +65,21 @@ if (empty($current_forum)) {
}
$current_forum_category = get_forumcategory_information($current_forum['forum_category']);
$is_group_tutor = false;
if (!empty($group_id)) {
if (!empty($groupId)) {
//Group info & group category info
$group_properties = GroupManager::get_group_properties($group_id);
$group_properties = GroupManager::get_group_properties($groupId);
//User has access in the group?
$user_has_access_in_group = GroupManager::user_has_access($userid, $group_id, GroupManager::GROUP_TOOL_FORUM);
$user_has_access_in_group = GroupManager::user_has_access($userid, $groupId, GroupManager::GROUP_TOOL_FORUM);
$is_group_tutor = GroupManager::is_tutor_of_group(api_get_user_id(), $group_id);
$is_group_tutor = GroupManager::is_tutor_of_group(api_get_user_id(), $groupId);
//Course
if (!api_is_allowed_to_edit(false, true) AND //is a student
(($current_forum_category && $current_forum_category['visibility'] == 0) OR $current_forum['visibility'] == 0 OR !$user_has_access_in_group)
(($current_forum_category && $current_forum_category['visibility'] == 0) OR
$current_forum['visibility'] == 0 OR !$user_has_access_in_group)
) {
api_not_allowed();
}
@ -116,13 +115,15 @@ if (!empty($_GET['gidReq'])) {
Session::write('toolgroup',$toolgroup);
}
$forumUrl = api_get_path(WEB_CODE_PATH).'forum/';
if ($origin == 'group') {
$interbreadcrumb[] = array('url' => '../group/group.php', 'name' => get_lang('Groups'));
$interbreadcrumb[] = array('url'=>'../group/group_space.php?gidReq='.$_SESSION['toolgroup'], 'name'=> get_lang('GroupSpace').' '.$group_properties['name']);
$interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'group/group.php', 'name' => get_lang('Groups'));
$interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(), 'name'=> get_lang('GroupSpace').' '.$group_properties['name']);
$interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Forum').' '.Security::remove_XSS($current_forum['forum_title']));
} else {
$interbreadcrumb[] = array('url' => 'index.php?search='.Security::remove_XSS($my_search), 'name' => get_lang('ForumCategories'));
$interbreadcrumb[] = array('url' => 'viewforumcategory.php?forumcategory='.$current_forum_category['cat_id'].'&search='.Security::remove_XSS(urlencode($my_search)), 'name' => prepare4display($current_forum_category['cat_title']));
$interbreadcrumb[] = array('url' => $forumUrl.'index.php?search='.Security::remove_XSS($my_search), 'name' => get_lang('ForumCategories'));
$interbreadcrumb[] = array('url' => $forumUrl.'viewforumcategory.php?forumcategory='.$current_forum_category['cat_id'].'&search='.Security::remove_XSS(urlencode($my_search)), 'name' => prepare4display($current_forum_category['cat_title']));
$interbreadcrumb[] = array('url' => '#', 'name' => Security::remove_XSS($current_forum['forum_title']));
}
@ -194,12 +195,18 @@ if ($my_action == 'liststd' AND isset($_GET['content']) AND isset($_GET['id']) A
if ($nrorow3 > 0 || $nrorow3 == -2) {
$url = 'cidReq='.Security::remove_XSS($_GET['cidReq']).'&forum='.Security::remove_XSS($my_forum).'&action='.Security::remove_XSS($_GET['action']).'&content='.Security::remove_XSS($_GET['content'],STUDENT).'&id='.intval($_GET['id']);
$tabs = array(
array('content' => get_lang('AllStudents'),
'url' => 'viewforum.php?'.$url.'&origin='.$origin.'&list=all'),
array('content' => get_lang('StudentsQualified'),
'url' => 'viewforum.php?'.$url.'&origin='.$origin.'&list=qualify'),
array('content' => get_lang('StudentsNotQualified'),
'url' => 'viewforum.php?'.$url.'&origin='.$origin.'&list=notqualify'),
array(
'content' => get_lang('AllStudents'),
'url' => $forumUrl.'viewforum.php?'.$url.'&origin='.$origin.'&list=all'
),
array(
'content' => get_lang('StudentsQualified'),
'url' => $forumUrl.'viewforum.php?'.$url.'&origin='.$origin.'&list=qualify'
),
array(
'content' => get_lang('StudentsNotQualified'),
'url' => $forumUrl.'viewforum.php?'.$url.'&origin='.$origin.'&list=notqualify'
),
);
$table_list .= Display::tabs_only_link($tabs, $active);
@ -227,13 +234,16 @@ if ($my_action == 'liststd' AND isset($_GET['content']) AND isset($_GET['id']) A
$class_stdlist = 'row_even';
}
$name_user_theme = api_get_person_name($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'].'&amp;tipo=sdtlist&amp;'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($my_forum).$origin_string.'">'.$name_user_theme.'</a></td>';
$table_list .= '<tr class="'.$class_stdlist.'"><td>
<a href="'.api_get_path(WEB_CODE_PATH).'user/userInfo.php?uInfo='.$row_student_list['user_id'].'&amp;tipo=sdtlist&amp;'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($my_forum).$origin_string.'">
'.$name_user_theme.'</a></td>';
if ($_GET['list'] == 'qualify') {
$table_list .= '<td>'.$row_student_list['qualify'].'/'.$max_qualify.'</td>';
}
if (api_is_allowed_to_edit(null, true)) {
$current_qualify_thread = show_qualify('1', $row_student_list['user_id'], $_GET['id']);
$table_list .= '<td><a href="forumqualify.php?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($my_forum).'&amp;thread='.Security::remove_XSS($_GET['id']).'&amp;user='.$row_student_list['user_id'].'&amp;user_id='.$row_student_list['user_id'].'&amp;idtextqualify='.$current_qualify_thread.'&amp;origin='.$origin.'">'.Display::return_icon($icon_qualify, get_lang('Qualify')).'</a></td></tr>';
$table_list .= '<td><a href="'.$forumUrl.'forumqualify.php?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($my_forum).'&amp;thread='.Security::remove_XSS($_GET['id']).'&amp;user='.$row_student_list['user_id'].'&amp;user_id='.$row_student_list['user_id'].'&amp;idtextqualify='.$current_qualify_thread.'&amp;origin='.$origin.'">'.
Display::return_icon($icon_qualify, get_lang('Qualify')).'</a></td></tr>';
}
$counter_stdlist++;
}
@ -269,14 +279,13 @@ echo '<div class="actions">';
if ($origin != 'learnpath') {
if ($origin=='group') {
echo '<a href="../group/group_space.php?'.api_get_cidreq().'&amp;gradebook='.$gradebook.'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('Groups'),'',ICON_SIZE_MEDIUM).'</a>';
echo '<a href='.api_get_path(WEB_CODE_PATH).'"group/group_space.php?'.api_get_cidreq().'&amp;gradebook='.$gradebook.'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('Groups'),'',ICON_SIZE_MEDIUM).'</a>';
} else {
echo '<span style="float:right;">'.search_link().'</span>';
echo '<a href="index.php">'.Display::return_icon('back.png', get_lang('BackToForumOverview'), '', ICON_SIZE_MEDIUM).'</a>';
echo '<a href="'.$forumUrl.'index.php">'.Display::return_icon('back.png', get_lang('BackToForumOverview'), '', ICON_SIZE_MEDIUM).'</a>';
}
}
// The link should appear when
// 1. the course admin is here
// 2. the course member is here and new threads are allowed
@ -285,10 +294,10 @@ if (api_is_allowed_to_edit(false, true) OR ($current_forum['allow_new_threads']
if ($current_forum['locked'] <> 1 AND $current_forum['locked'] <> 1) {
if (!api_is_anonymous()) {
if ($my_forum == strval(intval($my_forum))) {
echo '<a href="newthread.php?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($my_forum).$origin_string.'">'.Display::return_icon('new_thread.png',get_lang('NewTopic'),'',ICON_SIZE_MEDIUM).'</a>';
echo '<a href="'.$forumUrl.'newthread.php?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($my_forum).$origin_string.'">'.Display::return_icon('new_thread.png',get_lang('NewTopic'),'',ICON_SIZE_MEDIUM).'</a>';
} else {
$my_forum = strval(intval($my_forum));
echo '<a href="newthread.php?'.api_get_cidreq().'&amp;forum='.$my_forum.$origin_string.'">'.Display::return_icon('new_thread.png',get_lang('NewTopic'),'',ICON_SIZE_MEDIUM).'</a>';
echo '<a href="'.$forumUrl.'newthread.php?'.api_get_cidreq().'&amp;forum='.$my_forum.$origin_string.'">'.Display::return_icon('new_thread.png',get_lang('NewTopic'),'',ICON_SIZE_MEDIUM).'</a>';
}
}
} else {
@ -420,17 +429,20 @@ if (is_array($threads)) {
if ($origin != 'learnpath') {
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().'&amp;forum='.Security::remove_XSS($my_forum).'&amp;thread='.Security::remove_XSS($row['thread_id']).'&amp;post='.$row_post_id['post_id'].'&amp;gidReq='.$_SESSION['toolgroup'].'&amp;origin='.$origin.'&amp;id_attach='.$id_attach.'">'.Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>';
echo '<a href="'.$forumUrl.'editpost.php?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($my_forum).'&amp;thread='.Security::remove_XSS($row['thread_id']).'&amp;post='.$row_post_id['post_id'].'&id_attach='.$id_attach.'">'.
Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>';
if (api_resource_is_locked_by_gradebook($row['thread_id'], LINK_FORUM_THREAD)) {
echo Display::return_icon('delete_na.png', get_lang('ResourceLockedByGradebook'), array(), ICON_SIZE_SMALL);
} else {
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($my_forum).'&amp;action=delete&amp;content=thread&amp;gidReq='.$_SESSION['toolgroup'].'&amp;id='.$row['thread_id'].$origin_string."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('DeleteCompleteThread'), ENT_QUOTES))."')) return false;\">".Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).'</a>';
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($my_forum).'&amp;action=delete&amp;content=thread&id='.$row['thread_id'].$origin_string."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('DeleteCompleteThread'), ENT_QUOTES))."')) return false;\">".
Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).'</a>';
}
display_visible_invisible_icon('thread', $row['thread_id'], $row['visibility'], array('forum' => $my_forum, 'origin' => $origin, 'gidReq' => $_SESSION['toolgroup']));
display_lock_unlock_icon('thread', $row['thread_id'], $row['locked'], array('forum' => $my_forum, 'origin' => $origin, 'gidReq' => $_SESSION['toolgroup']));
echo '<a href="viewforum.php?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($my_forum).'&amp;action=move&amp;gidReq='.$_SESSION['toolgroup'].'&amp;thread='.$row['thread_id'].$origin_string.'">'.Display::return_icon('move.png', get_lang('MoveThread'), array(), ICON_SIZE_SMALL).'</a>';
display_visible_invisible_icon('thread', $row['thread_id'], $row['visibility'], array('forum' => $my_forum, 'origin' => $origin, 'gidReq' => $groupId));
display_lock_unlock_icon('thread', $row['thread_id'], $row['locked'], array('forum' => $my_forum, 'origin' => $origin, 'gidReq' => api_get_group_id()));
echo '<a href="viewforum.php?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($my_forum).'&amp;action=move&thread='.$row['thread_id'].$origin_string.'">'.
Display::return_icon('move.png', get_lang('MoveThread'), array(), ICON_SIZE_SMALL).'</a>';
}
}
$iconnotify = 'send_mail.gif';
@ -441,11 +453,13 @@ if (is_array($threads)) {
}
$icon_liststd = 'user.png';
if (!api_is_anonymous() && api_is_allowed_to_session_edit(false, true)) {
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($my_forum).'&amp;origin='.$origin.'&amp;action=notify&amp;content=thread&amp;gidReq='.$_SESSION['toolgroup'].'&amp;id='.$row['thread_id'].'">'.Display::return_icon($iconnotify, get_lang('NotifyMe')).'</a>';
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($my_forum).'&amp;origin='.$origin.'&amp;action=notify&amp;content=thread&id='.$row['thread_id'].'">'.
Display::return_icon($iconnotify, get_lang('NotifyMe')).'</a>';
}
if (api_is_allowed_to_edit(null,true) && $origin != 'learnpath') {
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($my_forum).'&amp;origin='.$origin.'&amp;action=liststd&amp;content=thread&amp;gidReq='.$_SESSION['toolgroup'].'&amp;id='.$row['thread_id'].'">'.Display::return_icon($icon_liststd,get_lang('StudentList'), array(), ICON_SIZE_SMALL).'</a>';
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($my_forum).'&amp;origin='.$origin.'&amp;action=liststd&amp;content=thread&id='.$row['thread_id'].'">'.
Display::return_icon($icon_liststd,get_lang('StudentList'), array(), ICON_SIZE_SMALL).'</a>';
}
echo '</td></tr>';
}

@ -26,10 +26,6 @@ if (isset($rows)) {
}
echo "<div ".$style."><table class=\"data_table\">";
// 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';

@ -40,7 +40,7 @@ if (isset($_GET['origin'])) {
// 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.
// but the problem is that the visibility of the forum AND forum category 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']);

@ -97,9 +97,7 @@ if (!api_is_allowed_to_edit(false, true) AND ($current_forum['visibility'] == 0
}
/* Actions */
$group_id = api_get_group_id();
$my_action = isset($_GET['action']) ? $_GET['action'] : '';
if ($my_action == 'delete' AND isset($_GET['content']) AND isset($_GET['id']) AND (api_is_allowed_to_edit(false, true) OR GroupManager::is_tutor_of_group(api_get_user_id(), $group_id))) {
$message = delete_post($_GET['id']); // Note: This has to be cleaned first.
@ -148,12 +146,6 @@ if ($my_message != 'PostDeletedSpecial') {
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;';
/* if ( isset($_GET['gradebook']) && $_GET['gradebook'] != '') {
$info_thread = get_thread_information($_GET['thread']);
echo '<a href="newthread.php?'.api_get_cidreq().'&amp;forum='.$info_thread['forum_id'].'&amp;origin='.$origin.'&amp;gradebook='.Security::remove_XSS($_GET['gradebook']).'">'.Display::return_icon('new_thread.png', get_lang('NewTopic'), '', ICON_SIZE_MEDIUM).'</a>';
} else {
echo '<a href="newthread.php?'.api_get_cidreq().'&amp;forum='.Security::remove_XSS($_GET['forum']).'&amp;origin='.$origin.'">'.Display::return_icon('new_thread.png', get_lang('NewTopic'), '', ICON_SIZE_MEDIUM).'</a>';
} */
} else {
echo get_lang('ForumLocked');
}

@ -21,7 +21,7 @@ if ((isset($_GET['action']) && $_GET['action']=='delete_attach') && isset($_GET[
delete_attachment(0,$_GET['id_attach']);
}
$rows=get_posts($_GET['thread']); // Note: This has to be cleaned first.
$rows = get_posts($_GET['thread']);
$rows = calculate_children($rows);
$count=0;
$clean_forum_id = intval($_GET['forum']);
@ -63,40 +63,49 @@ foreach ($rows as $post) {
$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']))) {
if (GroupManager::is_tutor_of_group(api_get_user_id(), $group_id) OR ($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']))) {
if (GroupManager::is_tutor_of_group(api_get_user_id(), $group_id) OR
($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']))
) {
if ($locked == false) {
echo "<a href=\"editpost.php?".api_get_cidreq()."&amp;gidReq=".Security::remove_XSS($_GET['gidReq'])."&amp;forum=".$clean_forum_id."&amp;thread=".$clean_thread_id."&amp;origin=".$origin."&amp;post=".$post['post_id']."&amp;id_attach=".$id_attach."\">".Display::return_icon('edit.png',get_lang('Edit'), array(), ICON_SIZE_SMALL)."</a>";
echo "<a href=\"editpost.php?".api_get_cidreq()."&forum=".$clean_forum_id."&thread=".$clean_thread_id."&post=".$post['post_id']."&amp;id_attach=".$id_attach."\">".
Display::return_icon('edit.png',get_lang('Edit'), array(), ICON_SIZE_SMALL)."</a>";
}
}
if (GroupManager::is_tutor_of_group(api_get_user_id(), $group_id) OR api_is_allowed_to_edit(false,true) && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session'])) {
if (GroupManager::is_tutor_of_group(api_get_user_id(), $group_id) OR
api_is_allowed_to_edit(false,true) &&
!(api_is_course_coach() &&
$current_forum['session_id']!=$_SESSION['id_session'])
) {
if ($locked == false) {
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&amp;gidReq=".Security::remove_XSS($_GET['gidReq'])."&amp;forum=".$clean_forum_id."&amp;thread=".$clean_thread_id."&amp;action=delete&amp;content=post&amp;id=".$post['post_id']."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('DeletePost'), ENT_QUOTES))."')) return false;\">".Display::return_icon('delete.png',get_lang('Delete'), array(), ICON_SIZE_SMALL)."</a>";
}
}
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'])) {
display_visible_invisible_icon('post', $post['post_id'], $post['visible'], array('forum'=>$clean_forum_id,'thread'=>$clean_thread_id ));
echo "";
if ($count>0) {
echo "<a href=\"viewthread.php?".api_get_cidreq()."&amp;gidReq=".Security::remove_XSS($_GET['gidReq'])."&amp;forum=".$clean_forum_id."&amp;thread=".$clean_thread_id."&amp;action=move&amp;origin=".$origin."&amp;post=".$post['post_id']."\">".Display::return_icon('move.png',get_lang('MovePost'), array(),ICON_SIZE_SMALL)."</a>";
}
}
$userinf = api_get_user_info($post['user_id']);
$user_status = api_get_status_of_user_in_course($post['user_id'],api_get_course_id());
if (api_is_allowed_to_edit(null,true)) {
//if ($count>0 && $user_status!=1) {
if ($count>0) {
$current_qualify_thread = show_qualify('1', $post['user_id'],$_GET['thread']);
if ($locked == false) {
echo "<a href=\"forumqualify.php?".api_get_cidreq()."&amp;forum=".$clean_forum_id."&amp;thread=".$clean_thread_id."&amp;action=list&amp;post=".$post['post_id']."&amp;user=".$post['user_id']."&amp;user_id=".$post['user_id']."&amp;origin=".$origin."&amp;idtextqualify=".$current_qualify_thread."\" >".Display::return_icon('new_test_small.gif',get_lang('Qualify'))."</a>";
}
}
}
if (($current_forum_category && $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 && $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 (!api_is_anonymous() && api_is_allowed_to_session_edit(false,true)) {
echo '<a href="reply.php?'.api_get_cidreq().'&amp;forum='.$clean_forum_id.'&amp;thread='.$clean_thread_id.'&amp;post='.$post['post_id'].'&amp;action=replymessage&amp;origin='. $origin .'">'.Display :: return_icon('message_reply_forum.png', get_lang('ReplyToMessage'))."</a>";
@ -116,7 +125,10 @@ foreach ($rows as $post) {
}
echo "</td>";
// 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=Display::return_icon('forumpostnew.gif');
} else {
$post_image=Display::return_icon('forumpost.gif');
@ -133,7 +145,6 @@ foreach ($rows as $post) {
echo "<td class=\"$messageclass\">".prepare4display($post['post_text'])."</td>";
echo "</tr>";
// The check if there is an attachment
$attachment_list = get_attachment($post['post_id']);
@ -147,7 +158,9 @@ foreach ($rows as $post) {
echo $realname;
echo ' "> '.$user_filename.' </a>';
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 '&nbsp;&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;origin='.Security::remove_XSS($_GET['origin']).'&amp;action=delete_attach&amp;id_attach='.$attachment_list['id'].'&amp;forum='.$clean_forum_id.'&amp;thread='.$clean_thread_id.'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)).'\')) return false;">'.Display::return_icon('delete.gif',get_lang('Delete')).'</a><br />';
}
echo '</td></tr>';

@ -22,12 +22,13 @@
*/
require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php';
$forumUrl = api_get_path(WEB_CODE_PATH).'forum/';
$rows = get_posts($_GET['thread']); // Note: This has to be cleaned first.
$rows = get_posts($_GET['thread']);
$rows = calculate_children($rows);
if (isset($_GET['post']) && $_GET['post']) {
$display_post_id = intval($_GET['post']); // note: this has to be cleaned first
$display_post_id = intval($_GET['post']);
} else {
// we need to display the first post
reset($rows);
@ -62,13 +63,19 @@ foreach ($rows as $post) {
$indent=$post['indent_cnt']*'20';
$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 = Display::return_icon('forumpostnew.gif');
} else {
$post_image = Display::return_icon('forumpost.gif');
}
$thread_structure.= $post_image;
if (isset($_GET['post']) && $_GET['post']==$post['post_id'] OR ($counter==1 AND !isset($_GET['post']))) {
if (isset($_GET['post']) &&
$_GET['post'] == $post['post_id'] OR
($counter==1 AND !isset($_GET['post']))
) {
$thread_structure .= '<strong>'.prepare4display($post['post_title']).'</strong></div>';
$prev_next_array[]= $post['post_id'];
} else {
@ -100,16 +107,32 @@ $next_message = get_lang('NextMessage');
$prev_message = get_lang('PrevMessage');
// images
$first_img = Display::return_icon('action_first.png',get_lang('FirstMessage'), array('style' => 'vertical-align: middle;'));
$last_img = Display::return_icon('action_last.png',get_lang('LastMessage'), array('style' => 'vertical-align: middle;'));
$prev_img = Display::return_icon('action_prev.png',get_lang('PrevMessage'), array('style' => 'vertical-align: middle;'));
$next_img = Display::return_icon('action_next.png',get_lang('NextMessage'), array('style' => 'vertical-align: middle;'));
$first_img = Display::return_icon(
'action_first.png',
get_lang('FirstMessage'),
array('style' => 'vertical-align: middle;')
);
$last_img = Display::return_icon(
'action_last.png',
get_lang('LastMessage'),
array('style' => 'vertical-align: middle;')
);
$prev_img = Display::return_icon(
'action_prev.png',
get_lang('PrevMessage'),
array('style' => 'vertical-align: middle;')
);
$next_img = Display::return_icon(
'action_next.png',
get_lang('NextMessage'),
array('style' => 'vertical-align: middle;')
);
// links
$first_href = 'viewthread.php?'.api_get_cidreq().'&amp;forum='.$clean_forum_id.'&amp;thread='.$clean_thread_id.'&amp;gradebook='.$gradebook.'&amp;origin='.$origin.'&amp;id=1&amp;post='.$prev_next_array[0];
$last_href = 'viewthread.php?'.api_get_cidreq().'&amp;forum='.$clean_forum_id.'&amp;thread='.$clean_thread_id.'&amp;gradebook='.$gradebook.'&amp;origin='.$origin.'&amp;post='.$prev_next_array[$max-1];
$prev_href = 'viewthread.php?'.api_get_cidreq().'&amp;forum='.$clean_forum_id.'&amp;thread='.$clean_thread_id.'&amp;gradebook='.$gradebook.'&amp;origin='.$origin.'&amp;post='.$prev_next_array[$prev_id];
$next_href = 'viewthread.php?'.api_get_cidreq().'&amp;forum='.$clean_forum_id.'&amp;thread='.$clean_thread_id.'&amp;gradebook='.$gradebook.'&amp;origin='.$origin.'&amp;post='.$prev_next_array[$next_id];
$first_href = $forumUrl.'viewthread.php?'.api_get_cidreq().'&amp;forum='.$clean_forum_id.'&amp;thread='.$clean_thread_id.'&amp;gradebook='.$gradebook.'&id=1&amp;post='.$prev_next_array[0];
$last_href = $forumUrl.'viewthread.php?'.api_get_cidreq().'&amp;forum='.$clean_forum_id.'&amp;thread='.$clean_thread_id.'&amp;gradebook='.$gradebook.'&post='.$prev_next_array[$max-1];
$prev_href = $forumUrl.'viewthread.php?'.api_get_cidreq().'&amp;forum='.$clean_forum_id.'&amp;thread='.$clean_thread_id.'&amp;gradebook='.$gradebook.'&post='.$prev_next_array[$prev_id];
$next_href = $forumUrl.'viewthread.php?'.api_get_cidreq().'&amp;forum='.$clean_forum_id.'&amp;thread='.$clean_thread_id.'&amp;gradebook='.$gradebook.'&post='.$prev_next_array[$next_id];
echo '<center style="margin-top: 10px; margin-bottom: 10px;">';
//go to: first and previous
@ -173,13 +196,17 @@ $id_attach = !empty($attachment_list)?$attachment_list['id']:'';
// The course admin him/herself can do this off course always
if (GroupManager::is_tutor_of_group(api_get_user_id(), $group_id) OR ($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']))) {
if ($locked == false) {
echo "<a href=\"editpost.php?".api_get_cidreq()."&amp;gidReq=".Security::remove_XSS($_GET['gidReq'])."&amp;forum=".$clean_forum_id."&amp;thread=".$clean_thread_id."&amp;origin=".$origin."&amp;post=".$rows[$display_post_id]['post_id']."&amp;id_attach=".$id_attach."\">".Display::return_icon('edit.png',get_lang('Edit'), array(), ICON_SIZE_SMALL)."</a>";
echo "<a href=\"editpost.php?".api_get_cidreq()."&forum=".$clean_forum_id."&thread=".$clean_thread_id."&post=".$rows[$display_post_id]['post_id']."&amp;id_attach=".$id_attach."\">".
Display::return_icon('edit.png',get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>';
}
}
if (GroupManager::is_tutor_of_group(api_get_user_id(), $group_id) OR api_is_allowed_to_edit(false,true) && !(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session'])) {
if (GroupManager::is_tutor_of_group(api_get_user_id(), $group_id) OR
api_is_allowed_to_edit(false,true) &&
!(api_is_course_coach() && $current_forum['session_id']!=$_SESSION['id_session'])
) {
if ($locked == false) {
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&amp;gidReq=".Security::remove_XSS($_GET['gidReq'])."&amp;forum=".$clean_forum_id."&amp;thread=".$clean_thread_id."&amp;action=delete&amp;content=post&amp;id=".$rows[$display_post_id]['post_id']."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('DeletePost'), ENT_QUOTES))."')) return false;\">".Display::return_icon('delete.png',get_lang('Delete'), array(), ICON_SIZE_SMALL)."</a>";
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&forum=".$clean_forum_id."&amp;thread=".$clean_thread_id."&amp;action=delete&amp;content=post&amp;id=".$rows[$display_post_id]['post_id']."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('DeletePost'), ENT_QUOTES))."')) return false;\">".Display::return_icon('delete.png',get_lang('Delete'), array(), ICON_SIZE_SMALL)."</a>";
}
display_visible_invisible_icon('post', $rows[$display_post_id]['post_id'], $rows[$display_post_id]['visible'],array('forum'=>$clean_forum_id,'thread'=>$clean_thread_id, 'post'=>Security::remove_XSS($_GET['post']) ));
echo "";
@ -201,16 +228,17 @@ if (GroupManager::is_tutor_of_group(api_get_user_id(), $group_id) OR api_is_allo
}
}
$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(null,true)) {
if ($post_id > $post_minor) {
//if ($user_status!=1) {
$current_qualify_thread=show_qualify('1', $rows[$display_post_id]['user_id'],$_GET['thread']);
if ($locked == false) {
echo "<a href=\"forumqualify.php?".api_get_cidreq()."&amp;forum=".$clean_forum_id."&amp;thread=".$clean_thread_id."&amp;action=list&amp;post=".$rows[$display_post_id]['post_id']."&amp;user=".$rows[$display_post_id]['user_id']."&amp;user_id=".$rows[$display_post_id]['user_id']."&amp;origin=".$origin."&amp;idtextqualify=".$current_qualify_thread."\" >".Display::return_icon('new_test_small.gif',get_lang('Qualify'))."</a>";
}
//}
}
}
if (($current_forum_category && $current_forum_category['locked']==0) AND $current_forum['locked']==0 AND $current_thread['locked']==0 OR api_is_allowed_to_edit(false,true)) {
@ -233,7 +261,10 @@ if (($current_forum_category && $current_forum_category['locked']==0) AND $curre
}
echo "</td>";
// 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']])) {
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=Display::return_icon('forumpostnew.gif');
} else {
$post_image=Display::return_icon('forumpost.gif');

Loading…
Cancel
Save