aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-08-07 11:23:52 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-08-07 11:23:52 +0000
commit5028eba1c6087d32ff5db192f12581cfe60a5b87 (patch)
tree55f40226dea46ce9fa09d1343d0422776dd7cb32
parent0171329bbf3b881493b5e45b841781ab03442f94 (diff)
downloadelgg-5028eba1c6087d32ff5db192f12581cfe60a5b87.tar.gz
elgg-5028eba1c6087d32ff5db192f12581cfe60a5b87.tar.bz2
The log browser is now searchable.
git-svn-id: https://code.elgg.org/elgg/trunk@1747 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--mod/logbrowser/index.php31
-rw-r--r--mod/logbrowser/languages/en.php7
-rw-r--r--mod/logbrowser/start.php5
-rw-r--r--mod/logbrowser/views/default/logbrowser/css.php42
-rw-r--r--mod/logbrowser/views/default/logbrowser/form.php66
-rw-r--r--mod/logbrowser/views/default/object/logwrapper.php12
6 files changed, 147 insertions, 16 deletions
diff --git a/mod/logbrowser/index.php b/mod/logbrowser/index.php
index d0a6b7852..cabcad766 100644
--- a/mod/logbrowser/index.php
+++ b/mod/logbrowser/index.php
@@ -17,18 +17,30 @@
$limit = get_input('limit', 40);
$offset = get_input('offset');
- $user_guid = get_input('user_guid',0);
- if ($user_guid) {
- $user = (int) $user_guid;
+ $search_username = get_input('search_username');
+ if ($search_username) {
+ if ($user = get_user_by_username($search_username)) {
+ $user = $user->guid;
+ }
} else {
- $user = "";
+ $user_guid = get_input('user_guid',0);
+ if ($user_guid) {
+ $user = (int) $user_guid;
+ } else {
+ $user = "";
+ }
}
+
+ $timelower = get_input('timelower');
+ if ($timelower) $timelower = strtotime($timelower);
+ $timeupper = get_input('timeupper');
+ if ($timeupper) $timeupper = strtotime($timeupper);
$title = elgg_view_title(elgg_echo('logbrowser'));
// Get log entries
- $log = get_system_log($user, "", "", $limit, $offset);
- $count = get_system_log($user, "", "", $limit, $offset, true);
+ $log = get_system_log($user, "", "", $limit, $offset, false, $timeupper, $timelower);
+ $count = get_system_log($user, "", "", $limit, $offset, true, $timeupper, $timelower);
$log_entries = array();
foreach ($log as $l)
@@ -37,12 +49,15 @@
$tmp->subtype = 'logwrapper';
$tmp->entry = $l;
$log_entries[] = $tmp;
- }
+ }
+
+ $form = elgg_view('logbrowser/form',array('user_guid' => $user, 'timeupper' => $timeupper, 'timelower' => $timelower));
+
set_context('search');
$result = elgg_view_entity_list($log_entries, $count, $offset, $limit, false, false);
set_context('admin');
// Display main admin menu
- page_draw(elgg_echo('logbrowser'),elgg_view_layout("two_column_left_sidebar", '', $title.$result));
+ page_draw(elgg_echo('logbrowser'),elgg_view_layout("two_column_left_sidebar", '', $title . $form . $result));
?> \ No newline at end of file
diff --git a/mod/logbrowser/languages/en.php b/mod/logbrowser/languages/en.php
index 50ba14fc7..ea507af46 100644
--- a/mod/logbrowser/languages/en.php
+++ b/mod/logbrowser/languages/en.php
@@ -16,7 +16,12 @@
*/
'logbrowser' => 'Log browser',
- 'logbrowser:browse' => 'Browse system log',
+ 'logbrowser:browse' => 'Browse system log',
+ 'logbrowser:search' => 'Refine results',
+ 'logbrowser:user' => 'Username to search by',
+ 'logbrowser:starttime' => 'Beginning time (for example "last monday", "1 hour ago")',
+ 'logbrowser:endtime' => 'End time',
+
);
add_translation("en",$english);
diff --git a/mod/logbrowser/start.php b/mod/logbrowser/start.php
index 4a3b5916a..85edc5704 100644
--- a/mod/logbrowser/start.php
+++ b/mod/logbrowser/start.php
@@ -18,7 +18,10 @@
global $CONFIG;
// Register a page handler, so we can have nice URLs
- register_page_handler('logbrowser','logbrowser_page_handler');
+ register_page_handler('logbrowser','logbrowser_page_handler');
+
+ // Extend CSS
+ extend_view('css','logbrowser/css');
}
/**
diff --git a/mod/logbrowser/views/default/logbrowser/css.php b/mod/logbrowser/views/default/logbrowser/css.php
new file mode 100644
index 000000000..95dabb7d7
--- /dev/null
+++ b/mod/logbrowser/views/default/logbrowser/css.php
@@ -0,0 +1,42 @@
+<?php
+
+?>
+
+ #logbrowser_search_area {
+ margin: 3px;
+ }
+
+ #logbrowserSearchform {
+
+ padding: 10px;
+ background-color: #eee;
+
+ }
+
+ .log_entry {
+ margin: 3px;
+ width: 650px;
+ font-size: 80%;
+ }
+
+ .log_entry_user {
+ width: 120px;
+ background-color: #eee;
+ margin-left: 5px;
+ }
+
+ .log_entry_time {
+ width: 210px;
+ background-color: #eee;
+ }
+
+ .log_entry_item {
+ background-color: #eee;
+ margin-left: 5px;
+ }
+
+ .log_entry_action {
+ width: 75px;
+ background-color: #eee;
+ margin-left: 5px;
+ } \ No newline at end of file
diff --git a/mod/logbrowser/views/default/logbrowser/form.php b/mod/logbrowser/views/default/logbrowser/form.php
new file mode 100644
index 000000000..2b0c78720
--- /dev/null
+++ b/mod/logbrowser/views/default/logbrowser/form.php
@@ -0,0 +1,66 @@
+
+<div id="logbrowser_search_area">
+<?php
+
+ // Time lower limit
+
+ if ($vars['timelower']) {
+ $lowerval = date('r',$vars['timelower']);
+ } else {
+ $lowerval = "";
+ }
+ if ($vars['timeupper']) {
+ $upperval = date('r',$vars['timeupper']);
+ } else {
+ $upperval = "";
+ }
+ if ($vars['user_guid']) {
+ if ($user = get_entity($vars['user_guid']))
+ $userval = $user->username;
+ } else {
+ $userval = "";
+ }
+
+
+ $form = "";
+
+ $form .= "<p>" . elgg_echo('logbrowser:user');
+ $form .= elgg_view('input/text',array(
+ 'internalname' => 'search_username',
+ 'value' => $userval
+ )) . "</p>";
+
+ $form .= "<p>" . elgg_echo('logbrowser:starttime');
+ $form .= elgg_view('input/text',array(
+ 'internalname' => 'timelower',
+ 'value' => $lowerval
+ )) . "</p>";
+
+ $form .= "<p>" . elgg_echo('logbrowser:endtime');
+ $form .= elgg_view('input/text',array(
+ 'internalname' => 'timeupper',
+ 'value' => $upperval
+ )) . "</p>";
+ $form .= elgg_view('input/submit',array(
+ 'value' => elgg_echo('search')
+ ));
+
+ $wrappedform = elgg_view('input/form',array(
+ 'body' => $form,
+ 'method' => 'get',
+ 'action' => $vars['url'] . "mod/logbrowser/"
+ ));
+
+ if ($upperval || $lowerval || $userval) {
+ $hidden = "";
+ } else {
+ $hidden = "style=\"display:none\"";
+ }
+
+?>
+
+ <div id="logbrowserSearchform" <?php echo $hidden; ?>><?php echo $wrappedform; ?></div>
+ <p>
+ <a href="#" onclick="$('#logbrowserSearchform').toggle()"><?php echo elgg_echo('logbrowser:search'); ?></a>
+ </p>
+ </div> \ No newline at end of file
diff --git a/mod/logbrowser/views/default/object/logwrapper.php b/mod/logbrowser/views/default/object/logwrapper.php
index 8450c9b66..a46b166cd 100644
--- a/mod/logbrowser/views/default/object/logwrapper.php
+++ b/mod/logbrowser/views/default/object/logwrapper.php
@@ -21,17 +21,17 @@
?>
<table class="log_entry">
<tr>
- <td class="log_entry_user">
- <?php if ($by) {echo "<a href=\"".$by->getURL()."\">{$by->name}</a>"; } else echo "&nbsp;"; ?>
- <td>
<td class="log_entry_time">
<?php echo date('r', $entry->time_created ); ?>
</td>
+ <td class="log_entry_user">
+ <?php if ($by) {echo "<a href=\"".$by->getURL()."\">{$by->name}</a>"; } else echo "&nbsp;"; ?>
+ <td>
<td class="log_entry_item">
<?php
- if ($obj_url) $info .= "<a href=\"$obj_url\">";
- $info .= "{$entry->object_class}";
- if ($obj_url) $info .= "</a>";
+ if ($obj_url) echo "<a href=\"$obj_url\">";
+ echo "{$entry->object_class}";
+ if ($obj_url) echo "</a>";
?>
</td>
<td class="log_entry_action">