0f3fe4b6 |
1 | <?PHP //$Id$ |
2 | |
3ef642d9 |
3 | class block_participants extends block_list { |
9b4b78fd |
4 | function init() { |
0f3fe4b6 |
5 | $this->title = get_string('people'); |
89adb174 |
6 | $this->version = 2004052600; |
0f3fe4b6 |
7 | } |
8 | |
9 | function get_content() { |
61240489 |
10 | |
0f3fe4b6 |
11 | global $USER, $CFG; |
61240489 |
12 | |
13 | // the following 3 lines is need to pass _self_test(); |
14 | if (empty($this->instance->pageid)) { |
15 | return ''; |
16 | } |
17 | |
18 | |
19 | // only 2 possible contexts, site or course |
20 | if ($this->instance->pageid == SITEID) { // site context |
21 | $currentcontext = get_context_instance(CONTEXT_SYSTEM, SITEID); |
22 | $canviewparticipants = has_capability('moodle/site:viewparticipants', $currentcontext); |
23 | } else { // course context |
24 | $currentcontext = get_context_instance(CONTEXT_COURSE, $this->instance->pageid); |
25 | $canviewparticipants = has_capability('moodle/course:viewparticipants', $currentcontext); |
26 | } |
27 | |
28 | if (!$canviewparticipants) { |
29 | $this->context = ''; |
30 | return $this->content; |
31 | } |
0f3fe4b6 |
32 | |
675dbdd9 |
33 | if ($this->content !== NULL) { |
34 | return $this->content; |
35 | } |
9b4b78fd |
36 | if (empty($this->instance)) { |
675dbdd9 |
37 | $this->content = ''; |
0f3fe4b6 |
38 | return $this->content; |
39 | } |
40 | |
9b4b78fd |
41 | $this->content = new stdClass; |
0f3fe4b6 |
42 | $this->content->items = array(); |
43 | $this->content->icons = array(); |
44 | $this->content->footer = ''; |
45 | |
0f3fe4b6 |
46 | |
0d6b9d4f |
47 | if (empty($this->instance->pageid)) { |
48 | $this->instance->pageid = SITEID; |
49 | } |
50 | |
b008da95 |
51 | if ($this->instance->pageid != SITEID |
840c1c31 |
52 | || $canviewparticipants) { |
9b4b78fd |
53 | |
84bb3c12 |
54 | $this->content->items[] = '<a title="'.get_string('listofallpeople').'" href="'. |
01199ea9 |
55 | $CFG->wwwroot.'/user/index.php?contextid='.$currentcontext->id.'">'.get_string('participants').'</a>'; |
0d905d9f |
56 | $this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/users.gif" class="icon" alt="" />'; |
0f3fe4b6 |
57 | } |
58 | |
0f3fe4b6 |
59 | |
60 | return $this->content; |
61 | } |
0d6b9d4f |
62 | |
63 | // my moodle can only have SITEID and it's redundant here, so take it away |
64 | function applicable_formats() { |
044cdea0 |
65 | return array('all' => true, 'my' => false); |
0d6b9d4f |
66 | } |
52788321 |
67 | |
0f3fe4b6 |
68 | } |
69 | |
01199ea9 |
70 | ?> |