]> git.mjollnir.org Git - moodle.git/commitdiff
blocks editing ui: MDL-19398 fix some bugs with adding a block.
authortjhunt <tjhunt>
Tue, 14 Jul 2009 09:28:10 +0000 (09:28 +0000)
committertjhunt <tjhunt>
Tue, 14 Jul 2009 09:28:10 +0000 (09:28 +0000)
lib/blocklib.php
lib/pagelib.php

index 3d84436482c92a527b9a01a5c147568cf25334a2..83d238f2f8c8fd9fc9148b7c07f53b768fce1773 100644 (file)
@@ -67,8 +67,8 @@ class block_not_on_page_exception extends moodle_exception {
     public function __construct($instanceid, $page) {
         $a = new stdClass;
         $a->instanceid = $instanceid;
-        $a->url = $page->url;
-        parent::__construct('blockdoesnotexistonpage', '', $page->url, $a);
+        $a->url = $page->url->out();
+        parent::__construct('blockdoesnotexistonpage', '', $page->url->out(), $a);
     }
 }
 
@@ -511,7 +511,14 @@ class block_manager {
 
     public function add_block_at_end_of_default_region($blockname) {
         $defaulregion = $this->get_default_region();
+
         $lastcurrentblock = end($this->birecordsbyregion[$defaulregion]);
+        if ($lastcurrentblock) {
+            $weight = $lastcurrentblock->weight + 1;
+        } else {
+            $weight = 0;
+        }
+
         if ($this->page->subpage) {
             $subpage = $this->page->subpage;
         } else {
@@ -525,13 +532,13 @@ class block_manager {
             $pagetypepattern = 'course-view-*';
         }
 
-        $this->add_block($blockname, $defaulregion, $lastcurrentblock->weight + 1, false, $pagetypepattern, $subpage);
+        $this->add_block($blockname, $defaulregion, $weight, false, $pagetypepattern, $subpage);
     }
 
     /**
      * Convenience method, calls add_block repeatedly for all the blocks in $blocks.
      *
-     * @param array $blocks array with arrray keys the region names, and values an array of block names.
+     * @param array $blocks array with array keys the region names, and values an array of block names.
      * @param string $pagetypepattern optional. Passed to @see add_block()
      * @param string $subpagepattern optional. Passed to @see add_block()
      */
@@ -865,6 +872,9 @@ function block_process_url_add($page) {
     }
 
     $page->blocks->add_block_at_end_of_default_region($blocktype);
+
+    $page->url->remove_params('bui_addblock');
+
     return true;
 }
 
@@ -881,6 +891,9 @@ function block_process_url_delete($page) {
 
     $instance = $page->blocks->find_instance($blockid);
     blocks_delete_instance($instance->instance);
+
+    $page->url->remove_params('bui_deleteid');
+
     return true;
 }
 
index 3935a89f7ddd9e504bb17ea3a0b3def5fd84fbc4..be7b6a0fbf20d78b4b9d38939e437ff0ada2817f 100644 (file)
@@ -857,7 +857,8 @@ class moodle_page {
 
         if (!during_initial_install()) {
             $this->blocks->load_blocks();
-            if (block_process_url_actions($this)) {
+            if (empty($this->_block_actions_done) && block_process_url_actions($this)) {
+                $this->_block_actions_done = true;
                 redirect($this->url->out(false, array(), false));
             }
         }