MDL-78962 core/loadingicon: remove jQuery requirement in the API
[moodle.git] / report / progress / lib.php
blob3931e714b3bfdcc13255a9fb386734db21defb2e
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.
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/>.
17 /**
18 * This file contains functions used by the progress report
20 * @package report
21 * @subpackage progress
22 * @copyright 2009 Sam Hemelryk
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 defined('MOODLE_INTERNAL') || die;
28 /**
29 * This function extends the navigation with the report items
31 * @param navigation_node $navigation The navigation node to extend
32 * @param stdClass $course The course to object for the report
33 * @param stdClass $context The context of the course
35 function report_progress_extend_navigation_course($navigation, $course, $context) {
36 global $CFG, $OUTPUT;
38 require_once($CFG->libdir.'/completionlib.php');
40 $showonnavigation = has_capability('report/progress:view', $context);
41 $group = groups_get_course_group($course,true); // Supposed to verify group
42 if($group===0 && $course->groupmode==SEPARATEGROUPS) {
43 $showonnavigation = ($showonnavigation && has_capability('moodle/site:accessallgroups', $context));
46 $completion = new completion_info($course);
47 $showonnavigation = ($showonnavigation && $completion->is_enabled() && $completion->has_activities());
48 if ($showonnavigation) {
49 $url = new moodle_url('/report/progress/index.php', array('course'=>$course->id));
50 $navigation->add(get_string('pluginname','report_progress'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
54 /**
55 * Return a list of page types
56 * @param string $pagetype current page type
57 * @param stdClass $parentcontext Block's parent context
58 * @param stdClass $currentcontext Current context of block
59 * @return array
61 function report_progress_page_type_list($pagetype, $parentcontext, $currentcontext) {
62 $array = array(
63 '*' => get_string('page-x', 'pagetype'),
64 'report-*' => get_string('page-report-x', 'pagetype'),
65 'report-progress-*' => get_string('page-report-progress-x', 'report_progress'),
66 'report-progress-index' => get_string('page-report-progress-index', 'report_progress'),
68 return $array;