Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

mnet: courses and activity log know about mnet remote users

  • Loading branch information...
commit c215b32be74d6386aa09738ea02473a1bfdb283b 1 parent d14383e
martinlanghoff authored
197 course/lib.php
@@ -260,6 +260,96 @@ function make_log_url($module, $url) {
260 260 }
261 261
262 262
  263 +function build_mnet_logs_array($hostid, $course, $user=0, $date=0, $order="l.time ASC", $limitfrom='', $limitnum='',
  264 + $modname="", $modid=0, $modaction="", $groupid=0) {
  265 +
  266 + global $CFG;
  267 +
  268 + // It is assumed that $date is the GMT time of midnight for that day,
  269 + // and so the next 86400 seconds worth of logs are printed.
  270 +
  271 + /// Setup for group handling.
  272 +
  273 + // TODO: I don't understand group/context/etc. enough to be able to do
  274 + // something interesting with it here
  275 + // What is the context of a remote course?
  276 +
  277 + /// If the group mode is separate, and this user does not have editing privileges,
  278 + /// then only the user's group can be viewed.
  279 + //if ($course->groupmode == SEPARATEGROUPS and !has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) {
  280 + // $groupid = get_current_group($course->id);
  281 + //}
  282 + /// If this course doesn't have groups, no groupid can be specified.
  283 + //else if (!$course->groupmode) {
  284 + // $groupid = 0;
  285 + //}
  286 + $groupid = 0;
  287 +
  288 + $joins = array();
  289 +
  290 + $qry = "
  291 + SELECT
  292 + l.*,
  293 + u.firstname,
  294 + u.lastname,
  295 + u.picture
  296 + FROM
  297 + {$CFG->prefix}mnet_log l
  298 + LEFT JOIN
  299 + {$CFG->prefix}user u
  300 + ON
  301 + l.userid = u.id
  302 + WHERE
  303 + ";
  304 +
  305 + $where .= "l.hostid = '$hostid'";
  306 +
  307 + // TODO: Is 1 really a magic number referring to the sitename?
  308 + if ($course != 1 || $modid != 0) {
  309 + $where .= " AND\n l.course='$course'";
  310 + }
  311 +
  312 + if ($modname) {
  313 + $where .= " AND\n l.module = '$modname'";
  314 + }
  315 +
  316 + if ('site_errors' === $modid) {
  317 + $where .= " AND\n ( l.action='error' OR l.action='infected' )";
  318 + } else if ($modid) {
  319 + //TODO: This assumes that modids are the same across sites... probably
  320 + //not true
  321 + $where .= " AND\n l.cmid = '$modid'";
  322 + }
  323 +
  324 + if ($modaction) {
  325 + $firstletter = substr($modaction, 0, 1);
  326 + if (ctype_alpha($firstletter)) {
  327 + $where .= " AND\n lower(l.action) LIKE '%" . strtolower($modaction) . "%'";
  328 + } else if ($firstletter == '-') {
  329 + $where .= " AND\n lower(l.action) NOT LIKE '%" . strtolower(substr($modaction, 1)) . "%'";
  330 + }
  331 + }
  332 +
  333 + if ($user) {
  334 + $where .= " AND\n l.userid = '$user'";
  335 + }
  336 +
  337 + if ($date) {
  338 + $enddate = $date + 86400;
  339 + $where .= " AND\n l.time > '$date' AND l.time < '$enddate'";
  340 + }
  341 +
  342 + $result = array();
  343 + $result['totalcount'] = count_records_sql("SELECT COUNT(*) FROM {$CFG->prefix}mnet_log l WHERE $where");
  344 + if(!empty($result['totalcount'])) {
  345 + $where .= "\n ORDER BY\n $order";
  346 + $result['logs'] = get_records_sql($qry.$where, $limitfrom, $limitnum);
  347 + } else {
  348 + $result['logs'] = array();
  349 + }
  350 + return $result;
  351 +}
  352 +
263 353 function build_logs_array($course, $user=0, $date=0, $order="l.time ASC", $limitfrom='', $limitnum='',
264 354 $modname="", $modid=0, $modaction="", $groupid=0) {
265 355
@@ -453,6 +543,113 @@ function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0, $per
453 543 }
454 544
455 545
  546 +function print_mnet_log($hostid, $course, $user=0, $date=0, $order="l.time ASC", $page=0, $perpage=100,
  547 + $url="", $modname="", $modid=0, $modaction="", $groupid=0) {
  548 +
  549 + global $CFG;
  550 +
  551 + if (!$logs = build_mnet_logs_array($hostid, $course, $user, $date, $order, $page*$perpage, $perpage,
  552 + $modname, $modid, $modaction, $groupid)) {
  553 + notify("No logs found!");
  554 + print_footer($course);
  555 + exit;
  556 + }
  557 +
  558 + if ($course->id == SITEID) {
  559 + $courses[0] = '';
  560 + if ($ccc = get_courses('all', 'c.id ASC', 'c.id,c.shortname,c.visible')) {
  561 + foreach ($ccc as $cc) {
  562 + $courses[$cc->id] = $cc->shortname;
  563 + }
  564 + }
  565 + }
  566 +
  567 + $totalcount = $logs['totalcount'];
  568 + $count=0;
  569 + $ldcache = array();
  570 + $tt = getdate(time());
  571 + $today = mktime (0, 0, 0, $tt["mon"], $tt["mday"], $tt["year"]);
  572 +
  573 + $strftimedatetime = get_string("strftimedatetime");
  574 +
  575 + echo "<p align=\"center\">\n";
  576 + print_string("displayingrecords", "", $totalcount);
  577 + echo "</p>\n";
  578 +
  579 + print_paging_bar($totalcount, $page, $perpage, "$url&amp;perpage=$perpage&amp;");
  580 +
  581 + echo "<table class=\"logtable\" border=\"0\" align=\"center\" cellpadding=\"3\" cellspacing=\"0\">\n";
  582 + echo "<tr>";
  583 + if ($course->id == SITEID) {
  584 + echo "<th class=\"c0 header\">".get_string('course')."</th>\n";
  585 + }
  586 + echo "<th class=\"c1 header\">".get_string('time')."</th>\n";
  587 + echo "<th class=\"c2 header\">".get_string('ip_address')."</th>\n";
  588 + echo "<th class=\"c3 header\">".get_string('fullname')."</th>\n";
  589 + echo "<th class=\"c4 header\">".get_string('action')."</th>\n";
  590 + echo "<th class=\"c5 header\">".get_string('info')."</th>\n";
  591 + echo "</tr>\n";
  592 +
  593 + if (empty($logs['logs'])) {
  594 + echo "</table>\n";
  595 + return;
  596 + }
  597 +
  598 + $row = 1;
  599 + foreach ($logs['logs'] as $log) {
  600 +
  601 + $log->info = $log->coursename;
  602 + $row = ($row + 1) % 2;
  603 +
  604 + if (isset($ldcache[$log->module][$log->action])) {
  605 + $ld = $ldcache[$log->module][$log->action];
  606 + } else {
  607 + $ld = get_record('log_display', 'module', $log->module, 'action', $log->action);
  608 + $ldcache[$log->module][$log->action] = $ld;
  609 + }
  610 + if (0 && $ld && !empty($log->info)) {
  611 + // ugly hack to make sure fullname is shown correctly
  612 + if (($ld->mtable == 'user') and ($ld->field == sql_concat('firstname', "' '" , 'lastname'))) {
  613 + $log->info = fullname(get_record($ld->mtable, 'id', $log->info), true);
  614 + } else {
  615 + $log->info = get_field($ld->mtable, $ld->field, 'id', $log->info);
  616 + }
  617 + }
  618 +
  619 + //Filter log->info
  620 + $log->info = format_string($log->info);
  621 +
  622 + $log->url = strip_tags(urldecode($log->url)); // Some XSS protection
  623 + $log->info = strip_tags(urldecode($log->info)); // Some XSS protection
  624 + $log->url = str_replace('&', '&amp;', $log->url); /// XHTML compatibility
  625 +
  626 + echo '<tr class="r'.$row.'">';
  627 + if ($course->id == SITEID) {
  628 + echo "<td class=\"r$row c0\" nowrap=\"nowrap\">\n";
  629 + echo " <a href=\"{$CFG->wwwroot}/course/view.php?id={$log->course}\">".$courses[$log->course]."</a>\n";
  630 + echo "</td>\n";
  631 + }
  632 + echo "<td class=\"r$row c1\" nowrap=\"nowrap\" align=\"right\">".userdate($log->time, '%a').
  633 + ' '.userdate($log->time, $strftimedatetime)."</td>\n";
  634 + echo "<td class=\"r$row c2\" nowrap=\"nowrap\">\n";
  635 + link_to_popup_window("/iplookup/index.php?ip=$log->ip&amp;user=$log->userid", 'iplookup',$log->ip, 400, 700);
  636 + echo "</td>\n";
  637 + $fullname = fullname($log, has_capability('moodle/site:viewfullnames', get_context_instance(CONTEXT_COURSE, $course->id)));
  638 + echo "<td class=\"r$row c3\" nowrap=\"nowrap\">\n";
  639 + echo " <a href=\"$CFG->wwwroot/user/view.php?id={$log->userid}\">$fullname</a>\n";
  640 + echo "</td>\n";
  641 + echo "<td class=\"r$row c4\" nowrap=\"nowrap\">\n";
  642 + echo $log->action .': '.$log->module;
  643 + echo "</td>\n";;
  644 + echo "<td class=\"r$row c5\" nowrap=\"nowrap\">{$log->info}</td>\n";
  645 + echo "</tr>\n";
  646 + }
  647 + echo "</table>\n";
  648 +
  649 + print_paging_bar($totalcount, $page, $perpage, "$url&amp;perpage=$perpage&amp;");
  650 +}
  651 +
  652 +
456 653 function print_log_csv($course, $user, $date, $order='l.time DESC', $modname,
457 654 $modid, $modaction, $groupid) {
458 655
41 course/report/log/index.php
@@ -6,7 +6,18 @@
6 6 require_once('lib.php');
7 7 require_once($CFG->libdir.'/adminlib.php');
8 8
9   - $id = required_param('id', PARAM_INT);// Course ID
  9 + $id = optional_param('id', PARAM_INT);// Course ID
  10 +
  11 + $host_course = optional_param('host_course', PARAM_PATH);// Course ID
  12 +
  13 + list($hostid, $id) = explode('/', $host_course);
  14 +
  15 + $course_stub = get_record('mnet_log', 'hostid', $hostid, 'course', $id);
  16 + $course->id = $id;
  17 + $course->shortname = $course_stub->coursename;
  18 + $course->fullname = $course_stub->coursename;
  19 +
  20 +
10 21 $group = optional_param('group', -1, PARAM_INT); // Group to display
11 22 $user = optional_param('user', 0, PARAM_INT); // User to display
12 23 $date = optional_param('date', 0, PARAM_FILE); // Date to display - number or some string
@@ -22,10 +33,12 @@
22 33
23 34 require_login();
24 35
25   - if (! $course = get_record('course', 'id', $id) ) {
26   - error('That\'s an invalid course id');
  36 + if ($hostid == $CFG->mnet_localhost_id) {
  37 + if (!$course = get_record('course', 'id', $id) ) {
  38 + error('That\'s an invalid course id'.$id);
  39 + }
27 40 }
28   -
  41 +
29 42 $context = get_context_instance(CONTEXT_COURSE, $course->id);
30 43
31 44 require_capability('moodle/site:viewreports', $context);
@@ -51,10 +64,10 @@
51 64 if ($date) {
52 65 $dateinfo = userdate($date, get_string('strftimedaydate'));
53 66 }
54   -
  67 +
55 68 switch ($logformat) {
56 69 case 'showashtml':
57   - if ($course->id == SITEID) {
  70 + if ($hostid != $CFG->mnet_localhost_id || $course->id == SITEID) {
58 71 $adminroot = admin_get_root();
59 72 admin_externalpage_setup('reportlog', $adminroot);
60 73 admin_externalpage_print_header($adminroot);
@@ -67,11 +80,15 @@
67 80 }
68 81
69 82 print_heading("$course->fullname: $userinfo, $dateinfo (".usertimezone().")");
70   - print_log_selector_form($course, $user, $date, $modname, $modid, $modaction, $group, $showcourses, $showusers, $logformat);
  83 + print_mnet_log_selector_form($hostid, $course, $user, $date, $modname, $modid, $modaction, $group, $showcourses, $showusers, $logformat);
71 84
72   - print_log($course, $user, $date, 'l.time DESC', $page, $perpage,
73   - "index.php?id=$course->id&amp;chooselog=1&amp;user=$user&amp;date=$date&amp;modid=$modid&amp;modaction=$modaction&amp;group=$group",
74   - $modname, $modid, $modaction, $group);
  85 + if($hostid == $CFG->mnet_localhost_id) {
  86 + print_log($course, $user, $date, 'l.time DESC', $page, $perpage,
  87 + "index.php?id=$course->id&amp;chooselog=1&amp;user=$user&amp;date=$date&amp;modid=$modid&amp;modaction=$modaction&amp;group=$group",
  88 + $modname, $modid, $modaction, $group);
  89 + } else {
  90 + print_mnet_log($hostid, $id, $user, $date, 'l.time DESC', $page, $perpage, "", $modname, $modid, $modaction, $group);
  91 + }
75 92 break;
76 93 case 'downloadascsv':
77 94 if (!print_log_csv($course, $user, $date, 'l.time DESC', $modname,
@@ -98,7 +115,7 @@
98 115
99 116
100 117 } else {
101   - if ($course->id == SITEID) {
  118 + if ($hostid != $CFG->mnet_localhost_id || $course->id == SITEID) {
102 119 $adminroot = admin_get_root();
103 120 admin_externalpage_setup('reportlog', $adminroot);
104 121 admin_externalpage_print_header($adminroot);
@@ -122,7 +139,7 @@
122 139
123 140 }
124 141
125   - if ($course->id == SITEID) {
  142 + if ($hostid != $CFG->mnet_localhost_id || $course->id == SITEID) {
126 143 admin_externalpage_print_footer($adminroot);
127 144 } else {
128 145 print_footer($course);
284 course/report/log/lib.php
... ... @@ -1,5 +1,289 @@
1 1 <?php // $Id$
2 2
  3 +function print_mnet_log_selector_form($hostid, $course, $selecteduser=0, $selecteddate='today',
  4 + $modname="", $modid=0, $modaction='', $selectedgroup=-1, $showcourses=0, $showusers=0, $logformat='showashtml') {
  5 +
  6 + global $USER, $CFG, $SITE;
  7 + require_once $CFG->dirroot.'/mnet/peer.php';
  8 +
  9 + $mnet_peer = new mnet_peer();
  10 + $mnet_peer->set_id($hostid);
  11 +
  12 + $sql = "select distinct course, hostid, coursename from {$CFG->prefix}mnet_log";
  13 + $courses = get_records_sql($sql);
  14 + $remotecoursecount = count($courses);
  15 +
  16 + // first check to see if we can override showcourses and showusers
  17 + $numcourses = $remotecoursecount + count_records_select("course", "", "COUNT(id)");
  18 + if ($numcourses < COURSE_MAX_COURSES_PER_DROPDOWN && !$showcourses) {
  19 + $showcourses = 1;
  20 + }
  21 +
  22 + $sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
  23 +
  24 + // Context for remote data is always SITE
  25 + // Groups for remote data are always OFF
  26 + if ($hostid == $CFG->mnet_localhost_id) {
  27 + $context = get_context_instance(CONTEXT_COURSE, $course->id);
  28 +
  29 + /// Setup for group handling.
  30 + if ($course->groupmode == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $context)) {
  31 + $selectedgroup = get_current_group($course->id);
  32 + $showgroups = false;
  33 + }
  34 + else if ($course->groupmode) {
  35 + $selectedgroup = ($selectedgroup == -1) ? get_current_group($course->id) : $selectedgroup;
  36 + $showgroups = true;
  37 + }
  38 + else {
  39 + $selectedgroup = 0;
  40 + $showgroups = false;
  41 + }
  42 +
  43 + } else {
  44 + $context = $sitecontext;
  45 + }
  46 +
  47 + // Get all the possible users
  48 + $users = array();
  49 +
  50 + // If looking at a different host, we're interested in all our site users
  51 + if ($hostid == $CFG->mnet_localhost_id && $course->category) {
  52 + if ($selectedgroup) { // If using a group, only get users in that group.
  53 + $courseusers = get_group_users($selectedgroup, 'u.lastname ASC', '', 'u.id, u.firstname, u.lastname, u.idnumber');
  54 + } else {
  55 + $courseusers = get_course_users($course->id, '', '', 'u.id, u.firstname, u.lastname, u.idnumber');
  56 + }
  57 + } else {
  58 + $courseusers = get_site_users("u.lastaccess DESC", "u.id, u.firstname, u.lastname, u.idnumber");
  59 + }
  60 +
  61 + if (count($courseusers) < COURSE_MAX_USERS_PER_DROPDOWN && !$showusers) {
  62 + $showusers = 1;
  63 + }
  64 +
  65 + if ($showusers) {
  66 + if ($courseusers) {
  67 + foreach ($courseusers as $courseuser) {
  68 + $users[$courseuser->id] = fullname($courseuser, has_capability('moodle/site:viewfullnames', $context));
  69 + }
  70 + }
  71 + if ($guest = get_guest()) {
  72 + $users[$guest->id] = fullname($guest);
  73 + }
  74 + }
  75 +
  76 + // Get all the hosts that we SSO with
  77 + $sql = "SELECT DISTINCT
  78 + h.id,
  79 + h.name
  80 + s.name as servicename
  81 + FROM
  82 + {$CFG->prefix}mnet_host h
  83 + LEFT OUTER JOIN
  84 + {$CFG->prefix}mnet_rpc2host rh ON
  85 + (h.id=rh.host_id AND rh.subscribe!=0)
  86 + LEFT OUTER JOIN
  87 + {$CFG->prefix}mnet_service2rpc sr ON
  88 + sr.rpcid=rh.rpc_id
  89 + LEFT OUTER JOIN
  90 + {$CFG->prefix}mnet_service s ON
  91 + (sr.serviceid=s.id AND s.name='sso')";
  92 + $hosts = get_records_sql($sql);
  93 +
  94 + foreach($hosts as $host) {
  95 + $hostarray[$host->id] = $host->name;
  96 + }
  97 +
  98 + $hostarray[$CFG->mnet_localhost_id] = $SITE->fullname;
  99 + asort($hostarray);
  100 +
  101 + foreach($hostarray as $hostid => $name) {
  102 + $courses = array();
  103 + $sites = array();
  104 + if ($CFG->mnet_localhost_id == $hostid) {
  105 + if (has_capability('moodle/site:viewreports', $sitecontext) && $showcourses) {
  106 + if ($ccc = get_records("course", "", "", "fullname","id,fullname,category")) {
  107 + foreach ($ccc as $cc) {
  108 + if ($cc->category) {
  109 + $courses["$hostid/$cc->id"] = "- $cc->fullname";
  110 + } else {
  111 + $sites["$hostid/$cc->id"] = "$cc->fullname Site";
  112 + }
  113 + }
  114 + }
  115 + }
  116 + } else {
  117 + if (has_capability('moodle/site:viewreports', $sitecontext) && $showcourses) {
  118 + $sql = "select distinct course, coursename from mdl_mnet_log where hostid = '$hostid'";
  119 + if ($ccc = get_records_sql($sql)) {
  120 + foreach ($ccc as $cc) {
  121 + if (1 == $cc->course) {
  122 + $sites["$hostid/$cc->course"] = "$cc->coursename Site";
  123 + } else {
  124 + $courses["$hostid/$cc->course"] = "- $cc->coursename";
  125 + }
  126 + }
  127 + }
  128 + }
  129 + }
  130 +
  131 + asort($courses);
  132 + $dropdown[$name] = $sites + $courses;
  133 + }
  134 +
  135 +
  136 + $activities = array();
  137 + $selectedactivity = "";
  138 +
  139 +/// Casting $course->modinfo to string prevents one notice when the field is null
  140 + if ($modinfo = unserialize((string)$course->modinfo)) {
  141 + $section = 0;
  142 + if ($course->format == 'weeks') { // Bodgy
  143 + $strsection = get_string("week");
  144 + } else {
  145 + $strsection = get_string("topic");
  146 + }
  147 + foreach ($modinfo as $mod) {
  148 + if ($mod->mod == "label") {
  149 + continue;
  150 + }
  151 + if ($mod->section > 0 and $section <> $mod->section) {
  152 + $activities["section/$mod->section"] = "-------------- $strsection $mod->section --------------";
  153 + }
  154 + $section = $mod->section;
  155 + $mod->name = strip_tags(format_string(urldecode($mod->name),true));
  156 + if (strlen($mod->name) > 55) {
  157 + $mod->name = substr($mod->name, 0, 50)."...";
  158 + }
  159 + if (!$mod->visible) {
  160 + $mod->name = "(".$mod->name.")";
  161 + }
  162 + $activities["$mod->cm"] = $mod->name;
  163 +
  164 + if ($mod->cm == $modid) {
  165 + $selectedactivity = "$mod->cm";
  166 + }
  167 + }
  168 + }
  169 +
  170 + if (has_capability('moodle/site:viewreports', $sitecontext) && !$course->category) {
  171 + $activities["site_errors"] = get_string("siteerrors");
  172 + if ($modid === "site_errors") {
  173 + $selectedactivity = "site_errors";
  174 + }
  175 + }
  176 +
  177 + $strftimedate = get_string("strftimedate");
  178 + $strftimedaydate = get_string("strftimedaydate");
  179 +
  180 + asort($users);
  181 +
  182 + // Prepare the list of action options.
  183 + $actions = array(
  184 + 'view' => get_string('view'),
  185 + 'add' => get_string('add'),
  186 + 'update' => get_string('update'),
  187 + 'delete' => get_string('delete'),
  188 + '-view' => get_string('allchanges')
  189 + );
  190 +
  191 + // Get all the possible dates
  192 + // Note that we are keeping track of real (GMT) time and user time
  193 + // User time is only used in displays - all calcs and passing is GMT
  194 +
  195 + $timenow = time(); // GMT
  196 +
  197 + // What day is it now for the user, and when is midnight that day (in GMT).
  198 + $timemidnight = $today = usergetmidnight($timenow);
  199 +
  200 + // Put today up the top of the list
  201 + $dates = array("$timemidnight" => get_string("today").", ".userdate($timenow, $strftimedate) );
  202 +
  203 + if (!$course->startdate or ($course->startdate > $timenow)) {
  204 + $course->startdate = $course->timecreated;
  205 + }
  206 +
  207 + $numdates = 1;
  208 + while ($timemidnight > $course->startdate and $numdates < 365) {
  209 + $timemidnight = $timemidnight - 86400;
  210 + $timenow = $timenow - 86400;
  211 + $dates["$timemidnight"] = userdate($timenow, $strftimedaydate);
  212 + $numdates++;
  213 + }
  214 +
  215 + if ($selecteddate == "today") {
  216 + $selecteddate = $today;
  217 + }
  218 +
  219 + $cid = empty($course->id)? '1' : $course->id;
  220 + echo "<center>\n";
  221 + echo "<form action=\"$CFG->wwwroot/course/report/log/index.php\" method=\"get\">\n";
  222 + echo "<input type=\"hidden\" name=\"chooselog\" value=\"1\" />\n";
  223 + echo "<input type=\"hidden\" name=\"showusers\" value=\"$showusers\" />\n";
  224 + echo "<input type=\"hidden\" name=\"showcourses\" value=\"$showcourses\" />\n";
  225 + if (has_capability('moodle/site:viewreports', $sitecontext) && $showcourses) {
  226 + $cid = empty($course->id)? '1' : $course->id;
  227 + choose_from_menu_nested($dropdown, "host_course", $hostid.'/'.$cid, "");
  228 + } else {
  229 + $courses = array();
  230 + $courses[$course->id] = $course->fullname . ((empty($course->category)) ? ' (Site) ' : '');
  231 + choose_from_menu($courses,"id",$course->id,false);
  232 + if (has_capability('moodle/site:viewreports', $sitecontext)) {
  233 + $a->url = "$CFG->wwwroot/course/report/log/index.php?chooselog=0&group=$selectedgroup&user=$selecteduser"
  234 + ."&id=$course->id&date=$selecteddate&modid=$selectedactivity&showcourses=1&showusers=$showusers";
  235 + print_string('logtoomanycourses','moodle',$a);
  236 + }
  237 + }
  238 +
  239 + if ($showgroups) {
  240 + if ($cgroups = get_groups($course->id)) {
  241 + foreach ($cgroups as $cgroup) {
  242 + $groups[$cgroup->id] = $cgroup->name;
  243 + }
  244 + }
  245 + else {
  246 + $groups = array();
  247 + }
  248 + choose_from_menu ($groups, "group", $selectedgroup, get_string("allgroups") );
  249 + }
  250 +
  251 + if ($showusers) {
  252 + choose_from_menu ($users, "user", $selecteduser, get_string("allparticipants") );
  253 + }
  254 + else {
  255 + $users = array();
  256 + if (!empty($selecteduser)) {
  257 + $user = get_record('user','id',$selecteduser);
  258 + $users[$selecteduser] = fullname($user);
  259 + }
  260 + else {
  261 + $users[0] = get_string('allparticipants');
  262 + }
  263 + choose_from_menu($users, 'user', $selecteduser, false);
  264 + $a->url = "$CFG->wwwroot/course/report/log/index.php?chooselog=0&group=$selectedgroup&user=$selecteduser"
  265 + ."&id=$course->id&date=$selecteddate&modid=$selectedactivity&showusers=1&showcourses=$showcourses";
  266 + print_string('logtoomanyusers','moodle',$a);
  267 + }
  268 + choose_from_menu ($dates, "date", $selecteddate, get_string("alldays"));
  269 + choose_from_menu ($activities, "modid", $selectedactivity, get_string("allactivities"), "", "");
  270 + choose_from_menu ($actions, 'modaction', $modaction, get_string("allactions"));
  271 +
  272 + $logformats = array('showashtml' => get_string('displayonpage'),
  273 + 'downloadascsv' => get_string('downloadtext'),
  274 + 'downloadasexcel' => get_string('downloadexcel'));
  275 + /*
  276 + $logformats = array('showashtml' => get_string('displayonpage'),
  277 + 'downloadascsv' => get_string('downloadtext'),
  278 + 'downloadasexcel' => get_string('downloadexcel'),
  279 + 'downloadasooo' => get_string('downloadasooo'));
  280 + */
  281 + choose_from_menu ($logformats, 'logformat', $logformat, false);
  282 + echo '<input type="submit" value="'.get_string('gettheselogs').'" />';
  283 + echo "</form>";
  284 + echo "</center>";
  285 +}
  286 +
3 287 function print_log_selector_form($course, $selecteduser=0, $selecteddate='today',
4 288 $modname="", $modid=0, $modaction='', $selectedgroup=-1, $showcourses=0, $showusers=0, $logformat='showashtml') {
5 289

0 comments on commit c215b32

Please sign in to comment.
Something went wrong with that request. Please try again.