From ee35e0b8557ce5c3d2493b1001752201cce963d8 Mon Sep 17 00:00:00 2001 From: tjhunt Date: Tue, 28 Mar 2006 17:33:40 +0000 Subject: [PATCH] Allow the display of course logs to be filtered by type of action. --- course/lib.php | 7 ++++++- course/report/log/index.php | 2 +- course/report/log/lib.php | 10 ++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/course/lib.php b/course/lib.php index acd0701435b..6014697d59c 100644 --- a/course/lib.php +++ b/course/lib.php @@ -303,7 +303,12 @@ function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0, $per } if ($modaction) { - $joins[] = "l.action = '$modaction'"; + $firstletter = substr($modaction, 0, 1); + if (ctype_alpha($firstletter)) { + $joins[] = "lower(l.action) LIKE '%" . strtolower($modaction) . "%'"; + } else if ($firstletter == '-') { + $joins[] = "lower(l.action) NOT LIKE '%" . strtolower(substr($modaction, 1)) . "%'"; + } } /// Getting all members of a group. diff --git a/course/report/log/index.php b/course/report/log/index.php index 20c1a1769f1..7649a7f8036 100644 --- a/course/report/log/index.php +++ b/course/report/log/index.php @@ -11,7 +11,7 @@ $date = optional_param('date', 0, PARAM_CLEAN); // Date to display $modname = optional_param('modname', ''); // course_module->id $modid = optional_param('modid', ''); // course_module->id - $modaction = optional_param('modaction', ''); // an action as recorded in the logs + $modaction = optional_param('modaction', '', PARAM_ALPHAEXT); // an action as recorded in the logs $page = optional_param('page', '0', PARAM_INT); // which page to show $perpage = optional_param('perpage', '100', PARAM_INT); // how many per page $showcourses = optional_param('showcourses',0,PARAM_INT); // whether to show courses if we're over our limit. diff --git a/course/report/log/lib.php b/course/report/log/lib.php index c0bdc019d40..7491f7d0561 100644 --- a/course/report/log/lib.php +++ b/course/report/log/lib.php @@ -113,6 +113,15 @@ function print_log_selector_form($course, $selecteduser=0, $selecteddate="today" asort($users); + // Prepare the list of action options. + $actions = array( + 'view' => get_string('view'), + 'add' => get_string('add'), + 'update' => get_string('update'), + 'delete' => get_string('delete'), + '-view' => get_string('allchanges') + ); + // Get all the possible dates // Note that we are keeping track of real (GMT) time and user time // User time is only used in displays - all calcs and passing is GMT @@ -191,6 +200,7 @@ function print_log_selector_form($course, $selecteduser=0, $selecteddate="today" } choose_from_menu ($dates, "date", $selecteddate, get_string("alldays")); choose_from_menu ($activities, "modid", $selectedactivity, get_string("allactivities"), "", ""); + choose_from_menu ($actions, 'modaction', $modaction, get_string("allactions")); echo ''; echo ""; echo "";