Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.9.1, 1.9.2
-
Fix Version/s: None
-
Component/s: Forum
-
Labels:None
-
Affected Branches:MOODLE_19_STABLE
Description
In a Q and A type, a person cannot view posts until they post something of their own. When the profile view is generated, it applies this logic, but does not obey they 'View Without Posting' permission.
I've found a work around based on the way mod/forum/lib.php - forum_get_readable_forums works.
Down on line 1621, it checks to see if the user has mod/forum:viewqandawithoutposting. If they don't, to creates an empty array in $forum->onlydiscussions, then populates it with discussions they have posted in. If they do have this perm, it totally skips this step, so $forum->onlydiscussions is not set.
In mod/forum/lib.php - forum_search_posts it only checks empty($forum->onlydiscussions) or not, but not viewqandawithoutposting, so if have viewqandawithoutposting but have not posted in the discussion, you cannot see the other posts in the discussion listed there, even though you should.
The workaround I have made takes advantage of the fact that for someone without the perm, $forum->onlydiscussions is an empty array, while with someone with the perm, $forum->onlydiscussions is not set, so I changed the block starting on line 1681 from:
if ($forum->type == 'qanda') {
if (!empty($forum->onlydiscussions)) {
$discussionsids = implode(',', $forum->onlydiscussions);
$select[] = "(d.id IN ($discussionsids) OR p.parent = 0)";
} else {
$select[] = "p.parent = 0";
}
}
to (only 5th line changes):
if ($forum->type == 'qanda') {
if (!empty($forum->onlydiscussions)) { $discussionsids = implode(',', $forum->onlydiscussions); $select[] = "(d.id IN ($discussionsids) OR p.parent = 0)"; } } elseif (isset($forum->onlydiscussions)) {
$select[] = "p.parent = 0";
}
}
This seems like there should be a cleaner solution, but i dont know.
Attachments
Issue Links
| This issue is duplicated by: | ||||
| MDL-16883 | Teacher can not view student replies in QandA forum on the user's profile Forum posts tab |
|
|
|
It might be a bit more straightforward to just check for the mod/forum:viewqandawithoutposting capability when building the select. A patch is attached.