Merge remote-tracking branch 'origin/master'

pull/5595/head
Angel Fernando Quiroz Campos 5 months ago
commit 7963adc8a0
No known key found for this signature in database
GPG Key ID: B284841AE3E562CD
  1. 57
      public/main/forum/forumfunction.inc.php
  2. 4
      public/main/forum/index.php
  3. 2
      public/main/forum/viewforum.php
  4. 23
      public/main/lp/learnpath.class.php

@ -1105,12 +1105,13 @@ function get_forum_categories(int $courseId = 0, int $sessionId = 0): Array
*
* @version february 2006, dokeos 1.8
*/
function get_forums_in_category(int $categoryId, int $courseId = 0)
function get_forums_in_category(int $categoryId, int $courseId = 0, int $sessionId = 0)
{
$repo = Container::getForumRepository();
$course = api_get_course_entity($courseId);
$session = api_get_session_entity($sessionId);
$qb = $repo->getResourcesByCourse($course, null, null, null, true, true);
$qb = $repo->getResourcesByCourse($course, $session, null, null, true, true);
$qb
->andWhere('resource.forumCategory = :catId')
->setParameter('catId', $categoryId)
@ -3357,7 +3358,7 @@ function send_mail($userInfo, CForum $forum, CForumThread $thread, CForumPost $p
$threadId = $thread->getIid();
$thread_link = api_get_path(WEB_CODE_PATH).
'forum/viewthread.php?'.api_get_cidreq().'&forum='.$forumId.'&thread='.$threadId;
'forum/viewthread.php?'.api_get_cidreq(true, true, false).'&forum='.$forumId.'&thread='.$threadId;
$email_body = get_lang('Dear').' '.
api_get_person_name($userInfo['firstname'], $userInfo['lastname'], null, PERSON_NAME_EMAIL_ADDRESS).", <br />\n\r";
@ -5357,7 +5358,7 @@ function reportPost(CForumPost $post, CForum $forumInfo, CForumThread $threadInf
$users = getReportRecipients();
if (!empty($users)) {
$url = api_get_path(WEB_CODE_PATH).
'forum/viewthread.php?forum='.$forumInfo->getIid().'&thread='.$threadInfo->getIid().'&'.api_get_cidreq().'&post_id='.$postId.'#post_id_'.$postId;
'forum/viewthread.php?forum='.$forumInfo->getIid().'&thread='.$threadInfo->getIid().'&'.api_get_cidreq(true, true, false).'&post_id='.$postId.'#post_id_'.$postId;
$postLink = Display::url(
$post->getTitle(),
$url
@ -5376,3 +5377,51 @@ function reportPost(CForumPost $post, CForum $forumInfo, CForumThread $threadInf
return true;
}
function getVisibleForums($courseId, $sessionId): array
{
$forums = get_forums($courseId, $sessionId);
$visibleForums = [];
foreach ($forums as $forum) {
$forumSession = $forum->getFirstResourceLink()->getSession();
if ($sessionId > 0) {
if (null === $forumSession) {
$threads = get_threads($forum->getIid(), $courseId, $sessionId, true);
if (!empty($threads)) {
$visibleForums[] = $forum;
}
} else {
$visibleForums[] = $forum;
}
} else {
$visibleForums[] = $forum;
}
}
return $visibleForums;
}
function getVisibleForumsInCategory($categoryId, $courseId, $sessionId): array
{
$forumsInCategory = get_forums_in_category($categoryId, $courseId, $sessionId);
$visibleForums = [];
foreach ($forumsInCategory as $forum) {
$forumSession = $forum->getFirstResourceLink()->getSession();
if ($sessionId > 0) {
if (null === $forumSession) {
$threads = get_threads($forum->getIid(), $courseId, $sessionId, true);
if (!empty($threads)) {
$visibleForums[] = $forum;
}
} else {
$visibleForums[] = $forum;
}
} else {
$visibleForums[] = $forum;
}
}
return $visibleForums;
}

@ -179,7 +179,7 @@ $forumCategories = get_forum_categories();
// Step 2: We find all the forums (only the visible ones if it is a student).
// display group forum in general forum tool depending to configuration option
$setting = api_get_setting('display_groups_forum_in_general_tool');
$allCourseForums = get_forums();
$allCourseForums = getVisibleForums($courseId, $sessionId);
$user_id = api_get_user_id();
/* RETRIEVING ALL GROUPS AND THOSE OF THE USER */
@ -399,7 +399,7 @@ if (is_array($forumCategories)) {
$forumCategoryInfo['forums'] = [];
// The forums in this category.
$forumInfo = [];
$forumsInCategory = get_forums_in_category($categoryId, $courseId);
$forumsInCategory = getVisibleForumsInCategory($categoryId, $courseId, $sessionId);
if (!empty($forumsInCategory)) {
$forumsDetailsList = [];

@ -494,7 +494,7 @@ if (is_array($threads)) {
}
}
if (!api_is_anonymous() && api_is_allowed_to_session_edit(false, true)) {
$iconsEdit .= '<a href="'.$url.'&forum='.$forumId."&action=notify&content=thread&id={$threadId}".'">'.
$iconsEdit .= '<a href="'.$viewForumUrl.'&forum='.$forumId."&action=notify&content=thread&id={$threadId}".'">'.
Display::getMdiIcon('email-alert', ($disable ? 'ch-tool-icon-disabled' : 'ch-tool-icon'), '', ICON_SIZE_SMALL, get_lang('Notify me')).'</a>';
}

@ -6794,7 +6794,10 @@ class learnpath
}
</script>';
$moveIcon = Display::getMdiIcon('cursor-move', 'ch-tool-icon', '', 16, get_lang('Move'));
$userRights = api_is_allowed_to_edit(false, true);
foreach ($a_forums as $forum) {
$forumSession = $forum->getFirstResourceLink()->getSession();
$isForumSession = (null !== $forumSession);
$forumId = $forum->getIid();
$title = Security::remove_XSS($forum->getTitle());
$link = Display::url(
@ -6813,8 +6816,14 @@ class learnpath
$return .= ' </a>';
$return .= Display::getMdiIcon('comment-quote', 'ch-tool-icon', null, 16, get_lang('Forum'));
$alertIcon = '';
if (!$isForumSession && $userRights) {
$tooltip = get_lang('This Learningpath includes a forum in the base course, so once users in a session will participate in this forum, it will start to appear in the forum tool in the session, whereas by default forums from the base course do not appear in the session.');
$alertIcon = Display::return_icon('warning.png', $tooltip, null, ICON_SIZE_SMALL);
}
$moveLink = Display::url(
$title.' '.$link,
$title,
api_get_self().'?'.
api_get_cidreq().'&action=add_item&type='.TOOL_FORUM.'&forum_id='.$forumId.'&lp_id='.$this->lp_id,
[
@ -6826,12 +6835,12 @@ class learnpath
]
);
$return .= '<a onclick="javascript:toggle_forum('.$forumId.');" style="cursor:hand; vertical-align:middle">
<img
src="'.Display::returnIconPath('add.png').'"
id="forum_'.$forumId.'_opener" align="absbottom"
/>
</a>
'.$moveLink;
<img
src="'.Display::returnIconPath('add.png').'"
id="forum_'.$forumId.'_opener" align="absbottom"
/>
</a>
'.$moveLink. ' '.$alertIcon;
$return .= '</li>';
$return .= '<div style="display:none" id="forum_'.$forumId.'_content">';

Loading…
Cancel
Save