Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
13 / 13 |
|
100.00% |
1 / 1 |
CRAP | n/a |
0 / 0 |
|
| local_transcript_myprofile_navigation | |
100.00% |
13 / 13 |
|
100.00% |
1 / 1 |
5 | |||
| 1 | <?php |
| 2 | // This file is part of Moodle - https://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 <https://www.gnu.org/licenses/>. |
| 16 | |
| 17 | /** |
| 18 | * Navigation for local_transcript. |
| 19 | * |
| 20 | * @package local_transcript |
| 21 | * @copyright 2026 DevLMS <contact@devlms.com> |
| 22 | * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
| 23 | */ |
| 24 | |
| 25 | /** |
| 26 | * Add a Transcripts link to the profile page. |
| 27 | * |
| 28 | * @param \core_user\output\myprofile\tree $tree |
| 29 | * @param stdClass $user |
| 30 | * @param bool $iscurrentuser |
| 31 | * @param stdClass|null $course |
| 32 | * @return bool |
| 33 | */ |
| 34 | function local_transcript_myprofile_navigation(\core_user\output\myprofile\tree $tree, $user, $iscurrentuser, $course) { |
| 35 | $sys = context_system::instance(); |
| 36 | $own = $iscurrentuser && has_capability('local/transcript:issueown', $sys); |
| 37 | if (!$own && !has_capability('local/transcript:manage', $sys)) { |
| 38 | return false; |
| 39 | } |
| 40 | $url = new moodle_url('/local/transcript/index.php', $iscurrentuser ? [] : ['userid' => $user->id]); |
| 41 | $tree->add_node(new \core_user\output\myprofile\node( |
| 42 | 'miscellaneous', |
| 43 | 'local_transcript', |
| 44 | get_string('mytranscripts', 'local_transcript'), |
| 45 | null, |
| 46 | $url |
| 47 | )); |
| 48 | return true; |
| 49 | } |