mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-57491 report_log: Improve filtering code by using static entries
This commit is contained in:
parent
c4cf1c60f5
commit
e762783dc0
@ -442,15 +442,13 @@ class report_log_renderable implements renderable {
|
||||
* @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');
|
||||
}
|
||||
}
|
||||
$ret['cli'] = get_string('cli', 'report_log');
|
||||
$ret['restore'] = get_string('restore', 'report_log');
|
||||
$ret['web'] = get_string('web', 'report_log');
|
||||
$ret['ws'] = get_string('ws', 'report_log');
|
||||
$ret['---'] = get_string('other', 'report_log');
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
@ -486,10 +486,20 @@ class report_log_table_log extends table_sql {
|
||||
$joins[] = "edulevel ".$edulevelsql;
|
||||
$params = array_merge($params, $edulevelparams);
|
||||
}
|
||||
|
||||
// Origin.
|
||||
if (isset($this->filterparams->origin) && ($this->filterparams->origin != '')) {
|
||||
if ($this->filterparams->origin !== '---') {
|
||||
// Filter by a single origin.
|
||||
$joins[] = "origin = :origin";
|
||||
$params['origin'] = $this->filterparams->origin;
|
||||
} else {
|
||||
// Filter by everything else.
|
||||
list($originsql, $originparams) = $DB->get_in_or_equal(array('cli', 'restore', 'ws', 'web'),
|
||||
SQL_PARAMS_NAMED, 'origin', false);
|
||||
$joins[] = "origin " . $originsql;
|
||||
$params = array_merge($params, $originparams);
|
||||
}
|
||||
}
|
||||
|
||||
if (!($this->filterparams->logreader instanceof logstore_legacy\log\store)) {
|
||||
|
@ -39,6 +39,7 @@ $string['page'] = 'Page {$a}';
|
||||
$string['logsformat'] = 'Logs format';
|
||||
$string['nologreaderenabled'] = 'No log reader enabled';
|
||||
$string['origin'] = 'Source';
|
||||
$string['other'] = 'Other';
|
||||
$string['page-report-log-x'] = 'Any log report';
|
||||
$string['page-report-log-index'] = 'Course log report';
|
||||
$string['page-report-log-user'] = 'User course log report';
|
||||
|
Loading…
x
Reference in New Issue
Block a user