first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
@@ -0,0 +1,46 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Privacy Subsystem implementation for report_configlog.
*
* @package report_configlog
* @copyright 2018 Zig Tan <zig@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace report_configlog\privacy;
defined('MOODLE_INTERNAL') || die();
/**
* Privacy Subsystem for report_configlog implementing null_provider.
*
* @copyright 2018 Zig Tan <zig@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements \core_privacy\local\metadata\null_provider {
/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
* @return string
*/
public static function get_reason(): string {
return 'privacy:metadata';
}
}
@@ -0,0 +1,219 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace report_configlog\reportbuilder\local\entities;
use lang_string;
use core_reportbuilder\local\entities\base;
use core_reportbuilder\local\helpers\format;
use core_reportbuilder\local\report\column;
use core_reportbuilder\local\report\filter;
use core_reportbuilder\local\filters\date;
use core_reportbuilder\local\filters\text;
/**
* Config change entity class implementation
*
* Defines all the columns and filters that can be added to reports that use this entity.
*
* @package report_configlog
* @copyright 2020 Paul Holden <paulh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class config_change extends base {
/**
* Database tables that this entity uses
*
* @return string[]
*/
protected function get_default_tables(): array {
return [
'config_log',
];
}
/**
* The default title for this entity
*
* @return lang_string
*/
protected function get_default_entity_title(): lang_string {
return new lang_string('entityconfigchange', 'report_configlog');
}
/**
* Initialize the entity
*
* @return base
*/
public function initialise(): base {
$columns = $this->get_all_columns();
foreach ($columns as $column) {
$this->add_column($column);
}
$filters = $this->get_all_filters();
foreach ($filters as $filter) {
$this->add_filter($filter);
}
return $this;
}
/**
* Returns list of all available columns
*
* @return column[]
*/
protected function get_all_columns(): array {
$tablealias = $this->get_table_alias('config_log');
// Time modified column.
$columns[] = (new column(
'timemodified',
new lang_string('timemodified', 'report_configlog'),
$this->get_entity_name()
))
->add_joins($this->get_joins())
->set_type(column::TYPE_TIMESTAMP)
->add_fields("{$tablealias}.timemodified")
->set_is_sortable(true)
->add_callback([format::class, 'userdate']);
// Plugin column.
$columns[] = (new column(
'plugin',
new lang_string('plugin', 'report_configlog'),
$this->get_entity_name()
))
->add_joins($this->get_joins())
->set_type(column::TYPE_TEXT)
->add_field("{$tablealias}.plugin")
->set_is_sortable(true)
->add_callback(static function(?string $plugin): string {
return $plugin ?? 'core';
});
// Setting column.
$columns[] = (new column(
'setting',
new lang_string('setting', 'report_configlog'),
$this->get_entity_name()
))
->add_joins($this->get_joins())
->set_type(column::TYPE_TEXT)
->add_field("{$tablealias}.name")
->set_is_sortable(true);
// New value column.
$columns[] = (new column(
'newvalue',
new lang_string('valuenew', 'report_configlog'),
$this->get_entity_name()
))
->add_joins($this->get_joins())
->set_type(column::TYPE_TEXT)
->add_field("{$tablealias}.value")
->set_is_sortable(true)
->add_callback(static function(?string $value): string {
return format_text($value, FORMAT_PLAIN);
});
// Old value column.
$columns[] = (new column(
'oldvalue',
new lang_string('valueold', 'report_configlog'),
$this->get_entity_name()
))
->add_joins($this->get_joins())
->set_type(column::TYPE_TEXT)
->add_field("{$tablealias}.oldvalue")
->set_is_sortable(true)
->add_callback(static function(?string $oldvalue): string {
return format_text($oldvalue, FORMAT_PLAIN);
});
return $columns;
}
/**
* Return list of all available filters
*
* @return filter[]
*/
protected function get_all_filters(): array {
$tablealias = $this->get_table_alias('config_log');
// Time modified filter.
$filters[] = (new filter(
date::class,
'timemodified',
new lang_string('timemodified', 'report_configlog'),
$this->get_entity_name(),
"{$tablealias}.timemodified"
))
->add_joins($this->get_joins())
->set_limited_operators([
date::DATE_ANY,
date::DATE_RANGE,
date::DATE_PREVIOUS,
date::DATE_CURRENT,
]);
// Plugin filter.
$filters[] = (new filter(
text::class,
'plugin',
new lang_string('plugin', 'report_configlog'),
$this->get_entity_name(),
"COALESCE({$tablealias}.plugin, 'core')"
))
->add_joins($this->get_joins());
// Setting filter.
$filters[] = (new filter(
text::class,
'setting',
new lang_string('setting', 'report_configlog'),
$this->get_entity_name(),
"{$tablealias}.name"
))
->add_joins($this->get_joins());
// New value filter.
$filters[] = (new filter(
text::class,
'value',
new lang_string('valuenew', 'report_configlog'),
$this->get_entity_name(),
"{$tablealias}.value"
))
->add_joins($this->get_joins());
// Old value filter.
$filters[] = (new filter(
text::class,
'oldvalue',
new lang_string('valueold', 'report_configlog'),
$this->get_entity_name(),
"{$tablealias}.oldvalue"
))
->add_joins($this->get_joins());
return $filters;
}
}
@@ -0,0 +1,116 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace report_configlog\reportbuilder\local\systemreports;
use context_system;
use report_configlog\reportbuilder\local\entities\config_change;
use core_reportbuilder\system_report;
use core_reportbuilder\local\entities\user;
use stdClass;
/**
* Config changes system report class implementation
*
* @package report_configlog
* @copyright 2020 Paul Holden <paulh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class config_changes extends system_report {
/**
* Initialise report, we need to set the main table, load our entities and set columns/filters
*/
protected function initialise(): void {
// Our main entity, it contains all of the column definitions that we need.
$entitymain = new config_change();
$entitymainalias = $entitymain->get_table_alias('config_log');
$this->set_main_table('config_log', $entitymainalias);
$this->add_entity($entitymain);
// We can join the "user" entity to our "main" entity using standard SQL JOIN.
$entityuser = new user();
$entityuseralias = $entityuser->get_table_alias('user');
$this->add_entity($entityuser
->add_join("LEFT JOIN {user} {$entityuseralias} ON {$entityuseralias}.id = {$entitymainalias}.userid")
);
// Now we can call our helper methods to add the content we want to include in the report.
$this->add_columns();
$this->add_filters();
// Set if report can be downloaded.
$this->set_downloadable(true, get_string('pluginname', 'report_configlog'));
}
/**
* Validates access to view this report
*
* @return bool
*/
protected function can_view(): bool {
return has_capability('moodle/site:config', context_system::instance());
}
/**
* Adds the columns we want to display in the report
*
* They are all provided by the entities we previously added in the {@see initialise} method, referencing each by their
* unique identifier
*/
protected function add_columns(): void {
$columns = [
'config_change:timemodified',
'user:fullnamewithlink',
'config_change:plugin',
'config_change:setting',
'config_change:newvalue',
'config_change:oldvalue',
];
$this->add_columns_from_entities($columns);
// Default sorting.
$this->set_initial_sort_column('config_change:timemodified', SORT_DESC);
// Custom callback to show 'CLI or install' in fullname column when there is no user.
if ($column = $this->get_column('user:fullnamewithlink')) {
$column->add_callback(static function(string $fullname, stdClass $row): string {
return $fullname ?: get_string('usernone', 'report_configlog');
});
}
}
/**
* Adds the filters we want to display in the report
*
* They are all provided by the entities we previously added in the {@see initialise} method, referencing each by their
* unique identifier
*/
protected function add_filters(): void {
$filters = [
'config_change:plugin',
'config_change:setting',
'config_change:value',
'config_change:oldvalue',
'user:fullname',
'config_change:timemodified',
];
$this->add_filters_from_entities($filters);
}
}
+33
View File
@@ -0,0 +1,33 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file contains mappings for classes that have been renamed so that they meet the requirements of the autoloader.
*
* @package report_configlog
* @copyright 2022 Paul Holden <paulh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$renamedclasses = [
// Since Moodle 4.1.
'report_configlog\\local\\systemreports\\config_changes' =>
'report_configlog\\reportbuilder\\local\\systemreports\\config_changes',
'report_configlog\\local\\entities\\config_change' =>
'report_configlog\\reportbuilder\\local\\entities\\config_change',
];
+52
View File
@@ -0,0 +1,52 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Config changes report
*
* @package report
* @subpackage configlog
* @copyright 2009 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use core_reportbuilder\system_report_factory;
use core_reportbuilder\local\filters\text;
use report_configlog\reportbuilder\local\systemreports\config_changes;
require(__DIR__.'/../../config.php');
require_once($CFG->libdir.'/adminlib.php');
// Allow searching by setting when providing parameter directly.
$search = optional_param('search', '', PARAM_TEXT);
admin_externalpage_setup('reportconfiglog', '', ['search' => $search], '', ['pagelayout' => 'report']);
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('configlog', 'report_configlog'));
// Create out report instance, setting initial filtering if required.
$report = system_report_factory::create(config_changes::class, context_system::instance());
if (!empty($search)) {
$report->set_filter_values([
'config_change:setting_operator' => text::IS_EQUAL_TO,
'config_change:setting_value' => $search,
]);
}
echo $report->output();
echo $OUTPUT->footer();
@@ -0,0 +1,41 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Strings for component 'report_configlog', language 'en', branch 'MOODLE_20_STABLE'
*
* @package report
* @subplugin configlog
* @copyright 2009 petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['configlog'] = 'Config changes';
$string['datefrom'] = 'Date from';
$string['dateto'] = 'Date to';
$string['entityconfigchange'] = 'Config change';
$string['plugin'] = 'Plugin';
$string['pluginname'] = 'Config changes';
$string['setting'] = 'Setting';
$string['timemodified'] = 'Date';
$string['user'] = 'User';
$string['usernone'] = 'CLI or install';
$string['user_help'] = 'Search by user first name or last name';
$string['value'] = 'Value';
$string['value_help'] = 'Search by new or original value of the configuration';
$string['valuenew'] = 'New value';
$string['valueold'] = 'Original value';
$string['privacy:metadata'] = 'The Config changes plugin does not store any personal data.';
+31
View File
@@ -0,0 +1,31 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Report settings
*
* @package report
* @subpackage configlog
* @copyright 2009 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
$ADMIN->add('reports', new admin_externalpage('reportconfiglog', get_string('configlog', 'report_configlog'), "$CFG->wwwroot/report/configlog/index.php"));
// no report settings
$settings = null;
@@ -0,0 +1,44 @@
@report @report_configlog @core_reportbuilder
Feature: In a report, admin can see configuration changes
In order see configuration changes
As an admin
I need to view the configuration changes report and use search to filter the report
# Set some config values so the report contains known data.
Background:
Given I log in as "admin"
And I change the window size to "large"
And I set the following administration settings values:
| Initial number of overall feedback fields | 5 |
| Maximum folder download size | 2048 |
| Default city | Perth |
@javascript
Scenario: Display configuration changes report
When I navigate to "Reports > Config changes" in site administration
Then the following should exist in the "reportbuilder-table" table:
| First name | Plugin | Setting | New value | Original value |
| Admin User | quiz | initialnumfeedbacks | 5 | 2 |
| Admin User | folder | maxsizetodownload | 2048 | 0 |
| Admin User | core | defaultcity | Perth | |
@javascript
Scenario Outline: Search configuration changes report
When I navigate to "Reports > Config changes" in site administration
And I click on "Filters" "button"
And I set the following fields in the "<field>" "core_reportbuilder > Filter" to these values:
| <field> operator | Contains |
| <field> value | <search> |
And I click on "Apply" "button" in the "[data-region='report-filters']" "css_element"
And I should see "Filters applied"
Then the following should exist in the "reportbuilder-table" table:
| Plugin | Setting | New value |
| <plugin> | <setting> | <value> |
And I should not see "<excluded>" in the "reportbuilder-table" "table"
Examples:
| field | search | plugin | setting | value | excluded |
| Plugin | folder | folder | maxsizetodownload | 2048 | quiz |
| Setting | initialnumfeedbacks | quiz | initialnumfeedbacks | 5 | maxsizetodownload |
| Setting | maxsizetodownload | folder | maxsizetodownload | 2048 | initialnumfeedbacks |
| New value | Perth | core | defaultcity | Perth | maxsizetodownload |
| Full name | Admin User | core | defaultcity | Perth | zzzzzzzzz |
+30
View File
@@ -0,0 +1,30 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Version details.
*
* @package report
* @subpackage configlog
* @copyright 2011 Petr Skoda
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
$plugin->version = 2024042200; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2024041600; // Requires this Moodle version.
$plugin->component = 'report_configlog'; // Full name of the plugin (used for diagnostics)