blocklib: MDL-19010 refactor blocklib to use block_manager to get the blocks for...
[moodle.git] / blocks / participants / block_participants.php
CommitLineData
0f3fe4b6 1<?PHP //$Id$
2
3ef642d9 3class block_participants extends block_list {
9b4b78fd 4 function init() {
0f3fe4b6 5 $this->title = get_string('people');
433c242f 6 $this->version = 2007101509;
0f3fe4b6 7 }
8
9 function get_content() {
224aa44a 10
99aa575d 11 global $CFG, $COURSE;
224aa44a 12
13 if (empty($this->instance)) {
14 $this->content = '';
15 return $this->content;
16 }
17
61240489 18 // the following 3 lines is need to pass _self_test();
19 if (empty($this->instance->pageid)) {
224aa44a 20 return '';
61240489 21 }
165088f6 22
23 $this->content = new object();
24 $this->content->items = array();
25 $this->content->icons = array();
26 $this->content->footer = '';
27
99aa575d 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)) {
224aa44a 30 $this->content = '';
675dbdd9 31 return $this->content;
32 }
165088f6 33
99aa575d 34 if ($COURSE->id == SITEID) {
165088f6 35 if (!has_capability('moodle/site:viewparticipants', get_context_instance(CONTEXT_SYSTEM))) {
36 $this->content = '';
37 return $this->content;
38 }
39 } else {
40 if (!has_capability('moodle/course:viewparticipants', $currentcontext)) {
41 $this->content = '';
42 return $this->content;
43 }
0f3fe4b6 44 }
45
224aa44a 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="" />';
0f3fe4b6 49
50 return $this->content;
51 }
224aa44a 52
0d6b9d4f 53 // my moodle can only have SITEID and it's redundant here, so take it away
54 function applicable_formats() {
9591bc3c 55 return array('all' => true, 'my' => false, 'tag' => false);
0d6b9d4f 56 }
52788321 57
0f3fe4b6 58}
59
9591bc3c 60?>