Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-13888

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

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Inactive
    • Affects Version/s: 1.9
    • Fix Version/s: None
    • Component/s: Blocks
    • Labels:
      None
    • Affected Branches:
      MOODLE_19_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); }

      }

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: