<?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="admin/report/customlang/db" VERSION="20100825" COMMENT="XMLDB file for Moodle admin/report/customlang"
+<XMLDB PATH="admin/report/customlang/db" VERSION="20101112" COMMENT="XMLDB file for Moodle admin/report/customlang"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../lib/xmldb/xmldb.xsd"
>
<TABLES>
- <TABLE NAME="customlang" COMMENT="Contains the working checkout of all strings and their customization" NEXT="customlang_components">
+ <TABLE NAME="report_customlang" COMMENT="Contains the working checkout of all strings and their customization" NEXT="report_customlang_components">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="lang"/>
<FIELD NAME="lang" TYPE="char" LENGTH="20" NOTNULL="true" SEQUENCE="false" COMMENT="The code of the language this string belongs to. Like en, cs or es" PREVIOUS="id" NEXT="componentid"/>
<INDEX NAME="uq_lang_component_string" UNIQUE="true" FIELDS="lang, componentid, stringid" COMMENT="For a given language and component, string identifiers must be unique"/>
</INDEXES>
</TABLE>
- <TABLE NAME="customlang_components" COMMENT="Contains the list of all installed plugins that provide their own language pack" PREVIOUS="customlang">
+ <TABLE NAME="report_customlang_components" COMMENT="Contains the list of all installed plugins that provide their own language pack " PREVIOUS="report_customlang">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="name"/>
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="The normalized name of the plugin" PREVIOUS="id" NEXT="version"/>
--- /dev/null
+<?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/>.
+
+/**
+ * Language customization report upgrades
+ *
+ * @package report
+ * @subpackage customlang
+ * @copyright 2010 David Mudrak <david.mudrak@gmail.com>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+function xmldb_report_customlang_upgrade($oldversion) {
+ global $CFG, $DB, $OUTPUT;
+
+ $dbman = $DB->get_manager();
+ $result = true;
+
+ /**
+ * Use proper plugin prefix for tables
+ */
+ if ($oldversion < 2010111200) {
+ if ($dbman->table_exists('customlang')) {
+ $dbman->rename_table(new xmldb_table('customlang'), 'report_customlang');
+ }
+ if ($dbman->table_exists('customlang_components')) {
+ $dbman->rename_table(new xmldb_table('customlang_components'), 'report_customlang_components');
+ }
+ upgrade_plugin_savepoint(true, 2010111200, 'report', 'customlang');
+ }
+
+ return $result;
+}
if (!is_array($strings)) {
$strings = array();
}
- $current = $DB->get_records_list('customlang', 'id', array_keys($strings));
+ $current = $DB->get_records_list('report_customlang', 'id', array_keys($strings));
$now = time();
foreach ($strings as $recordid => $customization) {
$current[$recordid]->modified = 1;
$current[$recordid]->outdated = 0;
$current[$recordid]->timecustomized = null;
- $DB->update_record('customlang', $current[$recordid]);
+ $DB->update_record('report_customlang', $current[$recordid]);
continue;
}
$current[$recordid]->modified = 1;
$current[$recordid]->outdated = 0;
$current[$recordid]->timecustomized = $now;
- $DB->update_record('customlang', $current[$recordid]);
+ $DB->update_record('report_customlang', $current[$recordid]);
continue;
}
}
}
if (!empty($updates)) {
list($sql, $params) = $DB->get_in_or_equal($updates);
- $DB->set_field_select('customlang', 'outdated', 0, "local IS NOT NULL AND id $sql", $params);
+ $DB->set_field_select('report_customlang', 'outdated', 0, "local IS NOT NULL AND id $sql", $params);
}
redirect($nexturl);
global $DB;
// make sure that all components are registered
- $current = $DB->get_records('customlang_components', null, 'name', 'name,version,id');
+ $current = $DB->get_records('report_customlang_components', null, 'name', 'name,version,id');
foreach (self::list_components() as $component) {
if (empty($current[$component])) {
$record = new stdclass();
} else {
$record->version = $version;
}
- $DB->insert_record('customlang_components', $record);
+ $DB->insert_record('report_customlang_components', $record);
} elseif ($version = get_component_version($component)) {
if (is_null($current[$component]->version) or ($version > $current[$component]->version)) {
- $DB->set_field('customlang_components', 'version', $version, array('id' => $current[$component]->id));
+ $DB->set_field('report_customlang_components', 'version', $version, array('id' => $current[$component]->id));
}
}
}
// reload components and fetch their strings
$stringman = get_string_manager();
- $components = $DB->get_records('customlang_components');
+ $components = $DB->get_records('report_customlang_components');
foreach ($components as $component) {
$sql = "SELECT stringid, s.*
- FROM {customlang} s
+ FROM {report_customlang} s
WHERE lang = ? AND componentid = ?
ORDER BY stringid";
$current = $DB->get_records_sql($sql, array($lang, $component->id));
}
if ($needsupdate) {
- $DB->update_record('customlang', $current[$stringid]);
+ $DB->update_record('report_customlang', $current[$stringid]);
continue;
}
$record->timecustomized = null;
}
- $DB->insert_record('customlang', $record);
+ $DB->insert_record('report_customlang', $record);
}
}
}
// get all customized strings from updated components
$sql = "SELECT s.*, c.name AS component
- FROM {customlang} s
- JOIN {customlang_components} c ON s.componentid = c.id
+ FROM {report_customlang} s
+ JOIN {report_customlang_components} c ON s.componentid = c.id
WHERE s.lang = ?
AND (s.local IS NOT NULL OR s.modified = 1)
ORDER BY componentid, stringid";
self::dump_strings($lang, $component, $strings);
}
- $DB->set_field_select('customlang', 'modified', 0, 'lang = ?', array($lang));
+ $DB->set_field_select('report_customlang', 'modified', 0, 'lang = ?', array($lang));
$sm = get_string_manager();
$sm->reset_caches();
}
public static function get_count_of_modified($lang) {
global $DB;
- return $DB->count_records('customlang', array('lang'=>$lang, 'modified'=>1));
+ return $DB->count_records('report_customlang', array('lang'=>$lang, 'modified'=>1));
}
/**
$csql = "SELECT COUNT(*)";
$fsql = "SELECT s.id, s.*, c.name AS component";
- $sql = " FROM {customlang_components} c
- JOIN {customlang} s ON s.componentid = c.id
+ $sql = " FROM {report_customlang_components} c
+ JOIN {report_customlang} s ON s.componentid = c.id
WHERE s.lang = :lang
AND c.name $insql";
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2010082500;
-$plugin->requires = 2010080901;
+$plugin->version = 2010111200;
+$plugin->requires = 2010111002;