From 4374ee2ca98be9c67775a324e1cf1079616c0364 Mon Sep 17 00:00:00 2001 From: mjollnir_ Date: Tue, 23 Aug 2005 04:48:34 +0000 Subject: [PATCH] Fixing warnings in my moodle/ blocks /pagelib, plus moved page->edit_always to base class --- blocks/moodleblock.class.php | 3 +++ lib/blocklib.php | 16 +++++++--------- lib/pagelib.php | 6 ++++++ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/blocks/moodleblock.class.php b/blocks/moodleblock.class.php index f4cc120f10a..b00f39609e5 100644 --- a/blocks/moodleblock.class.php +++ b/blocks/moodleblock.class.php @@ -279,6 +279,9 @@ class block_base { $title = $this->str->show; } + if (empty($this->instance->pageid)) { + $this->instance->pageid = 0; + } $page = page_create_object($this->instance->pagetype, $this->instance->pageid); $script = $page->url_get_full(array('instanceid' => $this->instance->id, 'sesskey' => $USER->sesskey)); diff --git a/lib/blocklib.php b/lib/blocklib.php index 1a73df240e1..e9b495e0480 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -251,6 +251,12 @@ function blocks_print_group(&$page, &$pageblocks, $position) { else { $maxweight = max(array_keys($pageblocks[$position])); } + + foreach ($instances as $instance) { + if (!empty($instance->pinned)) { + $maxweight--; + } + } $isediting = $page->user_is_editing(); @@ -266,9 +272,7 @@ function blocks_print_group(&$page, &$pageblocks, $position) { continue; } - if (method_exists($page,'edit_always')) { - $editalways = $page->edit_always(); - } + $editalways = $page->edit_always(); if (($isediting && empty($instance->pinned)) || !empty($editalways)) { $options = 0; @@ -314,12 +318,6 @@ function blocks_preferred_width(&$instances) { $blocks = blocks_get_record(); - foreach ($instances as $instance) { - if (!empty($instance->pinned)) { - $maxweight--; - } - } - foreach($instances as $instance) { if(!$instance->visible) { continue; diff --git a/lib/pagelib.php b/lib/pagelib.php index faea8798124..823d327d20a 100644 --- a/lib/pagelib.php +++ b/lib/pagelib.php @@ -293,6 +293,12 @@ class page_base { function init_full() { $this->full_init_done = true; } + + + // is this page always editable, regardless of anything else? + function edit_always() { + return false; + } }