Merge pull request #4938 from christianbeeznest/ofaj-21044-7

Forum: Fix visibility of forum in session course - BT#21044
pull/4939/head
christianbeeznest 1 year ago committed by GitHub
commit d4f7a6a073
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      public/main/forum/editpost.php
  2. 2
      public/main/forum/editthread.php
  3. 6
      public/main/forum/forumfunction.inc.php
  4. 2
      public/main/forum/forumqualify.php
  5. 6
      public/main/forum/iframe_thread.php
  6. 4
      public/main/forum/index.php
  7. 6
      public/main/forum/newthread.php
  8. 8
      public/main/forum/reply.php
  9. 12
      public/main/forum/viewforum.php
  10. 6
      public/main/forum/viewthread.php
  11. 14
      src/CoreBundle/Entity/AbstractResource.php

@ -122,8 +122,8 @@ $post = $postRepo->find($_GET['post']);
$courseEntity = api_get_course_entity();
$sessionEntity = api_get_session_entity();
$forumIsVisible = $forum->isVisible($courseEntity, $sessionEntity);
$categoryIsVisible = $category->isVisible($courseEntity, $sessionEntity);
$forumIsVisible = $forum->isVisible($courseEntity);
$categoryIsVisible = $category->isVisible($courseEntity);
if (empty($post)) {
api_not_allowed(true);
@ -208,7 +208,7 @@ JS;
// 4. if editing of replies is not allowed
// The only exception is the course manager
// I have split this is several pieces for clarity.
if (!api_is_allowed_to_edit(null, true) &&
if (!api_is_allowed_to_create_course() &&
(
(false === $categoryIsVisible) ||
false === $forumIsVisible

@ -93,7 +93,7 @@ $sessionEntity = api_get_session_entity();
//$forumIsVisible = $forum->isVisible($courseEntity, $sessionEntity);
$category = $forum->getForumCategory();
$categoryIsVisible = $category->isVisible($courseEntity, $sessionEntity);
$categoryIsVisible = $category->isVisible($courseEntity);
if (api_is_in_gradebook()) {
$interbreadcrumb[] = [

@ -3291,9 +3291,9 @@ function send_notification_mails(CForum $forum, CForumThread $thread, $reply_inf
}
$send_mails = false;
if ($thread->isVisible($courseEntity, $sessionEntity) &&
$forum->isVisible($courseEntity, $sessionEntity) &&
($current_forum_category && $forum->getForumCategory()->isVisible($courseEntity, $sessionEntity)) &&
if ($thread->isVisible($courseEntity) &&
$forum->isVisible($courseEntity) &&
($current_forum_category && $forum->getForumCategory()->isVisible($courseEntity)) &&
'1' != $forum->getApprovalDirectPost()
) {
$send_mails = true;

@ -95,7 +95,7 @@ $allowToQualify = false;
if ($allowed_to_edit) {
$allowToQualify = true;
} else {
$allowToQualify = $threadEntity->isThreadPeerQualify() && $forumEntity->isVisible($course, $session) && $userIdToQualify != $currentUserId;
$allowToQualify = $threadEntity->isThreadPeerQualify() && $forumEntity->isVisible($course) && $userIdToQualify != $currentUserId;
}
if (!$allowToQualify) {

@ -53,9 +53,9 @@ $sessionEntity = api_get_session_entity(api_get_session_id());
/* Is the user allowed here? */
// if the user is not a course administrator and the forum is hidden
// then the user is not allowed here.
if (!api_is_allowed_to_edit(false, true) &&
(false == $forumEntity->isVisible($courseEntity, $sessionEntity) ||
false == $threadEntity->isVisible($courseEntity, $sessionEntity)
if (!api_is_allowed_to_create_course() &&
(false == $forumEntity->isVisible($courseEntity) ||
false == $threadEntity->isVisible($courseEntity)
)
) {
api_not_allowed(false);

@ -338,7 +338,7 @@ if (is_array($forumCategories)) {
$tools = null;
$forumCategoryInfo['url'] = 'index.php?'.api_get_cidreq().'&forumcategory='.$categoryId;
$visibility = $forumCategory->isVisible($courseEntity, $sessionEntity);
$visibility = $forumCategory->isVisible($courseEntity);
if (!empty($categoryId)) {
if (api_is_allowed_to_edit(false, true) &&
@ -454,7 +454,7 @@ if (is_array($forumCategories)) {
}
$groupId = $forum->getForumOfGroup();
$forumInfo['visibility'] = $forumVisibility = $forum->isVisible($courseEntity, $sessionEntity);
$forumInfo['visibility'] = $forumVisibility = $forum->isVisible($courseEntity);
/*$forumInfo['number_threads'] = isset($forum['number_of_threads'])
? (int) $forum['number_of_threads']
: 0;*/

@ -122,8 +122,8 @@ if (api_is_in_gradebook()) {
// 1. the forumcategory or forum is invisible (visibility==0) and the user is not a course manager
if (!api_is_allowed_to_create_course() && //is a student
(
($current_forum_category && false == $current_forum_category->isVisible($courseEntity, $sessionEntity)) ||
false == $current_forum_category->isVisible($courseEntity, $sessionEntity)
($current_forum_category && false == $current_forum_category->isVisible($courseEntity)) ||
false == $current_forum_category->isVisible($courseEntity)
)
) {
api_not_allowed(true);
@ -131,7 +131,7 @@ if (!api_is_allowed_to_create_course() && //is a student
// 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->isVisible($courseEntity, $sessionEntity) &&
(($current_forum_category->isVisible($courseEntity) &&
0 != $current_forum_category->getLocked()) || 0 != $forumEntity->getLocked())
) {
api_not_allowed();

@ -111,9 +111,9 @@ $current_forum_category = $forum->getForumCategory();
// 3. if anonymous posts are not allowed
// The only exception is the course manager
// I have split this is several pieces for clarity.
if (!api_is_allowed_to_edit(false, true) &&
(($current_forum_category && !$current_forum_category->isVisible($courseEntity, $sessionEntity)) ||
!$forum->isVisible($courseEntity, $sessionEntity))
if (!api_is_allowed_to_create_course() &&
(($current_forum_category && !$current_forum_category->isVisible($courseEntity)) ||
!$forum->isVisible($courseEntity))
) {
api_not_allowed(true);
}
@ -259,7 +259,7 @@ echo '<h1>';
echo Display::url(
prepare4display($forum->getForumTitle()),
'viewforum.php?'.api_get_cidreq().'&'.http_build_query(['forum' => $forumId]),
['class' => empty($forum->isVisible($courseEntity, $sessionEntity)) ? 'text-muted' : null]
['class' => empty($forum->isVisible($courseEntity)) ? 'text-muted' : null]
);
echo '</h1>';
echo '<p class="forum_description">'.prepare4display($forum->getForumComment()).'</p>';

@ -106,8 +106,8 @@ if (!empty($groupId)) {
// Course
if (!api_is_allowed_to_create_course() && //is a student
(
($category && false == $category->isVisible($courseEntity, $sessionEntity)) ||
!$category->isVisible($courseEntity, $sessionEntity)
($category && false == $category->isVisible($courseEntity)) ||
!$category->isVisible($courseEntity)
)
) {
api_not_allowed(true);
@ -116,8 +116,8 @@ if (!empty($groupId)) {
// Course
if (!api_is_allowed_to_create_course() && //is a student
(
($category && false == $category->isVisible($courseEntity, $sessionEntity)) ||
!$category->isVisible($courseEntity, $sessionEntity)
($category && false == $category->isVisible($courseEntity)) ||
!$category->isVisible($courseEntity)
)
) {
api_not_allowed(true);
@ -362,7 +362,7 @@ if (is_array($threads)) {
$threadId = $thread->getIid();
// 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) ||
!('0' == $thread->getThreadReplies() && '0' == $thread->isVisible($courseEntity, $sessionEntity))
!('0' == $thread->getThreadReplies() && '0' == $thread->isVisible($courseEntity))
) {
$title = '<a href="viewthread.php?'.api_get_cidreq().'&forum='.$forumId
."&thread={$threadId}&search="
@ -476,7 +476,7 @@ if (is_array($threads)) {
$iconsEdit .= returnVisibleInvisibleIcon(
'thread',
$thread->getIid(),
$thread->isVisible($courseEntity, $sessionEntity),
$thread->isVisible($courseEntity),
[
'forum' => $forumId,
'gid' => $groupId,

@ -278,8 +278,8 @@ if (!empty($groupId)) {
// then the user is not allowed here.
if (!api_is_allowed_to_create_course() &&
(
!$forumEntity->isVisible($courseEntity, $sessionEntity) ||
!$threadEntity->isVisible($courseEntity, $sessionEntity)
!$forumEntity->isVisible($courseEntity) ||
!$threadEntity->isVisible($courseEntity)
)
) {
api_not_allowed();
@ -712,7 +712,7 @@ $template->assign('posts', $postList);
$formToString = '';
$showForm = true;
if (!api_is_allowed_to_edit(false, true) &&
(($current_forum_category && 0 == !$current_forum_category->isVisible($courseEntity, $sessionEntity)) || !$forumEntity->isVisible($courseEntity, $sessionEntity))
(($current_forum_category && 0 == !$current_forum_category->isVisible($courseEntity)) || !$forumEntity->isVisible($courseEntity))
) {
$showForm = false;
}

@ -461,10 +461,18 @@ abstract class AbstractResource
$found = false;
$link = null;
foreach ($links as $link) {
if ($link->getCourse() === $course && $link->getSession() === $session) {
$found = true;
if ($session) {
if ($link->getCourse() === $course && $link->getSession() === $session) {
$found = true;
break;
break;
}
} else {
if ($link->getCourse() === $course) {
$found = true;
break;
}
}
}

Loading…
Cancel
Save