Skip to content

Commit

Permalink
Bugfix: Includes disable output method for title specialization.
Browse files Browse the repository at this point in the history
- Fix DASH-981, DASH-982
  • Loading branch information
Nithyanandan committed Oct 1, 2024
1 parent 1e00f35 commit 4cccfbe
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 24 deletions.
12 changes: 11 additions & 1 deletion block_dash.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
Expand Down
24 changes: 2 additions & 22 deletions classes/local/block_builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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()) {
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4cccfbe

Please sign in to comment.