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

HTML Block on category page doesn't show embedded images for not-logged-in users

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 2.2.6, 2.3.3
    • 2.1.1, 2.2.1
    • Blocks
    • MOODLE_21_STABLE, MOODLE_22_STABLE
    • MOODLE_22_STABLE, MOODLE_23_STABLE
    • wip-mdl-29762
    • Hide

      Test 1
      As Admin:

      1. Access the course category page (site admin > courses > add/edit courses > select a categories
      2. Add HTML block, embedded an image for the content and save it
      3. Copy the site url

      On different browser (to make testing easier)

      1. Make sure you are not login to the system
      2. Paste the site url
        Make sure you are able to see the embedded image within the HTML block.

      Test 2
      As Admin:

      1. Access the course category page (site admin > courses > add/edit courses
      2. Add HTML block, embedded an image for the content and save it
        Make sure you are able to see the embedded image within the HTML block.
      Show
      Test 1 As Admin: Access the course category page (site admin > courses > add/edit courses > select a categories Add HTML block, embedded an image for the content and save it Copy the site url On different browser (to make testing easier) Make sure you are not login to the system Paste the site url Make sure you are able to see the embedded image within the HTML block. Test 2 As Admin: Access the course category page (site admin > courses > add/edit courses Add HTML block, embedded an image for the content and save it Make sure you are able to see the embedded image within the HTML block.

      Hints for solution:
      /pluginfile.php fetches context information from given context ID - line 55:
      list($context, $course, $cm) = get_context_info_array($contextid);
      Unfortunately, $course is null when viewing a block on a category page.

      Later, /pluginfile.php calls block_html_pluginfile($course, $birecord_or_cm, $context, $filearea, $args, $forcedownload) in /blocks/html/lib.php.
      There, login is required for the given course - line 32:
      require_course_login($course);
      Unfortunately, as $course is null, login requirement always fails for non-logged-in users and image isn't shown.

      A quick and dirty fix would be to replace line 32 in /blocks/html/lib.php

      require_course_login($course);

      with

      if ($course != null)
      require_course_login($course);

      But I'm quite sure that this would provoke some security issues so I would be grateful if you could provide a better fix

            rajeshtaneja Rajesh Taneja
            abias Alexander Bias
            Rossiani Wijaya Rossiani Wijaya
            Dan Poltawski Dan Poltawski
            David Monllaó David Monllaó
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.