From 4d6fd15c0055e44786e249d2101d5bb0910fc938 Mon Sep 17 00:00:00 2001 From: Sam Hemelryk Date: Wed, 8 Sep 2010 09:01:15 +0000 Subject: [PATCH] blocks MDL-23976 Added block method to determine if any of the blocks in a block region are docked. Kudo's to Brandon for the patch. --- lib/blocklib.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/blocklib.php b/lib/blocklib.php index eeb82764803..67c1f8a4ad4 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -419,6 +419,7 @@ class block_manager { /** * Checks to see whether all of the blocks within the given region are docked * + * @see region_uses_dock * @param string $region * @return bool True if all of the blocks within that region are docked */ @@ -436,6 +437,29 @@ class block_manager { return true; } + /** + * Checks to see whether any of the blocks within the given regions are docked + * + * @see region_completely_docked + * @param array|string $regions array of regions (or single region) + * @return bool True if any of the blocks within that region are docked + */ + public function region_uses_dock($regions, $output) { + if (!$this->page->theme->enable_dock) { + return false; + } + $this->check_is_loaded(); + foreach((array)$regions as $region) { + $this->ensure_content_created($region, $output); + foreach($this->visibleblockcontent[$region] as $instance) { + if(!empty($instance->content) && get_user_preferences('docked_block_instance_'.$instance->blockinstanceid, 0)) { + return true; + } + } + } + return false; + } + /// Actions ==================================================================== /**