3 class block_participants
extends block_list
{
5 $this->title
= get_string('people');
6 $this->version
= 2007101509;
9 function get_content() {
13 if (empty($this->instance
)) {
15 return $this->content
;
18 // the following 3 lines is need to pass _self_test();
19 if (empty($this->instance
->pageid
)) {
23 $this->content
= new object();
24 $this->content
->items
= array();
25 $this->content
->icons
= array();
26 $this->content
->footer
= '';
28 /// MDL-13252 Always get the course context or else the context may be incorrect in the user/index.php
29 if (!$currentcontext = get_context_instance(CONTEXT_COURSE
, $COURSE->id
)) {
31 return $this->content
;
34 if ($COURSE->id
== SITEID
) {
35 if (!has_capability('moodle/site:viewparticipants', get_context_instance(CONTEXT_SYSTEM
))) {
37 return $this->content
;
40 if (!has_capability('moodle/course:viewparticipants', $currentcontext)) {
42 return $this->content
;
46 $this->content
->items
[] = '<a title="'.get_string('listofallpeople').'" href="'.
47 $CFG->wwwroot
.'/user/index.php?contextid='.$currentcontext->id
.'">'.get_string('participants').'</a>';
48 $this->content
->icons
[] = '<img src="'.$CFG->pixpath
.'/i/users.gif" class="icon" alt="" />';
50 return $this->content
;
53 // my moodle can only have SITEID and it's redundant here, so take it away
54 function applicable_formats() {
55 return array('all' => true, 'my' => false, 'tag' => false);