Skip to content

Commit b297ae2

Browse files
committed
Overwrite subsection menu (MDL-82510)
1 parent ae3aa00 commit b297ae2

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
// This file is part of Moodle - http://moodle.org/
3+
//
4+
// Moodle is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// Moodle is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
17+
namespace format_multitopic\output\courseformat\content\cm;
18+
19+
use core\output\action_menu\link;
20+
use core_courseformat\output\local\content\cm\delegatedcontrolmenu as delegatedcontrolmenu_base;
21+
22+
/**
23+
* Class to render delegated section controls.
24+
*
25+
* @package format_multitopic
26+
* @copyright 2025 James Calder and Otago Polytechnic
27+
* @copyright based on work by 2024 Amaia Anabitarte <[email protected]>
28+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
29+
*/
30+
class delegatedcontrolmenu extends delegatedcontrolmenu_base {
31+
/**
32+
* Retrieves the view item for the section control menu.
33+
*
34+
* @return link|null The menu item if applicable, otherwise null.
35+
*/
36+
protected function get_section_view_item(): ?link {
37+
return null;
38+
}
39+
40+
/**
41+
* Retrieves the edit item for the section control menu.
42+
*
43+
* @return link|null The menu item if applicable, otherwise null.
44+
*/
45+
protected function get_section_edit_item(): ?link {
46+
$link = parent::get_section_edit_item();
47+
48+
if ($link) {
49+
$link->url->remove_params('sr');
50+
$link->url->remove_params('returnurl');
51+
}
52+
53+
return $link;
54+
}
55+
56+
/**
57+
* Retrieves the permalink item for the section control menu.
58+
*
59+
* @return link|null The menu item if applicable, otherwise null.
60+
*/
61+
protected function get_section_permalink_item(): ?link {
62+
$link = parent::get_section_permalink_item();
63+
64+
if ($link) {
65+
$link->url = course_get_url($this->format->get_course(), $this->section);
66+
}
67+
68+
return $link;
69+
}
70+
}

0 commit comments

Comments
 (0)