// 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;
}
//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)) {
}
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) {