Moodle
  1. Moodle
  2. MDL-13888

Allow RSS block on MyMoodle pages only for users who can configure it

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.9
    • Fix Version/s: 2.0.10
    • Component/s: Blocks
    • Labels:
      None
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE
    • Rank:
      583

      Description

      When deploying myMoodle on my installation I realised that all users see the rss block in the drop-down list of things they can add to myMoodle.

      But, depending on the way you've got the roles & permissions set up, many users won't actually be able to do anything with it. I think that they need to be able to configure RSS feeds for themeselves or for others, or be able to pick from existing shared feeds to display in the block. If none of these things are true, the block will be there, but empty and pretty much useless.

      The code below checks the things above before it decided whether you can pick the block in myMoodle - by checking them during the applicable_formats block. This approach has been used elsewhere for deciding whether blocks are suitable for myMoodle, so I hope its OK. Would some-one review it for me please before I commit it? One thing I'm not sure about is whether the same test should control the all=> true/false as well?I'm thinking probably yes?

      function applicable_formats() {
      global $USER;
      $context = get_context_instance(CONTEXT_SYSTEM);
      $feeds = get_records_select('block_rss_client', 'userid = '.$USER->id.' OR shared = 1');
      if (has_capability('block/rss_client:createsharedfeeds', $context)

      has_capability('block/rss_client:createprivatefeeds', $context)
      $feeds) { return array('all' => true, 'my' => true, 'tag'=>false); }

      else

      { return array('all' => true, 'my' => false, 'tag'=>false); }

      }

        Activity

        Hide
        Martin Dougiamas added a comment -

        At a glance I think it makes good sense for 2.0.

        Should we fix it for 1.9 too? Nicolas can you look at this, do a bit of analysis of how the block performs in various contexts?

        Show
        Martin Dougiamas added a comment - At a glance I think it makes good sense for 2.0. Should we fix it for 1.9 too? Nicolas can you look at this, do a bit of analysis of how the block performs in various contexts?
        Hide
        Nicolas Connault added a comment -

        The solution is only partial. When there is a shared feed available, the block is enabled, but so is the "Manage all my feeds" tab. This tab is useless unless one of the first conditions are true (user has createsharefeeds or createprivatefeeds capability).

        Adding to Jenny's patch, I would change config_instance_tabs.php by adding a conditional statement around this tab:

        if (has_capability('block/rss_client:createprivatefeeds', $context) || has_capability('block/rss_client:createprivatefeeds', $context))

        { $row[] = new tabobject('managefeeds', $script, get_string('managefeeds', 'block_rss_client')); }
        Show
        Nicolas Connault added a comment - The solution is only partial. When there is a shared feed available, the block is enabled, but so is the "Manage all my feeds" tab. This tab is useless unless one of the first conditions are true (user has createsharefeeds or createprivatefeeds capability). Adding to Jenny's patch, I would change config_instance_tabs.php by adding a conditional statement around this tab: if (has_capability('block/rss_client:createprivatefeeds', $context) || has_capability('block/rss_client:createprivatefeeds', $context)) { $row[] = new tabobject('managefeeds', $script, get_string('managefeeds', 'block_rss_client')); }
        Hide
        Nicolas Connault added a comment -

        Attaching patch

        Show
        Nicolas Connault added a comment - Attaching patch
        Hide
        Petr Škoda added a comment -

        My -1 for caps in applicable formats - this function was not supposed to restrict the blocks per user; reviewed all of them, it is abused this way in adminbookmarks and some mnet block
        The problem is that if you edit course, some blocks may be removed by blocks_remove_inappropriate() if you do not have that capability.

        My +1 to rewrite blocks in 2.0 and solve this properly...

        Show
        Petr Škoda added a comment - My -1 for caps in applicable formats - this function was not supposed to restrict the blocks per user; reviewed all of them, it is abused this way in adminbookmarks and some mnet block The problem is that if you edit course, some blocks may be removed by blocks_remove_inappropriate() if you do not have that capability. My +1 to rewrite blocks in 2.0 and solve this properly...

          People

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

            Dates

            • Created:
              Updated: