function show() { global $CFG; $search = $this->search; $this->errorpage = array_key_exists('error', $_GET) ? $_GET['error'] : null; $query = "SELECT count(*) FROM {$CFG->prefix}marginalia_event_log"; $total_events = count_records_sql($query); $query = "SELECT e.id AS id, e.userid AS userid, e.service AS service, e.action AS action" . ", e.description AS description, e.object_type AS object_type" . ", e.object_id AS object_id, e.modified AS modified" . ", e.course as course" . ", concat(u.firstname, ' ', u.lastname) AS fullname" . ", a.sheet_type AS sheet_type" . ", a.quote AS quote" . ", a.note AS note" . ", a.object_type AS an_object_type" . ", a.object_id AS an_object_id" . ", concat(qu.firstname, ' ', qu.lastname) AS qu_fullname" . ", p.id AS p_id" . ", p.subject AS p_name" . ", p.discussion AS p_discussion" . ", p.created AS p_created" . ", d.name AS d_name" . ", d.id AS d_id" . ", c.shortname AS c_name" . " FROM {$CFG->prefix}marginalia_event_log e" . " LEFT OUTER JOIN {$CFG->prefix}course c ON c.id=e.course" . " LEFT OUTER JOIN {$CFG->prefix}marginalia_annotation_log a" . " ON (e.object_type=" . AN_OTYPE_ANNOTATION . " AND a.eventid=e.id)" . " LEFT OUTER JOIN {$CFG->prefix}user u ON u.id=e.userid" . " LEFT OUTER JOIN {$CFG->prefix}forum_posts p" . " ON (a.object_type=" . AN_OTYPE_POST . " AND p.id=a.object_id)" . " LEFT OUTER JOIN {$CFG->prefix}forum_discussions d" . " ON (a.object_type=" . AN_OTYPE_POST . " AND d.id=p.discussion)" . " LEFT OUTER JOIN {$CFG->prefix}USER qu " . " ON (e.object_type=" . AN_OTYPE_ANNOTATION . " AND qu.id=a.quote_author_id)" . " WHERE 1=1"; if ($search->course) { $query .= " AND e.course=" . (int) $search->course . "\n"; } if ($search->user) { $query .= " AND e.userid=" . (int) $search->user . "\n"; } if ($search->discussion) { $query .= " AND d.id=" . (int) $search->discussion . "\n"; } if ($search->object_type) { $query .= " AND e.object_type=" . (int) $search->object_type; if ($search->object_id) { $query .= " AND e.object_id=" . (int) $search->object_id; } $query .= "\n"; } $query .= " ORDER BY e.modified DESC"; // echo "Query: $query\n"; $events = get_records_sql($query, $search->first - 1, $this->maxrecords); echo "<p>" . $search->desc() . "</p>\n"; echo "<table id='events'>\n"; echo " <thead><tr>\n"; echo " <th>Time</th><th>Course</th><th>User</th><th>Service</th><th>Action</th><th>Description</th><th>Object</th>\n"; if ($this->extracolumns) { echo "<th>Sheet</th><th>Quote</th><th>Note</th><th>Post</th><th>Discussion</th><th>Post Author</th><th>Posted</th>\n"; } echo " </tr></thead><tbody>\n"; if ($events && count($events)) { foreach ($events as $event) { echo " <tr>\n"; echo " <td>" . s(MarginaliaHelper::timeToIso($event->modified)) . "</td>\n"; echo " <td>" . s($event->c_name) . $this->zoom_link(array('course' => $event->course)) . "</td>\n"; echo " <td>" . s($event->fullname) . $this->zoom_link(array('user' => $event->userid)) . "</td>\n"; echo " <td>" . s($event->service) . "</td>\n"; echo " <td>" . s($event->action) . "</td>\n"; echo " <td>" . s($event->description) . "</td>\n"; if (AN_OTYPE_ANNOTATION == $event->object_type) { echo "<td>annotation #" . (int) $event->object_id . $this->zoom_link(array('object_type' => $event->object_type, 'object_id' => $event->object_id)) . "</td>\n"; if ($this->extracolumns) { if (AN_OTYPE_ANNOTATION == $event->object_type) { echo "<td>" . s(annotation_globals::sheet_str($event->sheet_type)) . "</td>\n"; echo "<td>" . s($event->quote) . "</td>\n"; echo "<td>" . s($event->note) . "</td>\n"; if (AN_OTYPE_POST == $event->an_object_type) { $url = $CFG->wwwroot . '/mod/forum/permalink.php?p=' . $event->p_id; echo "<td><a href='" . s($url) . "'>" . s($event->p_id) . "</a></td>\n"; echo "<td>" . s($event->d_name) . $this->zoom_link(array('d' => $event->d_id)) . "</td>\n"; echo "<td>" . s($event->qu_fullname) . "</a></td>\n"; echo "<td>" . s(MarginaliaHelper::timeToIso($event->p_created)) . "</td>\n"; } else { echo "<td colspan='4'></td>\n"; } } else { echo "<td colspan='8'></td>\n"; } } } else { if (AN_OTYPE_POST == $event->object_type) { echo "<td>post #" . (int) $event->object_id . $this->zoom_link(array('object_type' => $event->object_type, 'object_id' => $event->object_id)) . "</td>\n"; echo "<td colspan='8'></td>\n"; } else { echo "<td colspan='9'></td>\n"; } } echo " </tr>\n"; } echo "</tbody></table>\n"; $tsearch = $search->derive(); $tsearch->first = '{first}'; marginalia_summary_lib::show_result_pages($search->first, $total_events, $this->maxrecords, $tsearch->url()); } }