• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ewallah / moodle-report_comments / 3991272918

pending completion
3991272918

push

github

Renaat Debleu
coveralls

90 of 270 relevant lines covered (33.33%)

0.84 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/lib.php
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
/**
18
 * Library functions.
19
 *
20
 * @package    report_comments
21
 * @copyright  2017 iplusacademy.org
22
 * @author     Renaat Debleu (www.eWallah.net)
23
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 */
25

26
/**
27
 * This function extends the navigation with the report items
28
 *
29
 * @param navigation_node $navigation The navigation node to extend
30
 * @param stdClass $course The course to object for the report
31
 * @param stdClass $context The context of the course
32
 */
33
function report_comments_extend_navigation_course($navigation, $course, $context) {
34
    global $CFG;
×
35
    if (has_capability('report/comments:view', $context)) {
×
36
        if ($CFG->usecomments) {
×
37
            $str = get_string('comments');
×
38
            $url = new \moodle_url('/report/comments/index.php', ['course' => $course->id]);
×
39
            $navigation->add($str, $url, navigation_node::TYPE_SETTING, null, null, new \pix_icon('i/report', $str));
×
40
        }
41
        if ($CFG->enablenotes) {
×
42
            $url = new \moodle_url('/notes/index.php', ['course' => $course->id]);
×
43
            $str = get_string('notes', 'notes');
×
44
            $navigation->add($str, $url, navigation_node::TYPE_SETTING, null, null, new \pix_icon('i/report', $str));
×
45
        }
46
    }
47
}
48

49
/**
50
 * Add nodes to myprofile page.
51
 *
52
 * @param \core_user\output\myprofile\tree $tree Tree object
53
 * @param stdClass $user user object
54
 * @param bool $iscurrentuser
55
 * @param stdClass $course Course object
56
 *
57
 * @return bool
58
 */
59
function report_comments_myprofile_navigation(\core_user\output\myprofile\tree $tree, $user, $iscurrentuser, $course) {
60
    global $CFG;
×
61
    if (isguestuser($user) || !$iscurrentuser) {
×
62
        return false;
×
63
    }
64
    $context = context_system::instance();
×
65
    $return = false;
×
66
    if ($CFG->usecomments && has_capability('report/comments:view', $context)) {
×
67
        $url = new \moodle_url('/report/comments/index.php', ['course' => 1, 'id' => $user->id]);
×
68
        $node = new \core_user\output\myprofile\node('reports', 'comments', get_string('comments'), null, $url);
×
69
        $tree->add_node($node);
×
70
        $return = true;
×
71
    }
72
    return $return;
×
73
}
74

75
/**
76
 * Return a list of page types
77
 * @param string $pagetype current page type
78
 * @param stdClass $parentcontext Block's parent context
79
 * @param stdClass $currentcontext Current context of block
80
 * @return array
81
 */
82
function report_comments_page_type_list($pagetype, $parentcontext, $currentcontext) {
83
    return ['*' => new \lang_string('page-x', 'pagetype'), 'report-*' => new \lang_string('page-report-x', 'pagetype')];
×
84
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc