diff --git a/admin/tool/log/store/standard/classes/log/store.php b/admin/tool/log/store/standard/classes/log/store.php index 8c56a86f7cc..b10dbc4ff02 100644 --- a/admin/tool/log/store/standard/classes/log/store.php +++ b/admin/tool/log/store/standard/classes/log/store.php @@ -40,6 +40,11 @@ class store implements \tool_log\log\writer, \core\log\sql_reader { $this->logguests = $this->get_config('logguests', 1); } + /** + * Finally store the events into the database. + * + * @param \core\event\base[] $events + */ protected function insert_events($events) { global $DB; @@ -102,5 +107,15 @@ class store implements \tool_log\log\writer, \core\log\sql_reader { } public function cron() { + global $DB; + $loglifetime = $this->get_config('loglifetime', 0); + + // NOTE: we should do this only once a day, new cron will deal with this. + + if ($loglifetime > 0) { + $loglifetime = time() - ($loglifetime * 3600 * 24); // Value in days. + $DB->delete_records_select("logstore_standard_log", "timecreated < ?", array($loglifetime)); + mtrace(" Deleted old log records from standard store."); + } } } diff --git a/admin/tool/log/store/standard/lang/en/logstore_standard.php b/admin/tool/log/store/standard/lang/en/logstore_standard.php index 9cd59c18f67..c31967f6a7b 100644 --- a/admin/tool/log/store/standard/lang/en/logstore_standard.php +++ b/admin/tool/log/store/standard/lang/en/logstore_standard.php @@ -22,6 +22,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +$string['buffersize'] = 'Write buffer size'; $string['pluginname'] = 'Standard log'; $string['pluginname_desc'] = 'Standard log plugin, the data is stored in Moodle database table.'; $string['standard:read'] = 'Read logs'; diff --git a/admin/tool/log/store/standard/settings.php b/admin/tool/log/store/standard/settings.php index c1faa1ee2f1..1a2e4c5f201 100644 --- a/admin/tool/log/store/standard/settings.php +++ b/admin/tool/log/store/standard/settings.php @@ -26,8 +26,28 @@ defined('MOODLE_INTERNAL') || die(); if ($hassiteconfig) { - // TODO: Localise these settings. + $settings->add(new admin_setting_configcheckbox('logstore_standard/logguests', + new lang_string('logguests', 'core_admin'), + new lang_string('logguests_help', 'core_admin'), 1)); - $settings->add(new admin_setting_configcheckbox('logstore_standard/logguests', 'Log guest actions', '', '1')); - $settings->add(new admin_setting_configtext('logstore_standard/buffersize', 'Buffer size', '', '50', PARAM_INT)); + $options = array( + 0 => new lang_string('neverdeletelogs'), + 1000 => new lang_string('numdays', '', 1000), + 365 => new lang_string('numdays', '', 365), + 180 => new lang_string('numdays', '', 180), + 150 => new lang_string('numdays', '', 150), + 120 => new lang_string('numdays', '', 120), + 90 => new lang_string('numdays', '', 90), + 60 => new lang_string('numdays', '', 60), + 35 => new lang_string('numdays', '', 35), + 10 => new lang_string('numdays', '', 10), + 5 => new lang_string('numdays', '', 5), + 2 => new lang_string('numdays', '', 2)); + $settings->add(new admin_setting_configselect('logstore_standard/loglifetime', + new lang_string('loglifetime', 'core_admin'), + new lang_string('configloglifetime', 'core_admin'), 0, $options)); + + $settings->add(new admin_setting_configtext('logstore_standard/buffersize', + get_string('buffersize', 'logstore_standard'), + '', '50', PARAM_INT)); } diff --git a/admin/tool/log/store/standard/version.php b/admin/tool/log/store/standard/version.php index 9ef5f966600..a19fa63833d 100644 --- a/admin/tool/log/store/standard/version.php +++ b/admin/tool/log/store/standard/version.php @@ -24,6 +24,6 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2014011300; // The current plugin version (Date: YYYYMMDDXX). -$plugin->requires = 2014011000; // Requires this Moodle version. +$plugin->version = 2014013000; // The current plugin version (Date: YYYYMMDDXX). +$plugin->requires = 2014012400; // Requires this Moodle version. $plugin->component = 'logstore_standard'; // Full name of the plugin (used for diagnostics).