Moodle
  1. Moodle
  2. MDL-13888

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

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Inactive
    • 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

      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); }

      }

        Gliffy Diagrams

          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 Skoda 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 Skoda 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...
          Hide
          Marina Glancy added a comment -

          We have detected that this issue has been inactive for over two years and also did not collect many votes. It is possible that it has been already implemented in a more recent version of Moodle, or it is not highly demanded. There are unlimited number of ways Moodle functinality can be expanded and improved but we would like to concentrate on the features that will benefit majority of users, and which can not be implemented as plugins. If you have a suggestion for improving Moodle core, and there is no open issue for it in the tracker, please start a new forum discussion to see how many other users agree with you, and then create a new issue providing as many details as possible.

          ==BLK2YIMP20141121==

          Show
          Marina Glancy added a comment - We have detected that this issue has been inactive for over two years and also did not collect many votes. It is possible that it has been already implemented in a more recent version of Moodle, or it is not highly demanded. There are unlimited number of ways Moodle functinality can be expanded and improved but we would like to concentrate on the features that will benefit majority of users, and which can not be implemented as plugins. If you have a suggestion for improving Moodle core, and there is no open issue for it in the tracker, please start a new forum discussion to see how many other users agree with you, and then create a new issue providing as many details as possible. ==BLK2YIMP20141121==

            People

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

              Dates

              • Created:
                Updated:
                Resolved: