2004-04-18 23:20:53 +00:00
|
|
|
<?PHP //$Id$
|
|
|
|
|
2005-03-02 19:22:26 +00:00
|
|
|
class block_participants extends block_list {
|
2004-10-19 21:04:28 +00:00
|
|
|
function init() {
|
2004-04-18 23:20:53 +00:00
|
|
|
$this->title = get_string('people');
|
2004-05-28 10:53:54 +00:00
|
|
|
$this->version = 2004052600;
|
2004-04-18 23:20:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function get_content() {
|
2006-09-20 20:31:09 +00:00
|
|
|
|
2004-04-18 23:20:53 +00:00
|
|
|
global $USER, $CFG;
|
2006-09-20 20:31:09 +00:00
|
|
|
|
|
|
|
// the following 3 lines is need to pass _self_test();
|
|
|
|
if (empty($this->instance->pageid)) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// only 2 possible contexts, site or course
|
|
|
|
if ($this->instance->pageid == SITEID) { // site context
|
|
|
|
$currentcontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
|
|
|
|
$canviewparticipants = has_capability('moodle/site:viewparticipants', $currentcontext);
|
|
|
|
} else { // course context
|
|
|
|
$currentcontext = get_context_instance(CONTEXT_COURSE, $this->instance->pageid);
|
|
|
|
$canviewparticipants = has_capability('moodle/course:viewparticipants', $currentcontext);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$canviewparticipants) {
|
|
|
|
$this->context = '';
|
|
|
|
return $this->content;
|
|
|
|
}
|
2004-04-18 23:20:53 +00:00
|
|
|
|
2004-08-11 09:00:53 +00:00
|
|
|
if ($this->content !== NULL) {
|
|
|
|
return $this->content;
|
|
|
|
}
|
2004-10-19 21:04:28 +00:00
|
|
|
if (empty($this->instance)) {
|
2004-08-11 09:00:53 +00:00
|
|
|
$this->content = '';
|
2004-04-18 23:20:53 +00:00
|
|
|
return $this->content;
|
|
|
|
}
|
|
|
|
|
2004-10-19 21:04:28 +00:00
|
|
|
$this->content = new stdClass;
|
2004-04-18 23:20:53 +00:00
|
|
|
$this->content->items = array();
|
|
|
|
$this->content->icons = array();
|
|
|
|
$this->content->footer = '';
|
|
|
|
|
|
|
|
|
2005-08-16 00:25:39 +00:00
|
|
|
if (empty($this->instance->pageid)) {
|
|
|
|
$this->instance->pageid = SITEID;
|
|
|
|
}
|
|
|
|
|
2006-09-18 05:25:43 +00:00
|
|
|
if ($this->instance->pageid != SITEID
|
2006-09-18 09:02:12 +00:00
|
|
|
|| $canviewparticipants) {
|
2004-10-19 21:04:28 +00:00
|
|
|
|
2005-05-24 16:57:20 +00:00
|
|
|
$this->content->items[] = '<a title="'.get_string('listofallpeople').'" href="'.
|
2006-08-16 08:54:07 +00:00
|
|
|
$CFG->wwwroot.'/user/index.php?contextid='.$currentcontext->id.'">'.get_string('participants').'</a>';
|
2005-05-24 16:57:20 +00:00
|
|
|
$this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/users.gif" height="16" width="16" alt="" />';
|
2004-04-18 23:20:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return $this->content;
|
|
|
|
}
|
2005-08-16 00:25:39 +00:00
|
|
|
|
|
|
|
// my moodle can only have SITEID and it's redundant here, so take it away
|
|
|
|
function applicable_formats() {
|
2005-10-30 01:10:08 +00:00
|
|
|
return array('all' => true, 'my' => false);
|
2005-08-16 00:25:39 +00:00
|
|
|
}
|
2005-10-28 04:11:17 +00:00
|
|
|
|
2004-04-18 23:20:53 +00:00
|
|
|
}
|
|
|
|
|
2006-08-16 08:54:07 +00:00
|
|
|
?>
|