Skip to content

Commit

Permalink
Merge branch 'w16_MDL-44910_m27_logupgrade' of https://github.com/sko…
Browse files Browse the repository at this point in the history
  • Loading branch information
Damyon Wiese committed Apr 14, 2014
2 parents 8f6b473 + 5d2abe7 commit a4b2e65
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 6 deletions.
20 changes: 17 additions & 3 deletions admin/tool/log/db/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
47 changes: 47 additions & 0 deletions admin/tool/log/db/upgrade.php
Original file line number Diff line number Diff line change
@@ -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;
}
2 changes: 1 addition & 1 deletion admin/tool/log/store/legacy/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
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'),
Expand Down
4 changes: 2 additions & 2 deletions admin/tool/log/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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).

0 comments on commit a4b2e65

Please sign in to comment.