diff --git a/blocks/participants/block_participants.php b/blocks/participants/block_participants.php
index 6e7bcaae070..98f981f0877 100644
--- a/blocks/participants/block_participants.php
+++ b/blocks/participants/block_participants.php
@@ -7,59 +7,41 @@ class block_participants extends block_list {
}
function get_content() {
-
- global $USER, $CFG;
-
- // 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;
- }
- if ($this->content !== NULL) {
- return $this->content;
- }
+ global $CFG;
+
if (empty($this->instance)) {
$this->content = '';
return $this->content;
}
- $this->content = new stdClass;
+ // the following 3 lines is need to pass _self_test();
+ if (empty($this->instance->pageid)) {
+ return '';
+ }
+
+ if (!$currentcontext = get_context_instance(CONTEXT_COURSE, $this->instance->pageid)) {
+ $this->content = '';
+ return $this->content;
+ }
+
+ if (!has_capability('moodle/course:viewparticipants', $currentcontext)) {
+ $this->content = '';
+ return $this->content;
+ }
+
+ $this->content = new object();
$this->content->items = array();
$this->content->icons = array();
$this->content->footer = '';
-
- if (empty($this->instance->pageid)) {
- $this->instance->pageid = SITEID;
- }
-
- if ($this->instance->pageid != SITEID
- || $canviewparticipants) {
-
- $this->content->items[] = ''.get_string('participants').'';
- $this->content->icons[] = '
';
- }
-
+ $this->content->items[] = ''.get_string('participants').'';
+ $this->content->icons[] = '
';
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);
diff --git a/lib/db/access.php b/lib/db/access.php
index 4e9c865334d..c0893772b27 100644
--- a/lib/db/access.php
+++ b/lib/db/access.php
@@ -205,16 +205,6 @@ $moodle_capabilities = array(
)
),
- 'moodle/site:viewparticipants' => array(
-
- 'captype' => 'read',
- 'contextlevel' => CONTEXT_SYSTEM,
- 'legacy' => array(
- 'editingteacher' => CAP_ALLOW,
- 'admin' => CAP_ALLOW
- )
- ),
-
'moodle/site:viewreports' => array(
'riskbitmask' => RISK_PERSONAL,
diff --git a/user/index.php b/user/index.php
index dfe8368b14d..1b107b8f0ac 100644
--- a/user/index.php
+++ b/user/index.php
@@ -40,10 +40,11 @@
unset($contextid);
unset($courseid);
- require_login($course->id);
+ require_login($course);
- if (!has_capability('moodle/course:viewparticipants', $context)
- && !has_capability('moodle/site:viewparticipants', $context)) {
+ $sitecontext = get_context_instance(CONTEXT_SYSTEM);
+
+ if (!has_capability('moodle/course:viewparticipants', $context)) {
print_error('nopermissions');
}
@@ -53,7 +54,6 @@
// We should exclude "admin" users (those with "doanything" at site level) because
// Otherwise they appear in every participant list
- $sitecontext = get_context_instance(CONTEXT_SYSTEM);
$doanythingroles = get_roles_with_capability('moodle/site:doanything', CAP_ALLOW, $sitecontext);
foreach ($roles as $role) {
@@ -74,14 +74,6 @@
}
}
- if ($course->id == SITEID) {
- if (!has_capability('moodle/course:viewparticipants', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
- print_header("$course->shortname: ".get_string('participants'), $course->fullname,
- get_string('participants'), "", "", true, " ", navmenu($course));
- notice(get_string('sitepartlist'));
- }
- }
-
add_to_log($course->id, 'user', 'view all', 'index.php?id='.$course->id, '');
$bulkoperations = has_capability('moodle/course:bulkmessaging', $context);
@@ -120,7 +112,7 @@
}
$isseparategroups = ($course->groupmode == SEPARATEGROUPS and $course->groupmodeforce and
- !has_capability('moodle/site:accessallgroups', get_context_instance(CONTEXT_COURSE, $course->id)));
+ !has_capability('moodle/site:accessallgroups', $context));
if ($isseparategroups and (!$currentgroup) ) {
print_header("$course->shortname: ".get_string('participants'), $course->fullname,
@@ -146,7 +138,7 @@
}
- //setting up tags
+/// setting up tags
if ($course->id == SITEID) {
$filtertype = 'site';
} else if ($course->id && !$currentgroup) {
@@ -163,7 +155,7 @@
/// Get the hidden field list
- if (has_capability('moodle/course:viewhiddenuserfields', get_context_instance(CONTEXT_COURSE, $course->id))) {
+ if (has_capability('moodle/course:viewhiddenuserfields', $context)) {
$hiddenfields = array(); // teachers and admins are allowed to see everything
} else {
$hiddenfields = array_flip(explode(',', $CFG->hiddenuserfields));
@@ -177,19 +169,16 @@
/// Print my course menus
if ($mycourses = get_my_courses($USER->id)) {
echo '
| '; print_group_picture($group, $course->id, true, false, false); echo ' | ';
echo ''.$group->name;
- if (has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) {
+ if (has_capability('moodle/course:managegroups', $context)) {
echo ' ';
echo ' |