From 4cccfbeb9c95b04de89ff9cb273a0c21e70d4997 Mon Sep 17 00:00:00 2001 From: Nithyanandan Date: Tue, 1 Oct 2024 12:43:43 +0530 Subject: [PATCH] Bugfix: Includes disable output method for title specialization. - Fix DASH-981, DASH-982 --- block_dash.php | 12 +++++++++++- classes/local/block_builder.php | 24 ++---------------------- version.php | 2 +- 3 files changed, 14 insertions(+), 24 deletions(-) diff --git a/block_dash.php b/block_dash.php index e4e7dbc..898b2db 100644 --- a/block_dash.php +++ b/block_dash.php @@ -63,6 +63,13 @@ public function has_config() { public function specialization() { global $OUTPUT; + // Verify the dash output is disabled, then use the default title for the block. stop execution here. + if (block_dash_is_disabled()) { + // Use default block title. + $this->title = get_string('newblock', 'block_dash'); + return false; + } + if (isset($this->config->title)) { $this->title = $this->title = format_string($this->config->title, true, ['context' => $this->context]); } else { @@ -73,9 +80,12 @@ public function specialization() { $bb = block_builder::create($this); if ($bb->is_collapsible_content_addon()) { $addclass = "collapsible-block dash-block-collapse-icon"; - if (!$bb->is_section_expand_content_addon()) { + + $data = ['collapseaction' => true]; + if (!$bb->get_configuration()->get_data_source()->is_section_expand_content_addon($data)) { $addclass .= " collapsed"; } + $attr = [ 'data-toggle' => 'collapse', 'class' => $addclass, diff --git a/classes/local/block_builder.php b/classes/local/block_builder.php index 4e07d00..b96b261 100644 --- a/classes/local/block_builder.php +++ b/classes/local/block_builder.php @@ -29,6 +29,7 @@ use block_dash\output\query_debug; use block_dash\output\renderer; use html_writer; +use moodle_exception; /** * Helper class for creating block instance content. @@ -86,27 +87,7 @@ public function is_collapsible_content_addon($checksection = false) { return false; } - /** - * Confirm the block is configured to display only for the section. - * - * @return bool - */ - public function is_section_expand_content_addon() { - if ($this->is_collapsible_content_addon()) { - $currentsection = optional_param('section', 0, PARAM_INT); - if (isset($this->blockinstance->config->preferences)) { - $preferneces = $this->blockinstance->config->preferences; - if (isset($preferneces['filters'])) { - $restrictedsections = isset($preferneces['filters']['sectiondisplay']['sections']) ? - $preferneces['filters']['sectiondisplay']['sections'] : []; - if (in_array((int)$currentsection, $restrictedsections)) { - return true; - } - } - } - } - return false; - } + /** * Get content object for block instance. @@ -134,7 +115,6 @@ public function get_block_content() { 'pagelayout' => $this->blockinstance->page->pagelayout, 'pagecontext' => $this->blockinstance->page->context->id, 'collapseaction' => $this->is_collapsible_content_addon(), - 'showcollapseblock' => $this->is_section_expand_content_addon(), ]; if ($this->configuration->is_fully_configured()) { diff --git a/version.php b/version.php index 66584e1..2a5aa16 100644 --- a/version.php +++ b/version.php @@ -24,7 +24,7 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2024050803; // The current plugin version (Date: YYYYMMDDXX). +$plugin->version = 2024050804; // The current plugin version (Date: YYYYMMDDXX). $plugin->requires = 2021051700; // Requires this Moodle version. $plugin->component = 'block_dash'; // Full name of the plugin (used for diagnostics). $plugin->maturity = MATURITY_STABLE;