Merge branch 'w16_MDL-44910_m27_logupgrade' of https://github.com/skodak/moodle

This commit is contained in:
Damyon Wiese 2014-04-14 10:14:47 +08:00
commit a4b2e65c7d
4 changed files with 67 additions and 6 deletions

View file

@ -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');

View file

@ -0,0 +1,47 @@
<?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/>.
/**
* 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;
}

View file

@ -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'),

View file

@ -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).