Moodle

Subscribe to all forums in /forum/index.php not functioning

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.9.3
  • Fix Version/s: 1.9.5
  • Component/s: Forum
  • Labels:
    None
  • Affected Branches:
    MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_19_STABLE

Description

For non-admins: Subscribe to all forums from /forum/index.php (all forums in a course listing) does not function and users subscriptions are not changed. The unsubscribe from all does work. .

The errors in the php log for each forum that the script tries to subscribe to are along the lines of:

[Thu Jan 15 16:20:59 2009] [error] [client 144.32.148.21] PHP Notice: Context id 113 does not have valid path, please use build_context_path()<ul style="text-align: left"><li>line 375 of lib
accesslib.php: call to debugging()</li><li>line 125 of mod\\forum
index.php: call to has_capability()</li></ul> in \\lib
weblib.php on line 6923, referer: mod/forum/index.php?id=2

[Thu Jan 15 16:20:59 2009] [error] [client 144.32.148.21] PHP Notice: Undefined property: object::$contextlevel in \\lib
accesslib.php on line 442, referer: mod/forum/index.php?id=2

[Thu Jan 15 16:20:59 2009] [error] [client 144.32.148.21] PHP Notice: Undefined property: object::$path in \\lib
accesslib.php on line 371, referer: mod/forum/index.php?id=2

I've tried this on a fresh course and a fresh 1.9.3 install, so not sure why the contexts aren't right. As suggested, tried the rebuild context script but no change. In mod/forum/index.php I can force $cansub = true; to get it to work but that would open up security loopholes. Would this be a problem then with what gets passed (i.e. $cm) to the has_capability function??

I've done a couple of scenarios with a fresh install:

1) Student role only in course = doesn't work at all.

2) Student role on homepage and in course (our normal setup) = doesn't work for homepage forums, 'subscribe to all' works only for the first learning forum in course.

3) Student role granted site-wide (i.e. from Assign System Roles) = everything works ok.

Bug created after discussion:

http://moodle.org/mod/forum/discuss.php?d=114080

Students can obviously use the individual 'yes/no' buttons next to each forum for the time being and this bug does not affect the 'subscribe to THIS forum' link in each forum.

Issue Links

Activity

Hide
Garret Gengler added a comment -

I think this is the fix:

In mod/forum/index.php, around line 123:

/// Do course wide subscribe/unsubscribe
if (!is_null($subscribe) and !isguestuser() and !isguest()) {
foreach ($modinfo->instances['forum'] as $forumid=>$cm) {
$forum = $forums[$forumid];
$context = get_context_instance(CONTEXT_MODULE, $cm->id);

$cansub = false;
if (has_capability('mod/forum:viewdiscussion', $context)) { $cansub = true; }
if ($cansub && $cm->visible == 0 &&
!has_capability('mod/forum:managesubscriptions', $context))

{ $cansub = false; }

...

The original code (in v1.9.4) is passing a course module to has_capability. It needs to pass the course module's context... So I used get_context_instance to retrieve the appropriate context and passed that intsead of $cm.

I'll attach my changes as a diff. I don't have Moodle CVS access... Can someone confirm this is the fix, and pull it in?

Cheers,

Show
Garret Gengler added a comment - I think this is the fix: In mod/forum/index.php, around line 123: /// Do course wide subscribe/unsubscribe if (!is_null($subscribe) and !isguestuser() and !isguest()) { foreach ($modinfo->instances['forum'] as $forumid=>$cm) { $forum = $forums[$forumid]; $context = get_context_instance(CONTEXT_MODULE, $cm->id); $cansub = false; if (has_capability('mod/forum:viewdiscussion', $context)) { $cansub = true; } if ($cansub && $cm->visible == 0 && !has_capability('mod/forum:managesubscriptions', $context)) { $cansub = false; } ... The original code (in v1.9.4) is passing a course module to has_capability. It needs to pass the course module's context... So I used get_context_instance to retrieve the appropriate context and passed that intsead of $cm. I'll attach my changes as a diff. I don't have Moodle CVS access... Can someone confirm this is the fix, and pull it in? Cheers,
Hide
Garret Gengler added a comment -

this is a possible fix for this issue.

Show
Garret Gengler added a comment - this is a possible fix for this issue.
Hide
Dan Poltawski added a comment -

This fix looks good, thanks! I will test and apply the patch tomorrow.

(BTW: If you supply the patches in unified format we find it much easier to read - http://docs.moodle.org/en/Development:How_to_create_a_patch )

Show
Dan Poltawski added a comment - This fix looks good, thanks! I will test and apply the patch tomorrow. (BTW: If you supply the patches in unified format we find it much easier to read - http://docs.moodle.org/en/Development:How_to_create_a_patch )
Hide
Dan Poltawski added a comment -

Well i've done some testing tonight and I've fixed this in CVS. Thanks very much for the report and patch.

Show
Dan Poltawski added a comment - Well i've done some testing tonight and I've fixed this in CVS. Thanks very much for the report and patch.
Hide
Jerome Mouneyrac added a comment -

Fixed as said in MDL-15317
Thanks everybody

Show
Jerome Mouneyrac added a comment - Fixed as said in MDL-15317 Thanks everybody

People

Vote (2)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: