From 7bbc2890f7afebdd7532bb29eabedd28632f9aa0 Mon Sep 17 00:00:00 2001
From: tjhunt <tjhunt>
Date: Wed, 29 Jul 2009 03:19:43 +0000
Subject: [PATCH] blocks: MDL-19946 bugfixes for my previous commit.

---
 lib/blocklib.php | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/blocklib.php b/lib/blocklib.php
index a2d221e2f7..a880f988a0 100644
--- a/lib/blocklib.php
+++ b/lib/blocklib.php
@@ -792,7 +792,7 @@ class block_manager {
 
         $block = $this->page->blocks->find_instance($blockid);
 
-        if (!$block->user_can_edit() || !$this->page->user_can_edit_blocks() || !$block->user_can_addto($page)) {
+        if (!$block->user_can_edit() || !$this->page->user_can_edit_blocks() || !$block->user_can_addto($this->page)) {
             throw new moodle_exception('nopermissions', '', $this->page->url->out(), get_string('deleteablock'));
         }
 
@@ -859,7 +859,7 @@ class block_manager {
         $editpage = new moodle_page();
         $editpage->set_generaltype('form');
         $editpage->set_course($this->page->course);
-        $editpage->set_context($this->page->context);
+        $editpage->set_context($block->context);
         $editurlbase = str_replace($CFG->wwwroot . '/', '', $this->page->url->out(true));
         $editurlparams = $this->page->url->params();
         $editurlparams['bui_editid'] = $blockid;
-- 
2.39.5