. /** * Participants block * * @package block_participants * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class block_participants extends block_list { function init() { $this->title = get_string('pluginname', 'block_participants'); } function get_content() { global $CFG, $OUTPUT; if (empty($this->instance)) { $this->content = ''; return $this->content; } $this->content = new stdClass(); $this->content->items = array(); $this->content->icons = array(); $this->content->footer = ''; // user/index.php expect course context, so get one if page has module context. $currentcontext = $this->page->context->get_course_context(false); if (empty($currentcontext)) { $this->content = ''; return $this->content; } else if ($this->page->course->id == SITEID) { if (!has_capability('moodle/site:viewparticipants', context_system::instance())) { $this->content = ''; return $this->content; } } else { if (!has_capability('moodle/course:viewparticipants', $currentcontext)) { $this->content = ''; return $this->content; } } $icon = ''; $this->content->items[] = ''.$icon.get_string('participants').''; return $this->content; } // my moodle can only have SITEID and it's redundant here, so take it away function applicable_formats() { return array('all' => true, 'my' => false, 'tag' => false); } }