Moodle
  1. Moodle
  2. MDL-27058

Removing Forum from navigation block.

    Details

    • Database:
      Any
    • Testing Instructions:
      Hide

      1. Log in as an admin
      2. Check navadduserpostslinks is enabled
      3. Check that there is a `Forum posts` link in the `My profile` section of the navigation
      4. Disable navadduserpostslinks
      5. Check that there is no longer a `Forum posts` link

      Show
      1. Log in as an admin 2. Check navadduserpostslinks is enabled 3. Check that there is a `Forum posts` link in the `My profile` section of the navigation 4. Disable navadduserpostslinks 5. Check that there is no longer a `Forum posts` link
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_22_STABLE
    • Pull Master Branch:
      wip-MDL-27058-master
    • Rank:
      16693

      Description

      This issue is related somewhat to issue MDL-26967 which appears to be fixed by PULL-562. Also, see this (and other) forum posts: http://moodle.org/mod/forum/discuss.php?d=171315

      I believe the Forum links are confusing for the user when the capability is not present and results in multiple questions from students and guests asking how to use the forums. Disabling "See all user posts" (moodle/user:readuserposts) and "View discussions" (mod/forum:viewdiscussion) under "Site administration->Users->Permissions->Define roles->[Role]" should remove these options from the navigation block.

      Here is a suggested patch that does that for 2.X:

      Replace the following code within "/lib/navigationlib.php":

      // Add nodes for forum posts and discussions if the user can view either or both
      // There are no capability checks here as the content of the page is based
      // purely on the forums the current user has access too.
      $forumtab = $usernode->add(get_string('forumposts', 'forum'));
      $forumtab->add(get_string('posts', 'forum'), new moodle_url('/mod/forum/user.php', $baseargs));
      $forumtab->add(get_string('discussions', 'forum'), new moodle_url('/mod/forum/user.php', array_merge($baseargs, array('mode'=>'discussions'))));

      with this code:

      // Add nodes for forum posts and discussions if the user can view either or both
      $context = get_context_instance(CONTEXT_USER, $USER->id);
      if ($iscurrentuser && (has_capability('moodle/user:readuserposts', $context) || has_capability('mod/forum:viewdiscussion', $context))) {
      $forumtab = $usernode->add(get_string('forumposts', 'forum'));
      if (has_capability('moodle/user:readuserposts', $context))

      { $forumtab->add(get_string('posts', 'forum'), new moodle_url('/mod/forum/user.php', $baseargs)); }

      if (has_capability('mod/forum:viewdiscussion', $context))

      { $forumtab->add(get_string('discussions', 'forum'), new moodle_url('/mod/forum/user.php', array_merge($baseargs, array('mode'=>'discussions')))); }

      }

      Peace.

        Activity

        Hide
        Helen Foster added a comment -

        David, thanks for your report and for creating a patch.

        Show
        Helen Foster added a comment - David, thanks for your report and for creating a patch.
        Hide
        David Upson added a comment -

        Thank you, Helen. I hope others find this helpful. I personally believe that hard-coding program behavior when the option to not do so already exists in the code is a mistake. There is perhaps a good reason not to do it this way, but I haven't discovered it yet. It looks to me based on the code comments that it is just one of those things that someone never got back to changing because it doesn't really impact program functionality. In other words, it wasn't really broken. There are only so many hours in a day.

        Peace.

        Show
        David Upson added a comment - Thank you, Helen. I hope others find this helpful. I personally believe that hard-coding program behavior when the option to not do so already exists in the code is a mistake. There is perhaps a good reason not to do it this way, but I haven't discovered it yet. It looks to me based on the code comments that it is just one of those things that someone never got back to changing because it doesn't really impact program functionality. In other words, it wasn't really broken. There are only so many hours in a day. Peace.
        Hide
        David Upson added a comment -

        Thank you, Martin.

        Show
        David Upson added a comment - Thank you, Martin.
        Hide
        Sam Hemelryk added a comment -

        Hi guys,

        I've been looking at this just now.
        First up there have been serious changes to the forum user posts scripts in the latest weekly.
        Because of this I am very familiar at the moment with those scripts.
        Unfortunately the solution purposed David wouldn't be applicable as the capabilities you have used are respective of the forum and user capabilities however these links are shown all throughout the site. It is possible to check with a user whether it is applicable to show these links by checking all forums and if viewing another user cross user access however it is very painstaking and a big performance hi; not something we want to introduce to the navigation.

        However I know that not everyone wants these links and there have been several instances where people would rather they were not there.
        As such I have created a patch that introduces a new setting that allows the admin of a site to choose leave them off the navigation.

        I'm putting these changes up for peer-review now.

        Cheers
        Sam

        Show
        Sam Hemelryk added a comment - Hi guys, I've been looking at this just now. First up there have been serious changes to the forum user posts scripts in the latest weekly. Because of this I am very familiar at the moment with those scripts. Unfortunately the solution purposed David wouldn't be applicable as the capabilities you have used are respective of the forum and user capabilities however these links are shown all throughout the site. It is possible to check with a user whether it is applicable to show these links by checking all forums and if viewing another user cross user access however it is very painstaking and a big performance hi; not something we want to introduce to the navigation. However I know that not everyone wants these links and there have been several instances where people would rather they were not there. As such I have created a patch that introduces a new setting that allows the admin of a site to choose leave them off the navigation. I'm putting these changes up for peer-review now. Cheers Sam
        Hide
        Sam Hemelryk added a comment -

        Putting this up for integration

        Show
        Sam Hemelryk added a comment - Putting this up for integration
        Hide
        Aparup Banerjee added a comment -

        thanks this has been integrated and ready for testing.

        (the default is correct right?)

        Show
        Aparup Banerjee added a comment - thanks this has been integrated and ready for testing. (the default is correct right?)
        Hide
        Rossiani Wijaya added a comment -

        This is working great.

        Thanks Sam.

        Test passed.

        Show
        Rossiani Wijaya added a comment - This is working great. Thanks Sam. Test passed.
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Many thanks for the hard work developing and testing this. It has been spread to cvs and git upstream repositories.

        Closing, ciao

        Show
        Eloy Lafuente (stronk7) added a comment - Many thanks for the hard work developing and testing this. It has been spread to cvs and git upstream repositories. Closing, ciao
        Hide
        Susan Mangan added a comment -

        I'm running 2.3.2+ (Build: 20120920)

        I'm 99.99% positive the Teacher role had the capability to view all student forum posts (via the navigation block) before we upgraded to this version approx one month ago. They no longer have this capability even when navadduserpostslinks is enabled via the Admin settings. It seems access to the Navigation block disappears when a teacher clicks on a student name.

        Admin does have this capability when clicking on Full Profile.

        Is this somehow related?

        Show
        Susan Mangan added a comment - I'm running 2.3.2+ (Build: 20120920) I'm 99.99% positive the Teacher role had the capability to view all student forum posts (via the navigation block) before we upgraded to this version approx one month ago. They no longer have this capability even when navadduserpostslinks is enabled via the Admin settings. It seems access to the Navigation block disappears when a teacher clicks on a student name. Admin does have this capability when clicking on Full Profile. Is this somehow related?

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: