Merge commit 'catalyst/MOODLE_19_STABLE' into mdl19-linuxchix
[moodle-linuxchix.git] / blocks / participants / block_participants.php
blob02d55a659580b7e5ee7540535d0c71fc026534e6
1 <?PHP //$Id$
3 class block_participants extends block_list {
4 function init() {
5 $this->title = get_string('people');
6 $this->version = 2007101509;
9 function get_content() {
11 global $CFG, $COURSE;
13 if (empty($this->instance)) {
14 $this->content = '';
15 return $this->content;
18 // the following 3 lines is need to pass _self_test();
19 if (empty($this->instance->pageid)) {
20 return '';
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)) {
30 $this->content = '';
31 return $this->content;
34 if ($COURSE->id == SITEID) {
35 if (!has_capability('moodle/site:viewparticipants', get_context_instance(CONTEXT_SYSTEM))) {
36 $this->content = '';
37 return $this->content;
39 } else {
40 if (!has_capability('moodle/course:viewparticipants', $currentcontext)) {
41 $this->content = '';
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);