mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 08:55:15 +02:00
fix for MDL-6859, MDL-6860
This commit is contained in:
parent
010b211f51
commit
1b19e8107e
@ -6,12 +6,13 @@
|
||||
<FIELD name="transid" method="NO_CONV" type="varchar" length="255" />
|
||||
<FIELD name="amount" method="NO_CONV" type="varchar" length="10" />
|
||||
<FIELD name="currency" method="NO_CONV" type="char" length="3" />
|
||||
<FIELD name="paymentmethod" method="NO_CONV" type="enum('cc', 'echeck')" length="0" default="cc"/>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="enrol_authorize_refunds">
|
||||
<FIELDS>
|
||||
<FIELD name="amount" method="NO_CONV" type="varchar" length="10" />
|
||||
</FIELDS>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</DBMIGRATION>
|
||||
|
@ -228,6 +228,164 @@ function migrate2utf8_user($fields, $crash, $debug, $maxrecords, $done, $tablest
|
||||
|
||||
}
|
||||
|
||||
function migrate2utf8_user_info_category_name($recordid) {
|
||||
global $CFG, $globallang;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$uic = get_record('user_info_category', 'id', $recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
if ($globallang) {
|
||||
$fromenc = $globallang;
|
||||
} else {
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = null; //Non existing!
|
||||
$userlang = null; // Non existing
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
}
|
||||
|
||||
/// Initialise $result
|
||||
$result = $uic->name;
|
||||
|
||||
/// Convert the text
|
||||
if (($fromenc != 'utf-8') && ($fromenc != 'UTF-8')) {
|
||||
$result = utfconvert($uic->name, $fromenc);
|
||||
|
||||
$newuic = new object;
|
||||
$newuic->id = $recordid;
|
||||
$newuic->name = $result;
|
||||
migrate2utf8_update_record('user_info_category',$newuic);
|
||||
}
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_user_info_data_data($recordid) {
|
||||
global $CFG, $globallang;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$uid = get_record('user_info_data', 'id', $recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
$user = get_record_sql("SELECT u.lang, u.lang
|
||||
FROM {$CFG->prefix}user u,
|
||||
{$CFG->prefix}user_info_data uid
|
||||
WHERE u.id = uid.userid
|
||||
AND uid.id = $recordid");
|
||||
|
||||
if ($globallang) {
|
||||
$fromenc = $globallang;
|
||||
} else {
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = null; //Non existing!
|
||||
$userlang = $user->lang; // Non existing
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
}
|
||||
|
||||
/// Initialise $result
|
||||
$result = $uid->data;
|
||||
|
||||
/// Convert the text
|
||||
if (($fromenc != 'utf-8') && ($fromenc != 'UTF-8')) {
|
||||
$result = utfconvert($uic->data, $fromenc);
|
||||
|
||||
$newuid = new object;
|
||||
$newuid->id = $recordid;
|
||||
$newuid->data = $result;
|
||||
migrate2utf8_update_record('user_info_data',$newuid);
|
||||
}
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_user_info_field_name($recordid) {
|
||||
global $CFG, $globallang;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$uif = get_record('user_info_field', 'id', $recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($globallang) {
|
||||
$fromenc = $globallang;
|
||||
} else {
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = null; //Non existing!
|
||||
$userlang = null; // Non existing
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
}
|
||||
|
||||
/// Initialise $result
|
||||
$result = $uif->name;
|
||||
|
||||
/// Convert the text
|
||||
if (($fromenc != 'utf-8') && ($fromenc != 'UTF-8')) {
|
||||
$result = utfconvert($uif->name, $fromenc);
|
||||
$newuif = new object;
|
||||
$newuif->id = $recordid;
|
||||
$newuif->name = $result;
|
||||
migrate2utf8_update_record('user_info_field',$newuif);
|
||||
}
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_user_info_field_defaultdata($recordid) {
|
||||
global $CFG, $globallang;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$uif = get_record('user_info_field', 'id', $recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($globallang) {
|
||||
$fromenc = $globallang;
|
||||
} else {
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = null; //Non existing!
|
||||
$userlang = null; // Non existing
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
}
|
||||
|
||||
/// Initialise $result
|
||||
$result = $uif->name;
|
||||
|
||||
/// Convert the text
|
||||
if (($fromenc != 'utf-8') && ($fromenc != 'UTF-8')) {
|
||||
$result = utfconvert($uif->defaultdata, $fromenc);
|
||||
$newuif = new object;
|
||||
$newuif->id = $recordid;
|
||||
$newuif->defaultdata = $result;
|
||||
migrate2utf8_update_record('user_info_field',$newuif);
|
||||
}
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_role_name($recordid){
|
||||
global $CFG, $globallang;
|
||||
@ -267,6 +425,44 @@ function migrate2utf8_role_name($recordid){
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_role_shortname($recordid){
|
||||
global $CFG, $globallang;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$role = get_record('role', 'id', $recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
if ($globallang) {
|
||||
$fromenc = $globallang;
|
||||
} else {
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = null; //Non existing!
|
||||
$userlang = null; // Non existing
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
}
|
||||
|
||||
/// Initialise $result
|
||||
$result = $role->name;
|
||||
|
||||
/// Convert the text
|
||||
if (($fromenc != 'utf-8') && ($fromenc != 'UTF-8')) {
|
||||
$result = utfconvert($role->shortname, $fromenc);
|
||||
|
||||
$newrole = new object;
|
||||
$newrole->id = $recordid;
|
||||
$newrole->shortname = $result;
|
||||
migrate2utf8_update_record('role',$newrole);
|
||||
}
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_role_description($recordid){
|
||||
global $CFG, $globallang;
|
||||
|
||||
|
@ -9,6 +9,39 @@
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="user_lastaccess" />
|
||||
<TABLE name="user_info_category">
|
||||
<FIELDS>
|
||||
<FIELD name="name" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_user_info_category_name(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="user_info_data">
|
||||
<FIELDS>
|
||||
<FIELD name="data" method="PHP_FUNCTION" type="longtext" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_user_info_data_data(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="user_info_field">
|
||||
<FIELDS>
|
||||
<FIELD name="name" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_user_info_field_name(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="datatype" method="NO_CONV" type="varchar" length="255" />
|
||||
<FIELD name="defaultdata" method="PHP_FUNCTION" type="longtext" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_user_info_field_defaultdata(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="role">
|
||||
<FIELDS>
|
||||
<FIELD name="name" method="PHP_FUNCTION" type="varchar" length="255">
|
||||
@ -16,6 +49,11 @@
|
||||
migrate2utf8_role_name(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="shortname" method="NO_CONV" type="varchar" length="100">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_role_shortname(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="description" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf8_role_description(RECORDID)
|
||||
@ -23,7 +61,6 @@
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
|
||||
<TABLE name="context" />
|
||||
<TABLE name="role_allow_assign" />
|
||||
<TABLE name="role_allow_override" />
|
||||
@ -31,8 +68,7 @@
|
||||
<FIELDS>
|
||||
<FIELD name="enrol" method="NO_CONV" type="varchar" length="20" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
|
||||
</TABLE>
|
||||
<TABLE name="role_capabilities">
|
||||
<FIELDS>
|
||||
<FIELD name="capability" method="NO_CONV" type="varchar" length="255" dropindex="roleid-contextid-capability" adduniqueindex ="roleid-contextid-capability(roleid, contextid, capability(255))" />
|
||||
@ -349,9 +385,21 @@
|
||||
<FIELD name="std_time" method="NO_CONV" type="varchar" length="5" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="stats_daily" />
|
||||
<TABLE name="stats_weekly" />
|
||||
<TABLE name="stats_monthly" />
|
||||
<TABLE name="stats_daily">
|
||||
<FIELDS>
|
||||
<FIELD name="stattype" method="NO_CONV" type="enum('enrolments', 'activity', 'logins')" default="activity" length="0" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="stats_weekly">
|
||||
<FIELDS>
|
||||
<FIELD name="stattype" method="NO_CONV" type="enum('enrolments', 'activity', 'logins')" default="activity" length="0" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="stats_monthly">
|
||||
<FIELDS>
|
||||
<FIELD name="stattype" method="NO_CONV" type="enum('enrolments', 'activity', 'logins')" default="activity" length="0" />
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="stats_user_daily">
|
||||
<FIELDS>
|
||||
<FIELD name="stattype" method="NO_CONV" type="varchar" length="30" />
|
||||
|
@ -405,6 +405,43 @@ function migrate2utf8_data_csstemplate($recordid){
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_data_jstemplate($recordid){
|
||||
global $CFG, $globallang;
|
||||
|
||||
/// Some trivial checks
|
||||
if (empty($recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$data = get_record('data','id',$recordid)) {
|
||||
log_the_problem_somewhere();
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($globallang) {
|
||||
$fromenc = $globallang;
|
||||
} else {
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($data->course); //Non existing!
|
||||
$userlang = get_main_teacher_lang($data->course); //N.E.!!
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
}
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
|
||||
/// Convert the text
|
||||
if (($fromenc != 'utf-8') && ($fromenc != 'UTF-8')) {
|
||||
$result = utfconvert($data->jstemplate, $fromenc);
|
||||
|
||||
$newdata= new object;
|
||||
$newdata->id = $recordid;
|
||||
$newdata->jstemplate = $result;
|
||||
migrate2utf8_update_record('data',$newdata);
|
||||
}
|
||||
/// And finally, just return the converted field
|
||||
return $result;
|
||||
}
|
||||
|
||||
function migrate2utf8_data_listtemplateheader($recordid){
|
||||
global $CFG, $globallang;
|
||||
|
@ -153,6 +153,11 @@
|
||||
migrate2utf_data_csstemplate(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="jstemplate" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf_data_csstemplate(RECORDID)
|
||||
</PHP_FUNCTION>
|
||||
</FIELD>
|
||||
<FIELD name="addtemplate" method="PHP_FUNCTION" type="text" length="0">
|
||||
<PHP_FUNCTION>
|
||||
migrate2utf_data_addtemplate(RECORDID)
|
||||
|
@ -104,5 +104,22 @@
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
<TABLE name="wiki_locks">
|
||||
<FIELD name="pagename" method="PLAIN_SQL_UPDATE" type="varchar" length="255">
|
||||
<SQL_DETECT_USER>
|
||||
SELECT wl.userid
|
||||
FROM {$CFG->prefix}wiki_locks wl
|
||||
WHERE wl.id=RECORDID
|
||||
</SQL_DETECT_USER>
|
||||
<SQL_DETECT_COURSE>
|
||||
SELECT w.course
|
||||
FROM {$CFG->prefix}wiki w,
|
||||
{$CFG->prefix}wiki_locks wl
|
||||
WHERE w.id = wl.wikiid
|
||||
AND wl.id = RECORDID
|
||||
</SQL_DETECT_COURSE>
|
||||
</FIELD>
|
||||
</FIELDS>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</DBMIGRATION>
|
||||
|
Loading…
x
Reference in New Issue
Block a user