Skip to content
Snippets Groups Projects
Commit 03e87633 authored by Sebastian Schilling's avatar Sebastian Schilling
Browse files

fix: added hook to display menu in Moodle 4.5

parent f1eb9992
Branches main
No related tags found
No related merge requests found
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
*
* @package local_polaris_dashboard
* @copyright 2023, Center für Lehr- und Lernservice (CLS), RWTH Aachen University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace local_polaris_dashboard;
defined('MOODLE_INTERNAL') || die();
class hook_callbacks {
/**
* Workaround to bypass the course navigation override by Moodle version 4+.
* Is called after the override.
* An "_extend_course_navigation" function would not allow to add the navigation node in front of the grade-entry.
* As the local_ladashboard_extend_navigation function works on earlier versions,
* the branch is checked and the function is aborted if an earlier version than 4 is used.
*/
static function local_polaris_dashboard_before_html_attributes($attributes) {
global $PAGE, $CFG;
if ($PAGE->context->contextlevel != CONTEXT_COURSE || ((int)$CFG->branch) < 400) {
return $attributes;
}
local_polaris_dashboard_extend_arbitrary_navigation($PAGE->secondarynav);
return $attributes;
}
}
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Hook callbacks for Polaris Dashboard
*
* @package local_polaris_dashboard
* @copyright 2024 Sebastian Schilling <schilling@cls.rwth-aachen.de>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$callbacks = [
[
'hook' => \core\hook\output\before_html_attributes::class,
'callback' => [\local_polaris_dashboard\hook_callbacks::class, 'local_polaris_dashboard_before_html_attributes'],
],
];
...@@ -24,6 +24,9 @@ ...@@ -24,6 +24,9 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
use core\hook\output\before_html_attributes;
require_once($CFG->dirroot . "/local/polaris_dashboard/locallib.php"); require_once($CFG->dirroot . "/local/polaris_dashboard/locallib.php");
/** /**
...@@ -40,22 +43,5 @@ function local_polaris_dashboard_extend_navigation(global_navigation $navigation ...@@ -40,22 +43,5 @@ function local_polaris_dashboard_extend_navigation(global_navigation $navigation
$course_nav = $navigation->find($COURSE->id, navigation_node::TYPE_COURSE); $course_nav = $navigation->find($COURSE->id, navigation_node::TYPE_COURSE);
local_polaris_dashboard_extend_arbitrary_navigation($course_nav); local_polaris_dashboard_extend_arbitrary_navigation($course_nav);
}
/**
* Workaround to bypass the course navigation override by Moodle version 4+.
* Is called after the override.
* An "_extend_course_navigation" function would not allow to add the navigation node in front of the grade-entry.
* As the local_ladashboard_extend_navigation function works on earlier versions,
* the branch is checked and the function is aborted if an earlier version than 4 is used.
*/
function local_polaris_dashboard_add_htmlattributes() {
global $PAGE, $CFG;
if ($PAGE->context->contextlevel != CONTEXT_COURSE || ((int)$CFG->branch) < 400) {
return [];
}
local_polaris_dashboard_extend_arbitrary_navigation($PAGE->secondarynav);
return [];
} }
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
$plugin->version = 20230814012; $plugin->version = 20230814014;
$plugin->requires = 2014051200; $plugin->requires = 2014051200;
$plugin->component = 'local_polaris_dashboard'; $plugin->component = 'local_polaris_dashboard';
$plugin->maturity = MATURITY_ALPHA; $plugin->maturity = MATURITY_ALPHA;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment