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

Allow custom context levels to be specified in config table, as serialized array, and allow cached levels to be reset by plugin install

    Details

      Description

      Allow custom context levels to be specified in config table, as serialized array, and allow cached levels to be reset by plugin install.

      These changes are required to allow [Remote-Learner's ELIS] custom contexts to function correctly.

        Gliffy Diagrams

          Activity

          Show
          cibot CiBoT added a comment - Results for MDL-43635 Remote repository: https://github.com/brentboghosian/moodle2.git Remote branch MDL-43635 -m26 to be integrated into upstream MOODLE_26_STABLE Executed job http://integration.moodle.org/job/Precheck%20remote%20branch/550 Details: http://integration.moodle.org/job/Precheck%20remote%20branch/550/artifact/work/smurf.html Remote branch MDL-43635 -m27 to be integrated into upstream master Executed job http://integration.moodle.org/job/Precheck%20remote%20branch/551 Details: http://integration.moodle.org/job/Precheck%20remote%20branch/551/artifact/work/smurf.html
          Hide
          jfilip Justin Filip added a comment - - edited

          Just an FYI, I did not do the work on this, James McQuillan and Brent Boghosian both did but neither has a developer role so I can't assign the issue to them.

          Show
          jfilip Justin Filip added a comment - - edited Just an FYI, I did not do the work on this, James McQuillan and Brent Boghosian both did but neither has a developer role so I can't assign the issue to them.
          Show
          cibot CiBoT added a comment - Results for MDL-43635 Remote repository: https://github.com/brentboghosian/moodle2.git Remote branch MDL-43635 -m26 to be integrated into upstream MOODLE_26_STABLE Executed job http://integration.moodle.org/job/Precheck%20remote%20branch/555 Details: http://integration.moodle.org/job/Precheck%20remote%20branch/555/artifact/work/smurf.html Remote branch MDL-43635 -m27 to be integrated into upstream master Executed job http://integration.moodle.org/job/Precheck%20remote%20branch/556 Details: http://integration.moodle.org/job/Precheck%20remote%20branch/556/artifact/work/smurf.html
          Show
          cibot CiBoT added a comment - Results for MDL-43635 Remote repository: https://github.com/brentboghosian/moodle2.git Remote branch MDL-43635 -m26 to be integrated into upstream MOODLE_26_STABLE Executed job http://integration.moodle.org/job/Precheck%20remote%20branch/585 Details: http://integration.moodle.org/job/Precheck%20remote%20branch/585/artifact/work/smurf.html Remote branch MDL-43635 -m27 to be integrated into upstream master Executed job http://integration.moodle.org/job/Precheck%20remote%20branch/588 Details: http://integration.moodle.org/job/Precheck%20remote%20branch/588/artifact/work/smurf.html
          Hide
          brentboghosian Brent Boghosian added a comment -

          Have to make small change to PHPUnit test to reset after test to restore any existing custom contexts - shall be completed 14/02/11

          Show
          brentboghosian Brent Boghosian added a comment - Have to make small change to PHPUnit test to reset after test to restore any existing custom contexts - shall be completed 14/02/11
          Hide
          brentboghosian Brent Boghosian added a comment -

          Change to PHPUnit tests complete - squashed commit & updated issue.

          Show
          brentboghosian Brent Boghosian added a comment - Change to PHPUnit tests complete - squashed commit & updated issue.
          Hide
          cibot CiBoT added a comment -
          Show
          cibot CiBoT added a comment - Results for MDL-43635 Remote repository: https://github.com/brentboghosian/moodle2.git Remote branch MDL-43635 -m26 to be integrated into upstream MOODLE_26_STABLE Executed job http://integration.moodle.org/job/Precheck%20remote%20branch/1323 Details: http://integration.moodle.org/job/Precheck%20remote%20branch/1323/artifact/work/smurf.html Remote branch MDL-43635 -m27 to be integrated into upstream master Executed job http://integration.moodle.org/job/Precheck%20remote%20branch/1324 Warning: The MDL-43635 -m27 branch at https://github.com/brentboghosian/moodle2.git has not been rebased recently (>20 days ago). Details: http://integration.moodle.org/job/Precheck%20remote%20branch/1324/artifact/work/smurf.html
          Hide
          jfilip Justin Filip added a comment -

          Petr Skoda I think we probably need your eyes on this one? It relates to the changes that you had originally made in MDL-20045.

          Show
          jfilip Justin Filip added a comment - Petr Skoda I think we probably need your eyes on this one? It relates to the changes that you had originally made in MDL-20045 .
          Hide
          brentboghosian Brent Boghosian added a comment -

          Rebased m27 branch & updated issue

          Show
          brentboghosian Brent Boghosian added a comment - Rebased m27 branch & updated issue
          Hide
          dougiamas Martin Dougiamas added a comment -

          +10 to get this in 2.6 as well as 2.7.

          Show
          dougiamas Martin Dougiamas added a comment - +10 to get this in 2.6 as well as 2.7.
          Hide
          skodak Petr Skoda added a comment -

          Hello, I think the change in initialise_cfg() is not a good idea. I would personally prefer if all the hacking was done strictly in init_levels, such as:

                  if (empty($CFG->custom_context_classes)) {
                      return;
                  }
           
                  $levels = $CFG->custom_context_classes;
                  if (!is_array($levels)) {
                      $levels = @unserialize($levels);
                  }
                  if (!is_array($levels)) {
                      debugging('Invalid $CFG->custom_context_classes detected, value ignored.', DEBUG_DEVELOPER);
                      return;
                  }
           
                  // Unsupported custom levels, use with care!!!
                  foreach ($levels as $level => $classname) {
                      self::$alllevels[$level] = $classname;
                  }
                  ksort(self::$alllevels);

          (note: sample code not tested)

          Show
          skodak Petr Skoda added a comment - Hello, I think the change in initialise_cfg() is not a good idea. I would personally prefer if all the hacking was done strictly in init_levels, such as: if (empty($CFG->custom_context_classes)) { return; }   $levels = $CFG->custom_context_classes; if (!is_array($levels)) { $levels = @unserialize($levels); } if (!is_array($levels)) { debugging('Invalid $CFG->custom_context_classes detected, value ignored.', DEBUG_DEVELOPER); return; }   // Unsupported custom levels, use with care!!! foreach ($levels as $level => $classname) { self::$alllevels[$level] = $classname; } ksort(self::$alllevels); (note: sample code not tested)
          Hide
          jamesmcq24 James McQuillan added a comment -

          We'll have to test it to make sure, but I think that should work.

          Show
          jamesmcq24 James McQuillan added a comment - We'll have to test it to make sure, but I think that should work.
          Hide
          skodak Petr Skoda added a comment -

          Hello, $CFG->custom_context_classes is fine for use both from DB and config.php, thanks for testing it.

          Show
          skodak Petr Skoda added a comment - Hello, $CFG->custom_context_classes is fine for use both from DB and config.php, thanks for testing it.
          Hide
          dougiamas Martin Dougiamas added a comment -

          Update us here when it's ready, James, so we can push to integration asap.

          Show
          dougiamas Martin Dougiamas added a comment - Update us here when it's ready, James, so we can push to integration asap.
          Hide
          jamesmcq24 James McQuillan added a comment - - edited

          This looks good to me, my tests pass (with some minor modifications to the added unit test). Brent is testing as well and is updating the pull request. He'll update here when it's ready.

          Show
          jamesmcq24 James McQuillan added a comment - - edited This looks good to me, my tests pass (with some minor modifications to the added unit test). Brent is testing as well and is updating the pull request. He'll update here when it's ready.
          Hide
          brentboghosian Brent Boghosian added a comment -

          Requested changes made - squashed to single commit in both m26 & m27 branches.
          Tested ok. Code should now be ready for integration.

          Show
          brentboghosian Brent Boghosian added a comment - Requested changes made - squashed to single commit in both m26 & m27 branches. Tested ok. Code should now be ready for integration.
          Hide
          cibot CiBoT added a comment -
          Show
          cibot CiBoT added a comment - Results for MDL-43635 Remote repository: https://github.com/brentboghosian/moodle2.git Remote branch MDL-43635 -m26 to be integrated into upstream MOODLE_26_STABLE Executed job http://integration.moodle.org/job/Precheck%20remote%20branch/1894 Warning: The MDL-43635 -m26 branch at https://github.com/brentboghosian/moodle2.git has not been rebased recently (>20 days ago). Details: http://integration.moodle.org/job/Precheck%20remote%20branch/1894/artifact/work/smurf.html Remote branch MDL-43635 -m27 to be integrated into upstream master Executed job http://integration.moodle.org/job/Precheck%20remote%20branch/1895 Details: http://integration.moodle.org/job/Precheck%20remote%20branch/1895/artifact/work/smurf.html
          Hide
          skodak Petr Skoda added a comment -

          sending to integration, cheers

          Show
          skodak Petr Skoda added a comment - sending to integration, cheers
          Hide
          poltawski Dan Poltawski added a comment -

          I'm pulling this into this weeks integration. Note that its arrived a bit late, so we'll see if we are able to get to it.

          Show
          poltawski Dan Poltawski added a comment - I'm pulling this into this weeks integration. Note that its arrived a bit late, so we'll see if we are able to get to it.
          Hide
          damyon Damyon Wiese added a comment -

          Thanks, this seems pretty safe, although I must say the test does not test much. IMO it could be improved, e.g. by assigning some capabilities at a custom context level and then testing some access checks.

          Also - I noticed too late for the 26 branch that the commit message was badly formatted. I fixed it for master, but it was not worth rewriting history on the 26 branch.

          Here is the documentation on proper git commit messages:
          http://docs.moodle.org/dev/Commit_cheat_sheet

          Integrated to 26 and master and tests have been run.

          Show
          damyon Damyon Wiese added a comment - Thanks, this seems pretty safe, although I must say the test does not test much. IMO it could be improved, e.g. by assigning some capabilities at a custom context level and then testing some access checks. Also - I noticed too late for the 26 branch that the commit message was badly formatted. I fixed it for master, but it was not worth rewriting history on the 26 branch. Here is the documentation on proper git commit messages: http://docs.moodle.org/dev/Commit_cheat_sheet Integrated to 26 and master and tests have been run.
          Hide
          damyon Damyon Wiese added a comment -

          Passing.

          Show
          damyon Damyon Wiese added a comment - Passing.
          Hide
          stronk7 Eloy Lafuente (stronk7) added a comment -

          For fun: http://www.youtube.com/watch?v=IGENkpaPkgw

          Many thanks for your hard work, this is now part of Moodle!

          Ciao

          Show
          stronk7 Eloy Lafuente (stronk7) added a comment - For fun: http://www.youtube.com/watch?v=IGENkpaPkgw Many thanks for your hard work, this is now part of Moodle! Ciao

            People

            • Votes:
              2 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                10/Mar/14