mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
MDL-46865 report_log: Fixed showuser and showcourse in report log
This commit is contained in:
parent
8309373cbf
commit
bd2183cd16
@ -309,32 +309,22 @@ class report_log_renderable implements renderable {
|
||||
$sitecontext = context_system::instance();
|
||||
// First check to see if we can override showcourses and showusers.
|
||||
$numcourses = $DB->count_records("course");
|
||||
if ($numcourses < COURSE_MAX_COURSES_PER_DROPDOWN && !$this->showcourses) {
|
||||
$this->showcourses = 1;
|
||||
}
|
||||
|
||||
// Check if course filter should be shown.
|
||||
if ((has_capability('report/log:view', $sitecontext)) && ($this->showcourses ||
|
||||
(empty($this->showcourses) && ($numcourses < COURSE_MAX_COURSES_PER_DROPDOWN)))) {
|
||||
$courses[0] = get_string('sitelogs');
|
||||
$this->showcourses = true;
|
||||
if (has_capability('report/log:view', $sitecontext) && $this->showcourses) {
|
||||
if ($courserecords = $DB->get_records("course", null, "fullname", "id,shortname,fullname,category")) {
|
||||
foreach ($courserecords as $course) {
|
||||
if ($course->category) {
|
||||
$courses[$course->id] = format_string(get_course_display_name_for_list($course));
|
||||
if ($course->id == SITEID) {
|
||||
$courses[$course->id] = format_string($course->fullname) . ' (' . get_string('site') . ')';
|
||||
} else {
|
||||
$courses[$course->id] = $SITE->shortname;
|
||||
$courses[$course->id] = format_string(get_course_display_name_for_list($course));
|
||||
}
|
||||
}
|
||||
}
|
||||
core_collator::asort($courses);
|
||||
} else {
|
||||
if (!empty($this->course->id)) {
|
||||
$coursecontext = context_course::instance($this->course->id);
|
||||
if (has_capability('report/log:view', $coursecontext)) {
|
||||
$courses[$this->course->id] = format_string(get_course_display_name_for_list($this->course));
|
||||
} else {
|
||||
$this->showcourses = false;
|
||||
}
|
||||
} else {
|
||||
$this->showcourses = false;
|
||||
}
|
||||
}
|
||||
return $courses;
|
||||
}
|
||||
@ -384,9 +374,12 @@ class report_log_renderable implements renderable {
|
||||
$courseusers = get_enrolled_users($context, '', $this->groupid, 'u.id, ' . get_all_user_name_fields(true, 'u'),
|
||||
null, $limitfrom, $limitnum);
|
||||
|
||||
if (count($courseusers) < COURSE_MAX_USERS_PER_DROPDOWN && !$this->showusers) {
|
||||
$this->showusers = 1;
|
||||
}
|
||||
|
||||
$users = array();
|
||||
if (($this->showusers) || (count($courseusers) < COURSE_MAX_USERS_PER_DROPDOWN && empty($this->showusers))) {
|
||||
$this->showusers = true;
|
||||
if ($this->showusers) {
|
||||
if ($courseusers) {
|
||||
foreach ($courseusers as $courseuser) {
|
||||
$users[$courseuser->id] = fullname($courseuser, has_capability('moodle/site:viewfullnames', $context));
|
||||
|
@ -94,27 +94,26 @@ class report_log_renderer extends plugin_renderer_base {
|
||||
$selectedcourseid = empty($reportlog->course) ? 0 : $reportlog->course->id;
|
||||
|
||||
// Add course selector.
|
||||
$sitecontext = context_system::instance();
|
||||
$courses = $reportlog->get_course_list();
|
||||
if (!empty($courses)) {
|
||||
if ($reportlog->showcourses) {
|
||||
echo html_writer::label(get_string('selectacourse'), 'menuid', false, array('class' => 'accesshide'));
|
||||
echo html_writer::select($courses, "id", $selectedcourseid, null);
|
||||
} else {
|
||||
$courseoption[$selectedcourseid] = $courses[$selectedcourseid];
|
||||
unset($courses);
|
||||
echo html_writer::label(get_string('selectacourse'), 'menuid', false, array('class' => 'accesshide'));
|
||||
echo html_writer::select($courseoption, "id", $selectedcourseid, null);
|
||||
|
||||
// Check if user is admin and this came because of limitation on number of courses to show in dropdown.
|
||||
$sitecontext = context_system::instance();
|
||||
if (has_capability('report/log:view', $sitecontext)) {
|
||||
$a = new stdClass();
|
||||
$a->url = new moodle_url('/report/log/index.php', array('chooselog' => 0,
|
||||
'group' => $reportlog->get_selected_group(), 'user' => $reportlog->userid,
|
||||
'id' => $selectedcourseid, 'date' => $reportlog->date, 'modid' => $reportlog->modid,
|
||||
'showcourses' => 1, 'showusers' => $reportlog->showusers));
|
||||
print_string('logtoomanycourses', 'moodle', $a);
|
||||
}
|
||||
if (!empty($courses) && $reportlog->showcourses) {
|
||||
echo html_writer::label(get_string('selectacourse'), 'menuid', false, array('class' => 'accesshide'));
|
||||
echo html_writer::select($courses, "id", $selectedcourseid, null);
|
||||
} else {
|
||||
$courses = array();
|
||||
$courses[$selectedcourseid] = get_course_display_name_for_list($reportlog->course) . (($selectedcourseid == SITEID) ?
|
||||
' (' . get_string('site') . ') ' : '');
|
||||
echo html_writer::label(get_string('selectacourse'), 'menuid', false, array('class' => 'accesshide'));
|
||||
echo html_writer::select($courses, "id", $selectedcourseid, false);
|
||||
// Check if user is admin and this came because of limitation on number of courses to show in dropdown.
|
||||
if (has_capability('report/log:view', $sitecontext)) {
|
||||
$a = new stdClass();
|
||||
$a->url = new moodle_url('/report/log/index.php', array('chooselog' => 0,
|
||||
'group' => $reportlog->get_selected_group(), 'user' => $reportlog->userid,
|
||||
'id' => $selectedcourseid, 'date' => $reportlog->date, 'modid' => $reportlog->modid,
|
||||
'showcourses' => 1, 'showusers' => $reportlog->showusers));
|
||||
$a->url = $a->url->out(false);
|
||||
print_string('logtoomanycourses', 'moodle', $a);
|
||||
}
|
||||
}
|
||||
|
||||
@ -127,26 +126,26 @@ class report_log_renderer extends plugin_renderer_base {
|
||||
|
||||
// Add user selector.
|
||||
$users = $reportlog->get_user_list();
|
||||
if (!empty($users)) {
|
||||
if ($reportlog->showusers) {
|
||||
echo html_writer::label(get_string('selctauser'), 'menuuser', false, array('class' => 'accesshide'));
|
||||
echo html_writer::select($users, "user", $reportlog->userid, get_string("allparticipants"));
|
||||
|
||||
if ($reportlog->showusers) {
|
||||
echo html_writer::label(get_string('selctauser'), 'menuuser', false, array('class' => 'accesshide'));
|
||||
echo html_writer::select($users, "user", $reportlog->userid, get_string("allparticipants"));
|
||||
} else {
|
||||
$users = array();
|
||||
if (!empty($reportlog->userid)) {
|
||||
$users[$reportlog->userid] = $reportlog->get_selected_user_fullname();
|
||||
} else {
|
||||
$users = array();
|
||||
if (!empty($reportlog->userid)) {
|
||||
$users[$reportlog->userid] = $reportlog->get_selected_user_fullname();
|
||||
} else {
|
||||
$users[0] = get_string('allparticipants');
|
||||
}
|
||||
echo html_writer::label(get_string('selctauser'), 'menuuser', false, array('class' => 'accesshide'));
|
||||
echo html_writer::select($users, "user", $reportlog->userid, false);
|
||||
$a = new stdClass();
|
||||
$a->url = new moodle_url('/report/log/index.php', array('chooselog' => 0,
|
||||
'group' => $reportlog->get_selected_group(), 'user' => $reportlog->userid,
|
||||
'id' => $selectedcourseid, 'date' => $reportlog->date, 'modid' => $reportlog->modid,
|
||||
'showcourses' => 1, 'showusers' => $reportlog->showusers, 'showcourses' => $reportlog->showcourses));
|
||||
print_string('logtoomanyusers', 'moodle', $a);
|
||||
$users[0] = get_string('allparticipants');
|
||||
}
|
||||
echo html_writer::label(get_string('selctauser'), 'menuuser', false, array('class' => 'accesshide'));
|
||||
echo html_writer::select($users, "user", $reportlog->userid, false);
|
||||
$a = new stdClass();
|
||||
$a->url = new moodle_url('/report/log/index.php', array('chooselog' => 0,
|
||||
'group' => $reportlog->get_selected_group(), 'user' => $reportlog->userid,
|
||||
'id' => $selectedcourseid, 'date' => $reportlog->date, 'modid' => $reportlog->modid,
|
||||
'showusers' => 1, 'showcourses' => $reportlog->showcourses));
|
||||
$a->url = $a->url->out(false);
|
||||
print_string('logtoomanyusers', 'moodle', $a);
|
||||
}
|
||||
|
||||
// Add date selector.
|
||||
|
@ -44,8 +44,11 @@ $logreader = optional_param('logreader', '', PARAM_COMPONENT); // Reader wh
|
||||
$edulevel = optional_param('edulevel', -1, PARAM_INT); // Educational level.
|
||||
|
||||
$params = array();
|
||||
if ($id !== 0) {
|
||||
if (!empty($id)) {
|
||||
$params['id'] = $id;
|
||||
} else {
|
||||
$site = get_site();
|
||||
$id = $site->id;
|
||||
}
|
||||
if ($group !== 0) {
|
||||
$params['group'] = $group;
|
||||
|
Loading…
x
Reference in New Issue
Block a user