MDL-47575 gradebook: Show weights and contribution by default.
[moodle.git] / blocks / participants / block_participants.php
blob3cc6a8b9db51d5bb67183254887feb94d74d1be5
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 * Participants block
20 * @package block_participants
21 * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 class block_participants extends block_list {
26 function init() {
27 $this->title = get_string('pluginname', 'block_participants');
30 function get_content() {
32 global $CFG, $OUTPUT;
34 if (empty($this->instance)) {
35 $this->content = '';
36 return $this->content;
39 $this->content = new stdClass();
40 $this->content->items = array();
41 $this->content->icons = array();
42 $this->content->footer = '';
44 // user/index.php expect course context, so get one if page has module context.
45 $currentcontext = $this->page->context->get_course_context(false);
47 if (empty($currentcontext)) {
48 $this->content = '';
49 return $this->content;
50 } else if ($this->page->course->id == SITEID) {
51 if (!has_capability('moodle/site:viewparticipants', context_system::instance())) {
52 $this->content = '';
53 return $this->content;
55 } else {
56 if (!has_capability('moodle/course:viewparticipants', $currentcontext)) {
57 $this->content = '';
58 return $this->content;
62 $icon = '<img src="'.$OUTPUT->pix_url('i/users') . '" class="icon" alt="" />';
63 $this->content->items[] = '<a title="'.get_string('listofallpeople').'" href="'.
64 $CFG->wwwroot.'/user/index.php?contextid='.$currentcontext->id.'">'.$icon.get_string('participants').'</a>';
66 return $this->content;
69 // my moodle can only have SITEID and it's redundant here, so take it away
70 function applicable_formats() {
71 return array('all' => true, 'my' => false, 'tag' => false);