1<?php
2/**
3 * Log browser table
4 */
5
6$log_entries = elgg_extract('log_entries', $vars);
7
8if (empty($log_entries)) {
9	echo elgg_echo('notfound');
10	return true;
11}
12
13?>
14
15<table class="elgg-table">
16	<thead>
17		<tr>
18			<th><?php echo elgg_echo('logbrowser:date'); ?></th>
19			<th><?php echo elgg_echo('logbrowser:ip_address'); ?></th>
20			<th><?php echo elgg_echo('logbrowser:user:name'); ?></th>
21			<th><?php echo elgg_echo('logbrowser:user:guid'); ?></th>
22			<th><?php echo elgg_echo('logbrowser:object'); ?></th>
23			<th><?php echo elgg_echo('logbrowser:object:guid'); ?></th>
24			<th><?php echo elgg_echo('logbrowser:action'); ?></th>
25		</tr>
26	</thead>
27<?php
28	$alt = '';
29foreach ($log_entries as $entry) {
30	if ($entry->ip_address) {
31		$ip_address = $entry->ip_address;
32	} else {
33		$ip_address = '&nbsp;';
34	}
35
36	$user = get_entity($entry->performed_by_guid);
37	if ($user) {
38		$user_link = elgg_view('output/url', [
39			'href' => $user->getURL(),
40			'text' => $user->getDisplayName(),
41			'is_trusted' => true,
42		]);
43		$user_guid_link = elgg_view('output/url', [
44			'href' => "admin/administer_utilities/logbrowser?user_guid={$user->guid}",
45			'text' => $user->getGUID(),
46			'is_trusted' => true,
47		]);
48	} else {
49		$user_guid_link = $user_link = '&nbsp;';
50	}
51
52	$object = system_log_get_object_from_log_entry($entry);
53	if (is_callable([$object, 'getURL'])) {
54		$object_link = elgg_view('output/url', [
55			'href' => $object->getURL(),
56			'text' => $entry->object_class,
57			'is_trusted' => true,
58		]);
59	} else {
60		$object_link = $entry->object_class;
61	}
62?>
63<tr <?php echo $alt; ?>>
64<td class="log-entry-time">
65	<?php echo date('r', $entry->time_created); ?>
66</td>
67<td class="log-entry-ip-address">
68	<?php echo $ip_address; ?>
69</td>
70<td class="log-entry-user">
71	<?php echo $user_link; ?>
72</td>
73<td class="log-entry-guid">
74	<?php echo $user_guid_link; ?>
75</td>
76<td class="log-entry-object">
77	<?php echo $object_link; ?>
78</td>
79<td class="log-entry-guid">
80	<?php echo $entry->object_id; ?>
81</td>
82<td class="log-entry-action">
83	<?php echo $entry->event; ?>
84</td>
85</tr>
86<?php
87
88$alt = $alt ? '' : 'class="alt"';
89}
90?>
91</table>
92<?php
93