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

Incorrect references to global $PAGE in blocklib.php. Should always use $this->page

    XMLWordPrintable

    Details

      Description

      This breaks the kind of code that automatically creates a Moodle coures, including blocks, by creating a $page object, and then using it to add blocks. E.g. this typical OU code.

              // Add some blocks.
              $coursepage = new \moodle_page();
              $coursepage->set_course($newcourse);
              $coursepage->set_pagetype('course-view-*');
              $coursepage->set_pagelayout('course');
              $coursepage->blocks->get_regions();
       
              // News, Resources, Forums, Recommender and Handy links on the right.
              $coursepage->blocks->add_block('oucontacttutor', 'side-post', -7, false);
              $coursepage->blocks->add_block('news', 'side-post', 10, false);
              $coursepage->blocks->add_block('ourecent_activity', 'side-post', 20, false);
              $coursepage->blocks->add_block('oukeycoursedates', 'side-post', 43, false);
      

      Several new methods added during the theme Boost changes break this rule. I'll fix them.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              timhunt Tim Hunt
              Reporter:
              timhunt Tim Hunt
              Peer reviewer:
              Jake Dallimore
              Integrator:
              Dan Poltawski
              Tester:
              CiBoT
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Bas Brands
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                13/Mar/17