mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-50286 report_log: Allow filtering by event origin.
This commit is contained in:
parent
d1a3ea62ef
commit
3dee255163
@ -84,6 +84,9 @@ class report_log_renderable implements renderable {
|
|||||||
/** @var string order to sort */
|
/** @var string order to sort */
|
||||||
public $order;
|
public $order;
|
||||||
|
|
||||||
|
/** @var string origin to filter event origin */
|
||||||
|
public $origin;
|
||||||
|
|
||||||
/** @var int group id */
|
/** @var int group id */
|
||||||
public $groupid;
|
public $groupid;
|
||||||
|
|
||||||
@ -113,7 +116,7 @@ class report_log_renderable implements renderable {
|
|||||||
*/
|
*/
|
||||||
public function __construct($logreader = "", $course = 0, $userid = 0, $modid = 0, $action = "", $groupid = 0, $edulevel = -1,
|
public function __construct($logreader = "", $course = 0, $userid = 0, $modid = 0, $action = "", $groupid = 0, $edulevel = -1,
|
||||||
$showcourses = false, $showusers = false, $showreport = true, $showselectorform = true, $url = "", $date = 0,
|
$showcourses = false, $showusers = false, $showreport = true, $showselectorform = true, $url = "", $date = 0,
|
||||||
$logformat='showashtml', $page = 0, $perpage = 100, $order = "timecreated ASC") {
|
$logformat='showashtml', $page = 0, $perpage = 100, $order = "timecreated ASC", $origin ='') {
|
||||||
|
|
||||||
global $PAGE;
|
global $PAGE;
|
||||||
|
|
||||||
@ -157,6 +160,7 @@ class report_log_renderable implements renderable {
|
|||||||
$this->showreport = $showreport;
|
$this->showreport = $showreport;
|
||||||
$this->showselectorform = $showselectorform;
|
$this->showselectorform = $showselectorform;
|
||||||
$this->logformat = $logformat;
|
$this->logformat = $logformat;
|
||||||
|
$this->origin = $origin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -432,6 +436,24 @@ class report_log_renderable implements renderable {
|
|||||||
return $dates;
|
return $dates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return list of components to show in selector.
|
||||||
|
*
|
||||||
|
* @return array list of origins.
|
||||||
|
*/
|
||||||
|
public function get_origin_options() {
|
||||||
|
global $DB;
|
||||||
|
$origins = $DB->get_records_sql('select distinct origin from {logstore_standard_log} order by origin ASC');
|
||||||
|
$ret = array();
|
||||||
|
$ret[''] = get_string('allsources', 'report_log');
|
||||||
|
foreach ($origins as $origin) {
|
||||||
|
if (!empty($origin->origin)) {
|
||||||
|
$ret[$origin->origin] = get_string($origin->origin, 'report_log');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return list of edulevel.
|
* Return list of edulevel.
|
||||||
*
|
*
|
||||||
@ -469,7 +491,7 @@ class report_log_renderable implements renderable {
|
|||||||
$filter->action = $this->action;
|
$filter->action = $this->action;
|
||||||
$filter->date = $this->date;
|
$filter->date = $this->date;
|
||||||
$filter->orderby = $this->order;
|
$filter->orderby = $this->order;
|
||||||
|
$filter->origin = $this->origin;
|
||||||
// If showing site_errors.
|
// If showing site_errors.
|
||||||
if ('site_errors' === $this->modid) {
|
if ('site_errors' === $this->modid) {
|
||||||
$filter->siteerrors = true;
|
$filter->siteerrors = true;
|
||||||
|
@ -164,6 +164,11 @@ class report_log_renderer extends plugin_renderer_base {
|
|||||||
echo html_writer::label(get_string('actions'), 'menumodaction', false, array('class' => 'accesshide'));
|
echo html_writer::label(get_string('actions'), 'menumodaction', false, array('class' => 'accesshide'));
|
||||||
echo html_writer::select($reportlog->get_actions(), 'modaction', $reportlog->action, get_string("allactions"));
|
echo html_writer::select($reportlog->get_actions(), 'modaction', $reportlog->action, get_string("allactions"));
|
||||||
|
|
||||||
|
// Add origin.
|
||||||
|
$origin = $reportlog->get_origin_options();
|
||||||
|
echo html_writer::label(get_string('origin', 'report_log'), 'menuorigin', false, array('class' => 'accesshide'));
|
||||||
|
echo html_writer::select($origin, 'origin', $reportlog->origin, false);
|
||||||
|
|
||||||
// Add edulevel.
|
// Add edulevel.
|
||||||
$edulevel = $reportlog->get_edulevel_options();
|
$edulevel = $reportlog->get_edulevel_options();
|
||||||
echo html_writer::label(get_string('edulevel'), 'menuedulevel', false, array('class' => 'accesshide'));
|
echo html_writer::label(get_string('edulevel'), 'menuedulevel', false, array('class' => 'accesshide'));
|
||||||
|
@ -485,6 +485,11 @@ class report_log_table_log extends table_sql {
|
|||||||
$joins[] = "edulevel ".$edulevelsql;
|
$joins[] = "edulevel ".$edulevelsql;
|
||||||
$params = array_merge($params, $edulevelparams);
|
$params = array_merge($params, $edulevelparams);
|
||||||
}
|
}
|
||||||
|
// Origin.
|
||||||
|
if (isset($this->filterparams->origin) && ($this->filterparams->origin != '')) {
|
||||||
|
$joins[] = "origin = :origin";
|
||||||
|
$params['origin'] = $this->filterparams->origin;
|
||||||
|
}
|
||||||
|
|
||||||
if (!($this->filterparams->logreader instanceof logstore_legacy\log\store)) {
|
if (!($this->filterparams->logreader instanceof logstore_legacy\log\store)) {
|
||||||
// Filter out anonymous actions, this is N/A for legacy log because it never stores them.
|
// Filter out anonymous actions, this is N/A for legacy log because it never stores them.
|
||||||
|
@ -42,6 +42,7 @@ $chooselog = optional_param('chooselog', false, PARAM_BOOL);
|
|||||||
$logformat = optional_param('download', '', PARAM_ALPHA);
|
$logformat = optional_param('download', '', PARAM_ALPHA);
|
||||||
$logreader = optional_param('logreader', '', PARAM_COMPONENT); // Reader which will be used for displaying logs.
|
$logreader = optional_param('logreader', '', PARAM_COMPONENT); // Reader which will be used for displaying logs.
|
||||||
$edulevel = optional_param('edulevel', -1, PARAM_INT); // Educational level.
|
$edulevel = optional_param('edulevel', -1, PARAM_INT); // Educational level.
|
||||||
|
$origin = optional_param('origin', '', PARAM_TEXT); // Event origin.
|
||||||
|
|
||||||
$params = array();
|
$params = array();
|
||||||
if (!empty($id)) {
|
if (!empty($id)) {
|
||||||
@ -146,7 +147,7 @@ if (empty($course) || ($course->id == $SITE->id)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$reportlog = new report_log_renderable($logreader, $course, $user, $modid, $modaction, $group, $edulevel, $showcourses, $showusers,
|
$reportlog = new report_log_renderable($logreader, $course, $user, $modid, $modaction, $group, $edulevel, $showcourses, $showusers,
|
||||||
$chooselog, true, $url, $date, $logformat, $page, $perpage, 'timecreated DESC');
|
$chooselog, true, $url, $date, $logformat, $page, $perpage, 'timecreated DESC', $origin);
|
||||||
$readers = $reportlog->get_readers();
|
$readers = $reportlog->get_readers();
|
||||||
$output = $PAGE->get_renderer('report_log');
|
$output = $PAGE->get_renderer('report_log');
|
||||||
|
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$string['allsources'] = 'All sources';
|
||||||
|
$string['cli'] = 'CLI';
|
||||||
$string['eventcomponent'] = 'Component';
|
$string['eventcomponent'] = 'Component';
|
||||||
$string['eventcontext'] = 'Event context';
|
$string['eventcontext'] = 'Event context';
|
||||||
$string['eventloggedas'] = '{$a->realusername} as {$a->asusername}';
|
$string['eventloggedas'] = '{$a->realusername} as {$a->asusername}';
|
||||||
@ -36,8 +38,12 @@ $string['log:viewtoday'] = 'View today\'s logs';
|
|||||||
$string['page'] = 'Page {$a}';
|
$string['page'] = 'Page {$a}';
|
||||||
$string['logsformat'] = 'Logs format';
|
$string['logsformat'] = 'Logs format';
|
||||||
$string['nologreaderenabled'] = 'No log reader enabled';
|
$string['nologreaderenabled'] = 'No log reader enabled';
|
||||||
|
$string['origin'] = 'Source';
|
||||||
$string['page-report-log-x'] = 'Any log report';
|
$string['page-report-log-x'] = 'Any log report';
|
||||||
$string['page-report-log-index'] = 'Course log report';
|
$string['page-report-log-index'] = 'Course log report';
|
||||||
$string['page-report-log-user'] = 'User course log report';
|
$string['page-report-log-user'] = 'User course log report';
|
||||||
$string['pluginname'] = 'Logs';
|
$string['pluginname'] = 'Logs';
|
||||||
|
$string['restore'] = 'Restore';
|
||||||
$string['selectlogreader'] = 'Select log reader';
|
$string['selectlogreader'] = 'Select log reader';
|
||||||
|
$string['web'] = 'Web';
|
||||||
|
$string['ws'] = 'Web service';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user