From 5028eba1c6087d32ff5db192f12581cfe60a5b87 Mon Sep 17 00:00:00 2001 From: ben Date: Thu, 7 Aug 2008 11:23:52 +0000 Subject: The log browser is now searchable. git-svn-id: https://code.elgg.org/elgg/trunk@1747 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/logbrowser/index.php | 31 +++++++--- mod/logbrowser/languages/en.php | 7 ++- mod/logbrowser/start.php | 5 +- mod/logbrowser/views/default/logbrowser/css.php | 42 ++++++++++++++ mod/logbrowser/views/default/logbrowser/form.php | 66 ++++++++++++++++++++++ mod/logbrowser/views/default/object/logwrapper.php | 12 ++-- 6 files changed, 147 insertions(+), 16 deletions(-) create mode 100644 mod/logbrowser/views/default/logbrowser/css.php create mode 100644 mod/logbrowser/views/default/logbrowser/form.php (limited to 'mod') 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 @@ + + + #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 @@ + +
+username; + } else { + $userval = ""; + } + + + $form = ""; + + $form .= "

" . elgg_echo('logbrowser:user'); + $form .= elgg_view('input/text',array( + 'internalname' => 'search_username', + 'value' => $userval + )) . "

"; + + $form .= "

" . elgg_echo('logbrowser:starttime'); + $form .= elgg_view('input/text',array( + 'internalname' => 'timelower', + 'value' => $lowerval + )) . "

"; + + $form .= "

" . elgg_echo('logbrowser:endtime'); + $form .= elgg_view('input/text',array( + 'internalname' => 'timeupper', + 'value' => $upperval + )) . "

"; + $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\""; + } + +?> + +
>
+

+ +

+
\ 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 @@ ?> - +
- getURL()."\">{$by->name}"; } else echo " "; ?> - time_created ); ?> + getURL()."\">{$by->name}"; } else echo " "; ?> + "; - $info .= "{$entry->object_class}"; - if ($obj_url) $info .= ""; + if ($obj_url) echo ""; + echo "{$entry->object_class}"; + if ($obj_url) echo ""; ?> -- cgit v1.2.3