From 1e6e4d37f5d13390cbbd9bd2eac28123657191a4 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 23 Apr 2014 11:40:50 +0200 Subject: [PATCH] Minor - fixing PHP warnings, format code. --- main/forum/viewforum.php | 86 +++++++++-------- main/forum/viewforumcategory.php | 12 +-- main/forum/viewpost.inc.php | 10 +- main/forum/viewpost.php | 2 +- main/forum/viewthread.php | 8 -- main/forum/viewthread_nested.inc.php | 49 ++++++---- main/forum/viewthread_threaded.inc.php | 123 ++++++++++++++++--------- 7 files changed, 168 insertions(+), 122 deletions(-) diff --git a/main/forum/viewforum.php b/main/forum/viewforum.php index c1dec412d3..2659f190e0 100644 --- a/main/forum/viewforum.php +++ b/main/forum/viewforum.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(); } @@ -106,9 +105,9 @@ if (isset($_SESSION['gradebook'])){ if (!empty($gradebook) && $gradebook == 'view') { $interbreadcrumb[] = array ( - 'url' => '../gradebook/'.$_SESSION['gradebook_dest'], - 'name' => get_lang('ToolGradebook') - ); + 'url' => '../gradebook/'.$_SESSION['gradebook_dest'], + 'name' => get_lang('ToolGradebook') + ); } if (!empty($_GET['gidReq'])) { @@ -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,13 +195,19 @@ 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); $icon_qualify = 'blog_new.gif'; @@ -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 .= ''.$name_user_theme.''; + $table_list .= ' + + '.$name_user_theme.''; if ($_GET['list'] == 'qualify') { $table_list .= ''.$row_student_list['qualify'].'/'.$max_qualify.''; } if (api_is_allowed_to_edit(null, true)) { $current_qualify_thread = show_qualify('1', $row_student_list['user_id'], $_GET['id']); - $table_list .= ''.Display::return_icon($icon_qualify, get_lang('Qualify')).''; + $table_list .= ''. + Display::return_icon($icon_qualify, get_lang('Qualify')).''; } $counter_stdlist++; } @@ -269,14 +279,13 @@ echo '
'; if ($origin != 'learnpath') { if ($origin=='group') { - echo ''.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('Groups'),'',ICON_SIZE_MEDIUM).''; + echo ''.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('Groups'),'',ICON_SIZE_MEDIUM).''; } else { echo ''.search_link().''; - echo ''.Display::return_icon('back.png', get_lang('BackToForumOverview'), '', ICON_SIZE_MEDIUM).''; + echo ''.Display::return_icon('back.png', get_lang('BackToForumOverview'), '', ICON_SIZE_MEDIUM).''; } } - // 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 ''.Display::return_icon('new_thread.png',get_lang('NewTopic'),'',ICON_SIZE_MEDIUM).''; + echo ''.Display::return_icon('new_thread.png',get_lang('NewTopic'),'',ICON_SIZE_MEDIUM).''; } else { $my_forum = strval(intval($my_forum)); - echo ''.Display::return_icon('new_thread.png',get_lang('NewTopic'),'',ICON_SIZE_MEDIUM).''; + echo ''.Display::return_icon('new_thread.png',get_lang('NewTopic'),'',ICON_SIZE_MEDIUM).''; } } } 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 ''.Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).''; + echo ''. + Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).''; 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 '".Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).''; + echo '". + Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).''; } - 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 ''.Display::return_icon('move.png', get_lang('MoveThread'), array(), ICON_SIZE_SMALL).''; + 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 ''. + Display::return_icon('move.png', get_lang('MoveThread'), array(), ICON_SIZE_SMALL).''; } } $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 ''.Display::return_icon($iconnotify, get_lang('NotifyMe')).''; + echo ''. + Display::return_icon($iconnotify, get_lang('NotifyMe')).''; } if (api_is_allowed_to_edit(null,true) && $origin != 'learnpath') { - echo ''.Display::return_icon($icon_liststd,get_lang('StudentList'), array(), ICON_SIZE_SMALL).''; + echo ''. + Display::return_icon($icon_liststd,get_lang('StudentList'), array(), ICON_SIZE_SMALL).''; } echo ''; } diff --git a/main/forum/viewforumcategory.php b/main/forum/viewforumcategory.php index 78365968f6..5eadf7aea9 100644 --- a/main/forum/viewforumcategory.php +++ b/main/forum/viewforumcategory.php @@ -34,12 +34,12 @@ $htmlHeadXtra[] = ''; $htmlHeadXtra[] = ''; @@ -91,7 +91,7 @@ if (isset($_GET['origin'])) { if ($origin=='learnpath') { Display::display_reduced_header(); } else { - Display :: display_header(null); + Display::display_header(null); } /* ACTIONS */ diff --git a/main/forum/viewpost.inc.php b/main/forum/viewpost.inc.php index 6b07116776..2b4bd97b10 100644 --- a/main/forum/viewpost.inc.php +++ b/main/forum/viewpost.inc.php @@ -26,10 +26,6 @@ if (isset($rows)) { } echo "
"; - // 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'; @@ -87,13 +83,13 @@ if (isset($rows)) { } $userid = (int)$_GET['user_id']; -$userinf=api_get_user_info($userid); +$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', $userid,$threadid); -$current_qualify_thread=show_qualify('1',$userid,$threadid); +$max_qualify = show_qualify('2', $userid, $threadid); +$current_qualify_thread = show_qualify('1', $userid, $threadid); if (isset($_POST['idtextqualify'])) { store_theme_qualify($userid,$threadid,$qualify,$_SESSION['_user']['user_id'],date('Y-m-d H:i:s'),''); } diff --git a/main/forum/viewpost.php b/main/forum/viewpost.php index 8e488e9857..201263b5d6 100644 --- a/main/forum/viewpost.php +++ b/main/forum/viewpost.php @@ -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']); diff --git a/main/forum/viewthread.php b/main/forum/viewthread.php index d530036a34..53ff1efd44 100644 --- a/main/forum/viewthread.php +++ b/main/forum/viewthread.php @@ -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 '  '; -/* if ( isset($_GET['gradebook']) && $_GET['gradebook'] != '') { - $info_thread = get_thread_information($_GET['thread']); - echo ''.Display::return_icon('new_thread.png', get_lang('NewTopic'), '', ICON_SIZE_MEDIUM).''; - } else { - echo ''.Display::return_icon('new_thread.png', get_lang('NewTopic'), '', ICON_SIZE_MEDIUM).''; - } */ } else { echo get_lang('ForumLocked'); } diff --git a/main/forum/viewthread_nested.inc.php b/main/forum/viewthread_nested.inc.php index e17cf4685e..d0cd83dea8 100644 --- a/main/forum/viewthread_nested.inc.php +++ b/main/forum/viewthread_nested.inc.php @@ -21,8 +21,8 @@ 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=calculate_children($rows); +$rows = get_posts($_GET['thread']); +$rows = calculate_children($rows); $count=0; $clean_forum_id = intval($_GET['forum']); $clean_thread_id = intval($_GET['thread']); @@ -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 "".Display::return_icon('edit.png',get_lang('Edit'), array(), ICON_SIZE_SMALL).""; + echo "". + Display::return_icon('edit.png',get_lang('Edit'), array(), ICON_SIZE_SMALL).""; } } - 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 "".Display::return_icon('delete.png',get_lang('Delete'), array(), ICON_SIZE_SMALL).""; } } - 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 (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 )); if ($count>0) { echo "".Display::return_icon('move.png',get_lang('MovePost'), array(),ICON_SIZE_SMALL).""; } } - $userinf=api_get_user_info($post['user_id']); - $user_status=api_get_status_of_user_in_course($post['user_id'],api_get_course_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()); 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']); - + $current_qualify_thread = show_qualify('1', $post['user_id'],$_GET['thread']); if ($locked == false) { echo "".Display::return_icon('new_test_small.gif',get_lang('Qualify')).""; } } } - 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 ''.Display :: return_icon('message_reply_forum.png', get_lang('ReplyToMessage')).""; @@ -116,7 +125,10 @@ foreach ($rows as $post) { } echo ""; // 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 ""; echo ""; - // The check if there is an attachment $attachment_list = get_attachment($post['post_id']); @@ -147,8 +158,10 @@ foreach ($rows as $post) { echo $realname; echo ' "> '.$user_filename.' '; echo ''.$attachment_list['comment'].''; - 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 '  '.Display::return_icon('delete.gif',get_lang('Delete')).'
'; + 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 '  '.Display::return_icon('delete.gif',get_lang('Delete')).'
'; } echo ''; } diff --git a/main/forum/viewthread_threaded.inc.php b/main/forum/viewthread_threaded.inc.php index 9622200298..9a6f2840af 100644 --- a/main/forum/viewthread_threaded.inc.php +++ b/main/forum/viewthread_threaded.inc.php @@ -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); @@ -43,7 +44,7 @@ if(isset($_GET['origin'])) { // Delete attachment file. 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) @@ -62,15 +63,21 @@ foreach ($rows as $post) { $indent=$post['indent_cnt']*'20'; $thread_structure.= "
"; - 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'); + 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'); + $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']))) { - $thread_structure.=''.prepare4display($post['post_title']).'
'; - $prev_next_array[]=$post['post_id']; + if (isset($_GET['post']) && + $_GET['post'] == $post['post_id'] OR + ($counter==1 AND !isset($_GET['post'])) + ) { + $thread_structure .= ''.prepare4display($post['post_title']).''; + $prev_next_array[]= $post['post_id']; } else { if ($post['visible']=='0') { $class=' class="invisible"'; @@ -88,10 +95,10 @@ $locked = api_resource_is_locked_by_gradebook($clean_thread_id, LINK_FORUM_THREA /* NAVIGATION CONTROLS */ -$current_id=array_search($display_post_id,$prev_next_array); -$max=count($prev_next_array); -$next_id=$current_id+1; -$prev_id=$current_id-1; +$current_id = array_search($display_post_id, $prev_next_array); +$max = count($prev_next_array); +$next_id = $current_id + 1; +$prev_id = $current_id - 1; // text $first_message = get_lang('FirstMessage'); @@ -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().'&forum='.$clean_forum_id.'&thread='.$clean_thread_id.'&gradebook='.$gradebook.'&origin='.$origin.'&id=1&post='.$prev_next_array[0]; -$last_href = 'viewthread.php?'.api_get_cidreq().'&forum='.$clean_forum_id.'&thread='.$clean_thread_id.'&gradebook='.$gradebook.'&origin='.$origin.'&post='.$prev_next_array[$max-1]; -$prev_href = 'viewthread.php?'.api_get_cidreq().'&forum='.$clean_forum_id.'&thread='.$clean_thread_id.'&gradebook='.$gradebook.'&origin='.$origin.'&post='.$prev_next_array[$prev_id]; -$next_href = 'viewthread.php?'.api_get_cidreq().'&forum='.$clean_forum_id.'&thread='.$clean_thread_id.'&gradebook='.$gradebook.'&origin='.$origin.'&post='.$prev_next_array[$next_id]; +$first_href = $forumUrl.'viewthread.php?'.api_get_cidreq().'&forum='.$clean_forum_id.'&thread='.$clean_thread_id.'&gradebook='.$gradebook.'&id=1&post='.$prev_next_array[0]; +$last_href = $forumUrl.'viewthread.php?'.api_get_cidreq().'&forum='.$clean_forum_id.'&thread='.$clean_thread_id.'&gradebook='.$gradebook.'&post='.$prev_next_array[$max-1]; +$prev_href = $forumUrl.'viewthread.php?'.api_get_cidreq().'&forum='.$clean_forum_id.'&thread='.$clean_thread_id.'&gradebook='.$gradebook.'&post='.$prev_next_array[$prev_id]; +$next_href = $forumUrl.'viewthread.php?'.api_get_cidreq().'&forum='.$clean_forum_id.'&thread='.$clean_thread_id.'&gradebook='.$gradebook.'&post='.$prev_next_array[$next_id]; echo '
'; //go to: first and previous @@ -122,7 +145,7 @@ if ((int)$current_id > 0) { } // current counter -echo ' [ '.($current_id+1).' / '.$max.' ] '; +echo ' [ '.($current_id+1).' / '.$max.' ] '; // go to: next and last if (($current_id+1) < $max) { @@ -135,14 +158,14 @@ if (($current_id+1) < $max) { echo '
'; // 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'; +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'; } else { - $titleclass='forum_message_post_title'; - $messageclass='forum_message_post_text'; - $leftclass='forum_message_left'; + $titleclass = 'forum_message_post_title'; + $messageclass = 'forum_message_post_text'; + $leftclass = 'forum_message_left'; } // Displaying the message @@ -171,15 +194,19 @@ $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 (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 "".Display::return_icon('edit.png',get_lang('Edit'), array(), ICON_SIZE_SMALL).""; + echo "". + Display::return_icon('edit.png',get_lang('Edit'), array(), ICON_SIZE_SMALL).''; } } -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 "".Display::return_icon('delete.png',get_lang('Delete'), array(), ICON_SIZE_SMALL).""; + echo "".Display::return_icon('delete.png',get_lang('Delete'), array(), ICON_SIZE_SMALL).""; } 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 ""; @@ -200,17 +227,18 @@ if (GroupManager::is_tutor_of_group(api_get_user_id(), $group_id) OR api_is_allo echo "".Display::return_icon('move.png',get_lang('MovePost'), array(), ICON_SIZE_SMALL).""; } } -$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()); +$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() +); 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 "".Display::return_icon('new_test_small.gif',get_lang('Qualify')).""; - } - //} + if ($post_id > $post_minor) { + $current_qualify_thread=show_qualify('1', $rows[$display_post_id]['user_id'],$_GET['thread']); + + if ($locked == false) { + echo "".Display::return_icon('new_test_small.gif',get_lang('Qualify')).""; + } } } 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 ""; // 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'); @@ -255,8 +286,8 @@ $attachment_list = get_attachment($display_post_id); if (!empty($attachment_list)) { echo '
".prepare4display($post['post_text'])."
'; - $realname=$attachment_list['path']; - $user_filename=$attachment_list['filename']; + $realname = $attachment_list['path']; + $user_filename = $attachment_list['filename']; echo Display::return_icon('attachment.gif',get_lang('Attachment')); echo '