Skip to content

Commit

Permalink
MDL-68261 report_configlog: Log changes from admin/cli/cfg.php
Browse files Browse the repository at this point in the history
  • Loading branch information
brendanheywood committed May 5, 2020
1 parent cd391f9 commit 76de190
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
7 changes: 6 additions & 1 deletion admin/cli/cfg.php
Expand Up @@ -124,7 +124,12 @@
cli_error('The configuration variable is hard-set in the config.php, unable to change.', 4);
}

set_config($options['name'], $options['set'], $options['component']);
$new = $options['set'];
$old = get_config($options['component'], $options['name']);
if ($new !== $old) {
set_config($options['name'], $options['set'], $options['component']);
add_to_config_log($options['name'], $old, $new, $options['component']);
}
exit(0);
}

Expand Down
20 changes: 19 additions & 1 deletion report/configlog/classes/output/report_table.php
Expand Up @@ -90,7 +90,7 @@ protected function init_sql() {
$fields = 'cl.id, cl.timemodified, cl.plugin, cl.name, cl.value, cl.oldvalue, cl.userid, ' . $userfields;

$from = '{config_log} cl
JOIN {user} u ON u.id = cl.userid';
LEFT JOIN {user} u ON u.id = cl.userid';

// Report search.
$where = '1=1';
Expand Down Expand Up @@ -143,6 +143,24 @@ public function col_timemodified(\stdClass $row) {
return userdate($row->timemodified);
}

/**
* Format fullname field
*
* @param stdClass $row
* @return string
*/
public function col_fullname($row) {

$userid = $row->{$this->useridfield};
if (empty($userid)) {
// If the user id is empty it must have been set via the
// admin/cli/cfg.php script or during the initial install.
return get_string('usernone', 'report_configlog');
} else {
return parent::col_fullname($row);
}
}

/**
* Format report plugin field
*
Expand Down
1 change: 1 addition & 0 deletions report/configlog/lang/en/report_configlog.php
Expand Up @@ -31,6 +31,7 @@
$string['setting'] = 'Setting';
$string['timemodified'] = 'Date';
$string['user'] = 'User';
$string['usernone'] = 'CLI or install';
$string['user_help'] = 'Search by user first name or surname';
$string['value'] = 'Value';
$string['value_help'] = 'Search by new or original value of the configuration';
Expand Down

0 comments on commit 76de190

Please sign in to comment.