]> git.mjollnir.org Git - moodle.git/commitdiff
Fixed a warning which appears if you move a block to a
authordefacer <defacer>
Fri, 12 Nov 2004 18:44:54 +0000 (18:44 +0000)
committerdefacer <defacer>
Fri, 12 Nov 2004 18:44:54 +0000 (18:44 +0000)
position which doesn't currently have any blocks.

lib/blocklib.php

index 96fa0ef421fc2a8e9a628cbde1f04692f5846987..7fbd3e6a99b99055d3484feee94b136c0a07fd9d 100644 (file)
@@ -366,7 +366,7 @@ function blocks_execute_action($page, &$pageblocks, $blockaction, $instanceorid)
                 // The block is the first one, so a move "up" probably means it changes position
                 // Where is the instance going to be moved?
                 $newpos = $page->blocks_move_position($instance, BLOCK_MOVE_UP);
-                $newweight = max(array_keys($pageblocks[$newpos])) + 1;
+                $newweight = (empty($pageblocks[$newpos]) ? 0 : max(array_keys($pageblocks[$newpos]))) + 1;
 
                 blocks_execute_repositioning($instance, $newpos, $newweight);
             }
@@ -395,7 +395,7 @@ function blocks_execute_action($page, &$pageblocks, $blockaction, $instanceorid)
                 // The block is the last one, so a move "down" probably means it changes position
                 // Where is the instance going to be moved?
                 $newpos = $page->blocks_move_position($instance, BLOCK_MOVE_DOWN);
-                $newweight = max(array_keys($pageblocks[$newpos])) + 1;
+                $newweight = (empty($pageblocks[$newpos]) ? 0 : max(array_keys($pageblocks[$newpos]))) + 1;
 
                 blocks_execute_repositioning($instance, $newpos, $newweight);
             }
@@ -422,7 +422,7 @@ function blocks_execute_action($page, &$pageblocks, $blockaction, $instanceorid)
 
             // Where is the instance going to be moved?
             $newpos = $page->blocks_move_position($instance, BLOCK_MOVE_LEFT);
-            $newweight = max(array_keys($pageblocks[$newpos])) + 1;
+            $newweight = (empty($pageblocks[$newpos]) ? 0 : max(array_keys($pageblocks[$newpos]))) + 1;
 
             blocks_execute_repositioning($instance, $newpos, $newweight);
         break;
@@ -433,7 +433,7 @@ function blocks_execute_action($page, &$pageblocks, $blockaction, $instanceorid)
 
             // Where is the instance going to be moved?
             $newpos    = $page->blocks_move_position($instance, BLOCK_MOVE_RIGHT);
-            $newweight = max(array_keys($pageblocks[$newpos])) + 1;
+            $newweight = (empty($pageblocks[$newpos]) ? 0 : max(array_keys($pageblocks[$newpos]))) + 1;
 
             blocks_execute_repositioning($instance, $newpos, $newweight);
         break;