Skip to content

Commit

Permalink
Merge branch 'wip-mdl-46865' of https://github.com/rajeshtaneja/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
danpoltawski committed Nov 17, 2014
2 parents 296e292 + bd2183c commit d012fad
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 59 deletions.
33 changes: 13 additions & 20 deletions report/log/classes/renderable.php
Expand Up @@ -309,32 +309,22 @@ public function get_course_list() {
$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;
}
Expand Down Expand Up @@ -384,9 +374,12 @@ public function get_user_list() {
$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));
Expand Down
75 changes: 37 additions & 38 deletions report/log/classes/renderer.php
Expand Up @@ -94,27 +94,26 @@ public function report_selector_form(report_log_renderable $reportlog) {
$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);
}
}

Expand All @@ -127,26 +126,26 @@ public function report_selector_form(report_log_renderable $reportlog) {

// 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.
Expand Down
5 changes: 4 additions & 1 deletion report/log/index.php
Expand Up @@ -44,8 +44,11 @@
$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;
Expand Down

0 comments on commit d012fad

Please sign in to comment.