]> git.mjollnir.org Git - moodle.git/commitdiff
accesslib: build_context_path() now sets path/depth for other blocks
authormartinlanghoff <martinlanghoff>
Wed, 19 Sep 2007 07:56:14 +0000 (07:56 +0000)
committermartinlanghoff <martinlanghoff>
Wed, 19 Sep 2007 07:56:14 +0000 (07:56 +0000)
Blocks not on the coursepage should have their context "hanging" from the
site context. get_context_instance() was doing this correctly, but not
build_context_path().

lib/accesslib.php

index 26a12c8f1beb44490816478929210c7513d4dbf3..539de87ac034e439d73960c168508f2bcaf4d862 100755 (executable)
@@ -4464,7 +4464,7 @@ function build_context_path($force=false) {
                   $emptyclause ";
         execute_sql($sql, false);
 
-    // Blocks - non-pinned only
+    // Blocks - non-pinned course-view only
     $sql = "UPDATE {$CFG->prefix}context
               SET depth=it.pdepth+1, path=" . sql_concat('it.ppath', "'/'", 'id') . "
             FROM (SELECT bi.id AS instanceid, pctx.path AS ppath,
@@ -4480,6 +4480,18 @@ function build_context_path($force=false) {
                   $emptyclause ";
     execute_sql($sql, false);
 
+    // Blocks - others
+    $sql = "UPDATE {$CFG->prefix}context
+              SET depth=2, path=" . sql_concat("'$base/'", 'id') . "
+            FROM (SELECT bi.id AS instanceid
+                  FROM {$CFG->prefix}block_instance bi
+                        WHERE bi.pagetype != 'course-view'
+                  ) AS it
+            WHERE contextlevel=".CONTEXT_BLOCK."
+                  AND {$CFG->prefix}context.instanceid=it.instanceid
+                  $emptyclause ";
+    execute_sql($sql, false);
+
     // User
     $sql = "UPDATE {$CFG->prefix}context
               SET depth=2, path=".sql_concat("'$base/'", 'id')."