MDL-73316 contentbank: Add in secondary navigation

This commit is contained in:
Mathew May
2022-01-12 13:54:57 +08:00
parent a9952cfe4c
commit 76eaf6ee5f
3 changed files with 16 additions and 6 deletions
+5 -1
View File
@@ -46,7 +46,11 @@ if ($PAGE->course) {
require_login($PAGE->course->id);
}
$PAGE->set_url('/contentbank/index.php');
$PAGE->set_context($context);
if ($contextid == \context_system::instance()->id) {
$PAGE->set_context(context_course::instance($contextid));
} else {
$PAGE->set_context($context);
}
$PAGE->set_title($title);
$PAGE->set_heading($title);
$PAGE->add_body_class('limitedwidth');
+2 -5
View File
@@ -120,6 +120,7 @@ class secondary extends view {
],
self::TYPE_CUSTOM => [
'advgrading' => 2,
'contentbank' => 12,
],
];
}
@@ -134,11 +135,7 @@ class secondary extends view {
* @return array
*/
protected function get_default_category_mapping(): array {
return [
self::TYPE_CUSTOM => [
'contentbank' => 5,
],
];
return [];
}
/**
+9
View File
@@ -23,6 +23,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use core_contentbank\contentbank;
defined('MOODLE_INTERNAL') || die();
/**
@@ -5357,6 +5359,13 @@ class settings_navigation extends navigation_node {
$categorynode->add(get_string('checkpermissions', 'role'), $url, self::TYPE_SETTING, null, 'checkpermissions', new pix_icon('i/checkpermissions', ''));
}
$cb = new contentbank();
if ($cb->is_context_allowed($catcontext)
&& has_capability('moodle/contentbank:access', $catcontext)) {
$url = new \moodle_url('/contentbank/index.php', ['contextid' => $catcontext->id]);
$categorynode->add(get_string('contentbank'), $url, self::TYPE_CUSTOM, null, 'contentbank', new \pix_icon('i/contentbank', ''));
}
// Add the context locking node.
$this->add_context_locking_node($categorynode, $catcontext);