4ca6cfbf |
1 | <?php |
0f3fe4b6 |
2 | |
3ef642d9 |
3 | class block_participants extends block_list { |
9b4b78fd |
4 | function init() { |
882f4e13 |
5 | $this->title = get_string('pluginname', 'block_participants'); |
433c242f |
6 | $this->version = 2007101509; |
0f3fe4b6 |
7 | } |
8 | |
9 | function get_content() { |
224aa44a |
10 | |
6b608f8f |
11 | global $CFG, $OUTPUT; |
224aa44a |
12 | |
13 | if (empty($this->instance)) { |
14 | $this->content = ''; |
15 | return $this->content; |
16 | } |
17 | |
165088f6 |
18 | $this->content = new object(); |
19 | $this->content->items = array(); |
20 | $this->content->icons = array(); |
21 | $this->content->footer = ''; |
3179b000 |
22 | |
99aa575d |
23 | /// MDL-13252 Always get the course context or else the context may be incorrect in the user/index.php |
3179b000 |
24 | $currentcontext = $this->page->context; |
25 | |
cb640229 |
26 | if ($this->page->course->id == SITEID) { |
165088f6 |
27 | if (!has_capability('moodle/site:viewparticipants', get_context_instance(CONTEXT_SYSTEM))) { |
28 | $this->content = ''; |
29 | return $this->content; |
30 | } |
31 | } else { |
32 | if (!has_capability('moodle/course:viewparticipants', $currentcontext)) { |
33 | $this->content = ''; |
34 | return $this->content; |
35 | } |
0f3fe4b6 |
36 | } |
37 | |
224aa44a |
38 | $this->content->items[] = '<a title="'.get_string('listofallpeople').'" href="'. |
39 | $CFG->wwwroot.'/user/index.php?contextid='.$currentcontext->id.'">'.get_string('participants').'</a>'; |
b5d0cafc |
40 | $this->content->icons[] = '<img src="'.$OUTPUT->pix_url('i/users') . '" class="icon" alt="" />'; |
0f3fe4b6 |
41 | |
42 | return $this->content; |
43 | } |
224aa44a |
44 | |
0d6b9d4f |
45 | // my moodle can only have SITEID and it's redundant here, so take it away |
46 | function applicable_formats() { |
9591bc3c |
47 | return array('all' => true, 'my' => false, 'tag' => false); |
0d6b9d4f |
48 | } |
52788321 |
49 | |
0f3fe4b6 |
50 | } |
51 | |
4ca6cfbf |
52 | |