2 // This file is part of Moodle - http://moodle.org/
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.
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/>.
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
{
27 $this->title
= get_string('pluginname', 'block_participants');
30 function get_content() {
34 if (empty($this->instance
)) {
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)) {
49 return $this->content
;
50 } else if ($this->page
->course
->id
== SITEID
) {
51 if (!has_capability('moodle/site:viewparticipants', context_system
::instance())) {
53 return $this->content
;
56 if (!has_capability('moodle/course:viewparticipants', $currentcontext)) {
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);