Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Bug:MDL-6674

made changes to blocks_exeute_repositioning_atomic to fix some logic errors with shifting around the weight list
  • Loading branch information...
commit c4308cfa1b6ef680600a35f41943874433f686bb 1 parent a08a698
cap2501 authored
Showing with 15 additions and 9 deletions.
  1. +15 −9 lib/blocklib.php
View
24 lib/blocklib.php
@@ -703,11 +703,11 @@ function blocks_execute_url_action(&$PAGE, &$pageblocks,$pinned=false) {
// This shouldn't be used externally at all, it's here for use by blocks_execute_action()
// in order to reduce code repetition.
-function blocks_execute_repositioning(&$instance, $newpos, $newweight, $pinned=false) {
+function blocks_execute_repositioning(&$instance, $newpos, $newweight, $pinned=false, $checkPos=true) {
global $CFG;
- // If it's staying where it is, don't do anything
- if($newpos == $instance->position) {
+ // If it's staying where it is, don't do anything, unless overridden
+ if(($newpos == $instance->position)&& $checkPos) {
return;
}
@@ -736,6 +736,9 @@ function blocks_execute_repositioning(&$instance, $newpos, $newweight, $pinned=f
//like blocks_execute_repositiong except completely atomic, handles all aspects of the positioning
function blocks_execute_repositioning_atomic(&$instance, $newpos, $newweight, $pinned=false){
global $CFG;
+
+ if($instance->weight == $newweight)
+ return false;
//make room for block insert
if (!empty($pinned)) {
@@ -749,13 +752,16 @@ function blocks_execute_repositioning_atomic(&$instance, $newpos, $newweight, $p
}
execute_sql($sql,false);
-
-
- //reposition blocks
- blocks_execute_repositioning($instance,$newpos,$newweight,$pinned);
-
+ //adjusts the wieghts for changes in the weight list
+ if($newweight < $instance->weight){
+ $instance->weight+=2;
+ }else{
+ $newweight--;
+ }
-
+
+ //reposition blocks
+ blocks_execute_repositioning($instance,$newpos,$newweight,$pinned,false);
}
function blocks_get_pinned($page) {
Please sign in to comment.
Something went wrong with that request. Please try again.