diff --git a/admin/tool/log/db/install.php b/admin/tool/log/db/install.php index 6fccec41253..52d2d9de55d 100644 --- a/admin/tool/log/db/install.php +++ b/admin/tool/log/db/install.php @@ -24,14 +24,28 @@ defined('MOODLE_INTERNAL') || die(); +/** + * Install the plugin. + */ function xmldb_tool_log_install() { - global $CFG; + global $CFG, $DB; $enabled = array(); - // For now enable only the legacy logging, this keeps 100% BC. + // Add data to new log only from now on. + if (file_exists("$CFG->dirroot/$CFG->admin/tool/log/store/standard")) { + $enabled[] = 'logstore_standard'; + } + + // Enable legacy log reading, but only if there are existing data. if (file_exists("$CFG->dirroot/$CFG->admin/tool/log/store/legacy")) { - $enabled[] = 'logstore_legacy'; + unset_config('loglegacy', 'logstore_legacy'); + // Do not enabled legacy logging if somebody installed a new + // site and in less than one day upgraded to 2.7. + $params = array('yesterday' => time() - 60*60*24); + if ($DB->record_exists_select('log', "time < :yesterday", $params)) { + $enabled[] = 'logstore_legacy'; + } } set_config('enabled_stores', implode(',', $enabled), 'tool_log'); diff --git a/admin/tool/log/db/upgrade.php b/admin/tool/log/db/upgrade.php new file mode 100644 index 00000000000..0dc059726c8 --- /dev/null +++ b/admin/tool/log/db/upgrade.php @@ -0,0 +1,47 @@ +. + +/** + * Logging support. + * + * @package tool_log + * @copyright 2014 Petr Skoda {@link http://skodak.org} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +/** + * Upgrade the plugin. + * + * @param int $oldversion + * @return bool always true + */ +function xmldb_tool_log_upgrade($oldversion) { + global $CFG, $DB, $OUTPUT; + + $dbman = $DB->get_manager(); + + if ($oldversion < 2014040600) { + // Reset logging defaults in dev branches, + // in production upgrade the install.php is executed instead. + require_once(__DIR__ . '/install.php'); + xmldb_tool_log_install(); + upgrade_plugin_savepoint(true, 2014040600, 'tool', 'log'); + } + + return true; +} diff --git a/admin/tool/log/store/legacy/settings.php b/admin/tool/log/store/legacy/settings.php index d9ed97b5872..0a7149ecb7c 100644 --- a/admin/tool/log/store/legacy/settings.php +++ b/admin/tool/log/store/legacy/settings.php @@ -27,7 +27,7 @@ defined('MOODLE_INTERNAL') || die(); if ($hassiteconfig) { $settings->add(new admin_setting_configcheckbox('logstore_legacy/loglegacy', new lang_string('loglegacy', 'logstore_legacy'), - new lang_string('loglegacy_help', 'logstore_legacy'), 1)); + new lang_string('loglegacy_help', 'logstore_legacy'), 0)); $settings->add(new admin_setting_configcheckbox('logguests', new lang_string('logguests', 'admin'), diff --git a/admin/tool/log/version.php b/admin/tool/log/version.php index 0838cd29665..a70afc3a21e 100644 --- a/admin/tool/log/version.php +++ b/admin/tool/log/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 = 2014040600; // The current plugin version (Date: YYYYMMDDXX). +$plugin->requires = 2014040300; // Requires this Moodle version. $plugin->component = 'tool_log'; // Full name of the plugin (used for diagnostics).