diff --git a/main/forum/forumfunction.inc.php b/main/forum/forumfunction.inc.php index 0e65c2a5b7..c08886fd6b 100755 --- a/main/forum/forumfunction.inc.php +++ b/main/forum/forumfunction.inc.php @@ -6098,4 +6098,3 @@ function postIsEditableByStudent($forum, $post) return true; } } - diff --git a/main/forum/forumsearch.php b/main/forum/forumsearch.php index ed92bb1a1d..639d94fa0c 100755 --- a/main/forum/forumsearch.php +++ b/main/forum/forumsearch.php @@ -40,7 +40,6 @@ $origin = api_get_origin(); $nameTools = get_lang('ToolForum'); // Breadcrumbs - if (isset($_SESSION['gradebook'])) { $gradebook = $_SESSION['gradebook']; } diff --git a/main/forum/index.php b/main/forum/index.php index deb821afc0..ecae5fe694 100755 --- a/main/forum/index.php +++ b/main/forum/index.php @@ -309,9 +309,8 @@ if (is_array($forumCategories)) { // test if $whatsnew_post_info[$forum['forum_id']] is empty or not. if (isset($forum['forum_id'])) { if (!empty($whatsnew_post_info)) { - if ( - isset($whatsnew_post_info[$forum['forum_id']]) - && is_array($whatsnew_post_info[$forum['forum_id']]) + if (isset($whatsnew_post_info[$forum['forum_id']]) && + is_array($whatsnew_post_info[$forum['forum_id']]) ) { foreach ($whatsnew_post_info[$forum['forum_id']] as $key_thread_id => $new_post_array) { if (empty($whatsnew_post_info[$forum['forum_id']][$key_thread_id])) { @@ -367,7 +366,8 @@ if (is_array($forumCategories)) { } // Validation when belongs to a session $forumInfo['icon_session'] = api_get_session_image( - $forum['session_id'], $_user['status'] + $forum['session_id'], + $_user['status'] ); if ($forum['forum_of_group'] != '0') { $my_all_groups_forum_name = isset($all_groups[$forum['forum_of_group']]['name']) @@ -454,7 +454,6 @@ if (is_array($forumCategories)) { } } $forumInfo['last_poster_id'] = $poster_id; - if (!empty($forum['last_poster_id'])) { $forumInfo['last_poster_date'] = api_convert_and_format_date($forum['last_post_date']); $forumInfo['last_poster_user'] = display_user_link($poster_id, $name, null, $username); diff --git a/main/forum/newthread.php b/main/forum/newthread.php index e278cf658c..f1d574315a 100755 --- a/main/forum/newthread.php +++ b/main/forum/newthread.php @@ -72,7 +72,7 @@ if (!api_is_allowed_to_edit(false, true) && // 2. the forumcategory or forum is locked (locked <>0) and the user is not a course manager if (!api_is_allowed_to_edit(false, true) && - (($current_forum_category['visibility'] && $current_forum_category['locked'] <> 0) OR $current_forum['locked'] <> 0) + (($current_forum_category['visibility'] && $current_forum_category['locked'] <> 0) || $current_forum['locked'] <> 0) ) { api_not_allowed(); } diff --git a/main/forum/viewforum.php b/main/forum/viewforum.php index 37d609caf6..44369019f5 100755 --- a/main/forum/viewforum.php +++ b/main/forum/viewforum.php @@ -86,8 +86,7 @@ if (!empty($groupId)) { ); // Course - if ( - !api_is_allowed_to_edit(false, true) && //is a student + if (!api_is_allowed_to_edit(false, true) && //is a student (($current_forum_category && $current_forum_category['visibility'] == 0) || $current_forum['visibility'] == 0 || !$user_has_access_in_group) ) { @@ -95,11 +94,9 @@ if (!empty($groupId)) { } } else { //Course - if ( - !api_is_allowed_to_edit(false, true) && //is a student - ( - ($current_forum_category && $current_forum_category['visibility'] == 0) || - $current_forum['visibility'] == 0 + if (!api_is_allowed_to_edit(false, true) && ( + ($current_forum_category && $current_forum_category['visibility'] == 0) || + $current_forum['visibility'] == 0 ) //forum category or forum visibility is false ) { api_not_allowed(); @@ -107,7 +104,6 @@ if (!empty($groupId)) { } /* Header and Breadcrumbs */ - $my_search = isset($_GET['search']) ? $_GET['search'] : ''; $my_action = isset($_GET['action']) ? $_GET['action'] : ''; @@ -163,8 +159,7 @@ if ($origin == 'learnpath') { /* Actions */ // Change visibility of a forum or a forum category. -if ( - ($my_action == 'invisible' || $my_action == 'visible') && +if (($my_action == 'invisible' || $my_action == 'visible') && isset($_GET['content']) && isset($_GET['id']) && api_is_allowed_to_edit(false, true) && @@ -173,8 +168,7 @@ if ( $message = change_visibility($_GET['content'], $_GET['id'], $_GET['action']); } // Locking and unlocking. -if ( - ($my_action == 'lock' || $my_action == 'unlock') && +if (($my_action == 'lock' || $my_action == 'unlock') && isset($_GET['content']) && isset($_GET['id']) && api_is_allowed_to_edit(false, true) && api_is_allowed_to_session_edit(false, true) @@ -182,8 +176,7 @@ if ( $message = change_lock_status($_GET['content'], $_GET['id'], $my_action); } // Deleting. -if ( - $my_action == 'delete' && +if ($my_action == 'delete' && isset($_GET['content']) && isset($_GET['id']) && api_is_allowed_to_edit(false, true) && @@ -214,8 +207,7 @@ if ($my_action == 'move' && isset($_GET['thread']) && $message = move_thread_form(); } // Notification. -if ( - $my_action == 'notify' && +if ($my_action == 'notify' && isset($_GET['content']) && isset($_GET['id']) && api_is_allowed_to_session_edit(false, true) @@ -225,9 +217,7 @@ if ( } // Student list - -if ( - $my_action == 'liststd' && +if ($my_action == 'liststd' && isset($_GET['content']) && isset($_GET['id']) && (api_is_allowed_to_edit(null, true) || $is_group_tutor) @@ -369,12 +359,11 @@ if ($origin != 'learnpath') { // 1. the course admin is here // 2. the course member is here and new threads are allowed // 3. a visitor is here and new threads AND allowed AND anonymous posts are allowed -if ( - api_is_allowed_to_edit(false, true) || +if (api_is_allowed_to_edit(false, true) || ($current_forum['allow_new_threads'] == 1 && isset($_user['user_id'])) || ($current_forum['allow_new_threads'] == 1 && !isset($_user['user_id']) && $current_forum['allow_anonymous'] == 1) ) { - if ($current_forum['locked'] <> 1 AND $current_forum['locked'] <> 1) { + if ($current_forum['locked'] <> 1 && $current_forum['locked'] <> 1) { if (!api_is_anonymous() && !api_is_invitee()) { if ($my_forum == strval(intval($my_forum))) { echo ''; if (is_array($threads)) { $html = ''; $count = 1; - foreach ($threads as $row) { // Thread who have no replies yet and the only post is invisible should not be displayed to students. if (api_is_allowed_to_edit(false, true) || @@ -491,7 +478,7 @@ if (is_array($threads)) { $row['lastname'] ), array( - "title" => api_htmlentities($poster_username, ENT_QUOTES) + 'title' => api_htmlentities($poster_username, ENT_QUOTES) ) ); } @@ -533,11 +520,11 @@ if (is_array($threads)) { . Display::return_icon('post-forum.png', null, null, ICON_SIZE_SMALL) . " {$row['thread_replies']} ".get_lang('Replies').'
'; $html .= Display::return_icon( - 'post-forum.png', - null, - null, - ICON_SIZE_SMALL - ).' '.$row['thread_views'].' '.get_lang('Views').'
'.$newPost; + 'post-forum.png', + null, + null, + ICON_SIZE_SMALL + ).' '.$row['thread_views'].' '.get_lang('Views').'
'.$newPost; $html .= ''; $last_post_info = get_last_post_by_thread( @@ -623,8 +610,7 @@ if (is_array($threads)) { } } $iconnotify = 'notification_mail_na.png'; - if ( - is_array( + if (is_array( isset($_SESSION['forum_notification']['thread']) ? $_SESSION['forum_notification']['thread'] : null ) ) { diff --git a/main/forum/viewthread.php b/main/forum/viewthread.php index 4490e6c8bd..416c0439ae 100755 --- a/main/forum/viewthread.php +++ b/main/forum/viewthread.php @@ -197,8 +197,8 @@ if ($my_message != 'PostDeletedSpecial') { } // new thread link if (( - api_is_allowed_to_edit(false, true) && - !(api_is_session_general_coach() && $current_forum['session_id'] != $sessionId) + api_is_allowed_to_edit(false, true) && + !(api_is_session_general_coach() && $current_forum['session_id'] != $sessionId) ) || ($current_forum['allow_new_threads'] == 1 && isset($_user['user_id'])) || ($current_forum['allow_new_threads'] == 1 && !isset($_user['user_id']) && $current_forum['allow_anonymous'] == 1) diff --git a/main/forum/viewthread_nested.inc.php b/main/forum/viewthread_nested.inc.php index 0f78515b8d..5f90106cb0 100755 --- a/main/forum/viewthread_nested.inc.php +++ b/main/forum/viewthread_nested.inc.php @@ -143,12 +143,12 @@ foreach ($posts as $post) { ) { if ($locked == false) { $deleteUrl = api_get_self().'?'.api_get_cidreq().'&'.http_build_query([ - 'forum' => $clean_forum_id, - 'thread' => $clean_thread_id, - 'action' => 'delete', - 'content' => 'post', - 'id' => $post['post_id'] - ]); + 'forum' => $clean_forum_id, + 'thread' => $clean_thread_id, + 'action' => 'delete', + 'content' => 'post', + 'id' => $post['post_id'] + ]); $iconEdit .= Display::url( Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL), $deleteUrl, @@ -292,8 +292,7 @@ foreach ($posts as $post) { $html .= ''; // 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']]) && + if (isset($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$post['post_id']]) && !empty($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$post['post_id']]) && !empty($whatsnew_post_info[$_GET['forum']][$post['thread_id']]) ) { diff --git a/main/forum/viewthread_threaded.inc.php b/main/forum/viewthread_threaded.inc.php index c79490a5b8..c00d7d0ed7 100755 --- a/main/forum/viewthread_threaded.inc.php +++ b/main/forum/viewthread_threaded.inc.php @@ -42,8 +42,7 @@ if (isset($_GET['post']) && $_GET['post']) { // Are we in a lp ? $origin = api_get_origin(); // Delete attachment file. -if ( - isset($_GET['action']) && +if (isset($_GET['action']) && $_GET['action'] == 'delete_attach' && isset($_GET['id_attach']) ) { @@ -69,8 +68,7 @@ foreach ($rows as $post) { $indent = $post['indent_cnt'] * '20'; $thread_structure .= "
"; - if ( - !empty($whatsnew_post_info[$forumId][$post['thread_id']]) && + if (!empty($whatsnew_post_info[$forumId][$post['thread_id']]) && isset($whatsnew_post_info[$forumId][$threadId][$post['post_id']]) && !empty($whatsnew_post_info[$forumId][$threadId][$post['post_id']]) ) { @@ -79,11 +77,8 @@ foreach ($rows as $post) { $post_image = Display::return_icon('forumpost.gif'); } $thread_structure .= $post_image; - if ( - isset($_GET['post']) && - $_GET['post'] == $post['post_id'] || ( - $counter == 1 AND !isset($_GET['post']) - ) + if (isset($_GET['post']) && $_GET['post'] == $post['post_id'] || + ($counter == 1 && !isset($_GET['post'])) ) { $thread_structure .= ''.prepare4display($post['post_title']).''; $prev_next_array[] = $post['post_id']; @@ -98,10 +93,8 @@ foreach ($rows as $post) { ]), ['class' => empty($post['visible']) ? 'text-muted' : null] ); - $prev_next_array[] = $post['post_id']; } - $thread_structure .= '
'; $count++; } @@ -150,13 +143,13 @@ $class_next = ''; $first_href = $forumUrl.'viewthread.php?'.api_get_cidreq(). '&forum='.$forumId.'&thread='.$threadId. '&gradebook='.$gradebook.'&id=1&post='.$prev_next_array[0]; -$last_href = $forumUrl.'viewthread.php?'.api_get_cidreq(). +$last_href = $forumUrl.'viewthread.php?'.api_get_cidreq(). '&forum='.$forumId.'&thread='.$threadId. '&gradebook='.$gradebook.'&post='.$prev_next_array[$max - 1]; -$prev_href = $forumUrl.'viewthread.php?'.api_get_cidreq(). +$prev_href = $forumUrl.'viewthread.php?'.api_get_cidreq(). '&forum='.$forumId.'&thread='.$threadId. '&gradebook='.$gradebook.'&post='.$prev_next_array[$prev_id]; -$next_href = $forumUrl.'viewthread.php?'.api_get_cidreq(). +$next_href = $forumUrl.'viewthread.php?'.api_get_cidreq(). '&forum='.$forumId.'&thread='.$threadId. '&post='.$prev_next_array[$next_id]; @@ -236,8 +229,9 @@ $groupInfo = GroupManager::get_group_properties($groupId); // 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 ( -(isset($groupInfo['iid']) && GroupManager::is_tutor_of_group(api_get_user_id(), $groupInfo)) || ( +if ((isset($groupInfo['iid']) && + GroupManager::is_tutor_of_group(api_get_user_id(), $groupInfo) + ) || ( $current_forum['allow_edit'] == 1 && $row['user_id'] == $_user['user_id'] ) || ( @@ -276,8 +270,9 @@ if (!empty($my_post) && is_array($my_post)) { $post_minor = (int) $id_posts[0]; } -if ( - (isset($groupInfo['iid']) && GroupManager::is_tutor_of_group(api_get_user_id(), $groupInfo)) || +if ((isset($groupInfo['iid']) && + GroupManager::is_tutor_of_group(api_get_user_id(), $groupInfo) + ) || api_is_allowed_to_edit(false, true) && !(api_is_session_general_coach() && $current_forum['session_id'] != $sessionId) ) { @@ -392,17 +387,16 @@ if (($current_forum_category && $current_forum_category['locked'] == 0) && echo ""; // Note: this can be removed here because it will be displayed in the tree -if ( - isset($whatsnew_post_info[$forumId][$threadId][$rows[$display_post_id]['post_id']]) AND - !empty($whatsnew_post_info[$forumId][$threadId][$rows[$display_post_id]['post_id']]) AND +if (isset($whatsnew_post_info[$forumId][$threadId][$rows[$display_post_id]['post_id']]) && + !empty($whatsnew_post_info[$forumId][$threadId][$rows[$display_post_id]['post_id']]) && !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'); } -if ( - $rows[$display_post_id]['post_notification'] == '1' AND + +if ($rows[$display_post_id]['post_notification'] == '1' && $rows[$display_post_id]['poster_id'] == $_user['user_id'] ) { $post_image .= Display::return_icon('forumnotification.gif', get_lang('YouWillBeNotified')); @@ -432,8 +426,7 @@ if (!empty($attachment_list) && is_array($attachment_list)) { echo ''. Security::remove_XSS($attachment['comment'], STUDENT).''; - if ( - ($current_forum['allow_edit'] == 1 && $rows[$display_post_id]['user_id'] == $_user['user_id']) || + if (($current_forum['allow_edit'] == 1 && $rows[$display_post_id]['user_id'] == $_user['user_id']) || (api_is_allowed_to_edit(false, true) && !(api_is_session_general_coach() && $current_forum['session_id'] != $sessionId)) ) { echo '