Project

General

Profile

Bug #7034

Search function in forum

Added by Udo Scharf over 5 years ago. Updated over 5 years ago.

Status:
Bug resolved
Priority:
Normal
Assignee:
Category:
Forum
Target version:
Start date:
27/03/2014
Due date:
% Done:

100%

Estimated time:
0.00 h
Complexity:
Normal
SCRUM pts - complexity:
?

Description

Hi,
I found out that the search in the forum will give a result of all forums posts in a course, each time, even if they should not be visible or are part of a session forum.

Here is the solution:

In main/forum/forumfunction.inc.php
change the function
display_forum_search_results()
add
$table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
$session_id = api_get_session_id();

and change the SQL-statement to:

$sql = "SELECT posts.* FROM $table_posts posts, $table_threads threads, $table_item_property item_property
WHERE
posts.c_id = $course_id
AND item_property.c_id = $course_id
AND posts.thread_id=threads.thread_id
AND item_property.ref=threads.thread_id
AND item_property.visibility=1
AND item_property.id_session=$session_id
AND posts.visible=1
AND item_property.tool='".TOOL_FORUM_THREAD."'
AND ".implode(' AND ', $search_restriction)."
GROUP BY posts.post_id";

Associated revisions

Revision 4a3b890e (diff)
Added by Udo Scharf over 5 years ago

Fix forum search - see #7034

History

#1

Updated by Udo Scharf over 5 years ago

A lttle change in the sql-statement
$sql = "SELECT posts.* FROM $table_posts posts, $table_threads threads, $table_item_property item_property
WHERE
posts.c_id = $course_id
AND item_property.c_id = $course_id
AND posts.thread_id=threads.thread_id
AND item_property.ref=threads.thread_id
AND item_property.visibility=1
AND item_property.id_session=$session_id
AND posts.visible=1
AND item_property.tool='".TOOL_FORUM_THREAD."'
AND item_property.visibility <> 2
AND ".implode(' AND ', $search_restriction)."
GROUP BY posts.post_id";

Now post of invisbile threads will not be shown...

#2

Updated by Yannick Warnier over 5 years ago

  • Description updated (diff)
  • Status changed from New to Assigned
  • Assignee set to Yannick Warnier

Udo, do you have a GitHub account to give you credits for the commit, there?

#3

Updated by Yannick Warnier over 5 years ago

  • Status changed from Assigned to Bug resolved
  • Assignee changed from Yannick Warnier to Udo Scharf
  • % Done changed from 0 to 100

Tested, approved and pushed to github using scharf at connexus dot de as author

Also available in: Atom PDF