major whitespace cleanup - fixed \r line-ending
[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');
89adb174 6 $this->version = 2004052600;
0f3fe4b6 7 }
8
9 function get_content() {
bbbf2d40 10
0f3fe4b6 11 global $USER, $CFG;
bbbf2d40 12
13 // the following 3 lines is need to pass _self_test();
795821c4 14 if (empty($this->instance->pageid)) {
bbbf2d40 15 return '';
16 }
01199ea9 17
01199ea9 18
bbbf2d40 19 // only 2 possible contexts, site or course
20 if ($this->instance->pageid == SITEID) { // site context
840c1c31 21 $currentcontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
22 $canviewparticipants = has_capability('moodle/site:viewparticipants', $currentcontext);
bbbf2d40 23 } else { // course context
01199ea9 24 $currentcontext = get_context_instance(CONTEXT_COURSE, $this->instance->pageid);
840c1c31 25 $canviewparticipants = has_capability('moodle/course:viewparticipants', $currentcontext);
bbbf2d40 26 }
27
840c1c31 28 if (!$canviewparticipants) {
bbbf2d40 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>';
84bb3c12 56 $this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/users.gif" height="16" width="16" 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?>