]> git.mjollnir.org Git - moodle.git/commitdiff
accesslib:content_moved() fix bug in depth handling
authormartinlanghoff <martinlanghoff>
Wed, 19 Sep 2007 07:14:11 +0000 (07:14 +0000)
committermartinlanghoff <martinlanghoff>
Wed, 19 Sep 2007 07:14:11 +0000 (07:14 +0000)
the depth was getting a bit out-of-control when moving
up the tree. Fix it...

lib/accesslib.php

index d0e226b0efa6a0d9c6aa6cf7107676f0de0c1b80..4b61c4378156f799c45d733cbea06529a58647fb 100755 (executable)
@@ -4759,8 +4759,8 @@ function context_moved($context, $newparent) {
     $newpath  = $newparent->path . '/' . $context->id;
 
     $setdepth = '';
-    if ($newparent->depth +1 != $context->depth) {
-        $setdepth = ", depth= depth + " . ($context->depth - $newparent->depth +1);
+    if (($newparent->depth +1) != $context->depth) {
+        $setdepth = ", depth= depth + ({$newparent->depth} - {$context->depth}) + 1";
     }
     $sql = "UPDATE {$CFG->prefix}context 
             SET path='$newpath'