1931a9b0dfdcbdbb056c3dbe262095c897f88c5e
[moodle.git] / blocks / participants / block_participants.php
1 <?php
3 class block_participants extends block_list {
4     function init() {
5         $this->title = get_string('people');
6         $this->version = 2007101509;
7     }
9     function get_content() {
11         global $CFG, $OUTPUT;
13         if (empty($this->instance)) {
14             $this->content = '';
15             return $this->content;
16         }
18         $this->content = new object();
19         $this->content->items = array();
20         $this->content->icons = array();
21         $this->content->footer = '';
23         /// MDL-13252 Always get the course context or else the context may be incorrect in the user/index.php
24         $currentcontext = $this->page->context;
26         if ($this->page->course->id == SITEID) {
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             }
36         }
38         $this->content->items[] = '<a title="'.get_string('listofallpeople').'" href="'.
39                                   $CFG->wwwroot.'/user/index.php?contextid='.$currentcontext->id.'">'.get_string('participants').'</a>';
40         $this->content->icons[] = '<img src="'.$OUTPUT->pix_url('i/users') . '" class="icon" alt="" />';
42         return $this->content;
43     }
45     // my moodle can only have SITEID and it's redundant here, so take it away
46     function applicable_formats() {
47         return array('all' => true, 'my' => false, 'tag' => false);
48     }
50 }