Permalink
Browse files

MDL-8119 : Improvements to logging where Mnet hosts are involved

  • Loading branch information...
1 parent aa34400 commit f4f534c675b37cc37d2d988e79ab1394517c4306 donal72 committed Aug 3, 2007
Showing with 30 additions and 22 deletions.
  1. +8 −1 course/lib.php
  2. +8 −8 course/report/log/index.php
  3. +14 −13 course/report/log/lib.php
View
@@ -246,6 +246,9 @@ function make_log_url($module, $url) {
case 'blog':
return "/$module/$url";
break;
+ case 'mnet course':
+ return "/course/$url";
+ break;
case 'upload':
return $url;
break;
@@ -508,7 +511,11 @@ function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0, $per
echo '<tr class="r'.$row.'">';
if ($course->id == SITEID) {
echo "<td class=\"cell c0\">\n";
- echo " <a href=\"{$CFG->wwwroot}/course/view.php?id={$log->course}\">". format_string($courses[$log->course])."</a>\n";
+ if (empty($log->course)) {
+ echo format_string($log->info)."\n";
+ } else {
+ echo " <a href=\"{$CFG->wwwroot}/course/view.php?id={$log->course}\">". format_string($courses[$log->course])."</a>\n";
+ }
echo "</td>\n";
}
echo "<td class=\"cell c1\" align=\"right\">".userdate($log->time, '%a').
@@ -39,19 +39,19 @@
if (!$course = get_record('course', 'id', $id) ) {
error('That\'s an invalid course id'.$id);
}
+ $context = get_context_instance(CONTEXT_COURSE, $course->id);
+ require_capability('moodle/site:viewreports', $context);
+ add_to_log($course->id, "course", "report log", "report/log/index.php?id=$course->id", $course->id);
} else {
$course_stub = array_pop(get_records_select('mnet_log', " hostid='$hostid' AND course='$id' ", '', '*', '', '1'));
$course->id = $id;
$course->shortname = $course_stub->coursename;
$course->fullname = $course_stub->coursename;
+ $context = get_context_instance(CONTEXT_SYSTEM, SITEID);
+ require_capability('moodle/site:viewreports', $context);
+ add_to_log(0, "mnet course", "report log", "report/log/index.php?chooselog=1&host_course=".urlencode($host_course), $course->fullname);
}
- $context = get_context_instance(CONTEXT_COURSE, $course->id);
-
- require_capability('moodle/site:viewreports', $context);
-
- add_to_log($course->id, "course", "report log", "report/log/index.php?id=$course->id", $course->id);
-
$strlogs = get_string('logs');
$stradministration = get_string('administration');
$strreports = get_string('reports');
@@ -74,7 +74,7 @@
switch ($logformat) {
case 'showashtml':
- if ($hostid != $CFG->mnet_localhost_id || $course->id == SITEID) {
+ if ($hostid != $CFG->mnet_localhost_id || ($hostid == $CFG->mnet_localhost_id && $course->id == SITEID)) {
$adminroot = admin_get_root();
admin_externalpage_setup('reportlog', $adminroot);
admin_externalpage_print_header($adminroot);
@@ -122,7 +122,7 @@
} else {
- if ($hostid != $CFG->mnet_localhost_id || $course->id == SITEID) {
+ if ($hostid != $CFG->mnet_localhost_id || ($hostid == $CFG->mnet_localhost_id && $course->id == SITEID)) {
$adminroot = admin_get_root();
admin_externalpage_setup('reportlog', $adminroot);
admin_externalpage_print_header($adminroot);
View
@@ -85,6 +85,9 @@ function print_mnet_log_selector_form($hostid, $course, $selecteduser=0, $select
order by
h.name";
+ $hostarray = array();
+ $dropdown = array();
+
if ($hosts = get_records_sql($sql)) {
foreach($hosts as $host) {
$hostarray[$host->id] = $host->name;
@@ -94,36 +97,34 @@ function print_mnet_log_selector_form($hostid, $course, $selecteduser=0, $select
$hostarray[$CFG->mnet_localhost_id] = $SITE->fullname;
asort($hostarray);
- foreach($hostarray as $hostid => $name) {
+ // $hostid already exists
+ foreach($hostarray as $hostid_ => $name) {
$courses = array();
$sites = array();
- if ($CFG->mnet_localhost_id == $hostid) {
- if (has_capability('moodle/site:viewreports', $sitecontext) && $showcourses) {
+ if (has_capability('moodle/site:viewreports', $context) && $showcourses) {
+ if ($CFG->mnet_localhost_id == $hostid_) {
if ($ccc = get_records("course", "", "", "fullname","id,fullname,category")) {
foreach ($ccc as $cc) {
if ($cc->id == SITEID) {
- $sites["$hostid/$cc->id"] = format_string($cc->fullname).' ('.get_string('site').')';
+ $sites["$hostid_/$cc->id"] = format_string($cc->fullname).' ('.get_string('site').')';
} else {
- $courses["$hostid/$cc->id"] = format_string($cc->fullname);
+ $courses["$hostid_/$cc->id"] = format_string($cc->fullname);
}
}
}
- }
- } else {
- if (has_capability('moodle/site:viewreports', $sitecontext) && $showcourses) {
- $sql = "select distinct course, coursename from mdl_mnet_log where hostid = '$hostid'";
+ } else {
+ $sql = "select distinct course, coursename from mdl_mnet_log where hostid = '$hostid_'";
if ($ccc = get_records_sql($sql)) {
foreach ($ccc as $cc) {
- if (1 == $cc->course) { // TODO: this might be wrong - site course may have another id
- $sites["$hostid/$cc->course"] = $cc->coursename.' ('.get_string('site').')';
+ if (1 == $cc->course) { // TODO: MDL-8187 : this might be wrong - site course may have another id
+ $sites["$hostid_/$cc->course"] = $cc->coursename.' ('.get_string('site').')';
} else {
- $courses["$hostid/$cc->course"] = $cc->coursename;
+ $courses["$hostid_/$cc->course"] = $cc->coursename;
}
}
}
}
}
-
asort($courses);
$dropdown[$name] = $sites + $courses;
}

0 comments on commit f4f534c

Please sign in to comment.