Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

blocks: Making UTF8 migration script work with blocks not on course p…

…age, etc.

Author: Andrew Walbran <andrew.walbran@catalyst.net.nz>
  • Loading branch information...
commit 6488b3be2e0c275f24e2ea5b0510bf7e98906979 1 parent 748e20f
martinlanghoff authored
Showing with 24 additions and 18 deletions.
  1. +24 −18 blocks/db/migrate2utf8.php
View
42 blocks/db/migrate2utf8.php
@@ -15,8 +15,13 @@ function migrate2utf8_block_instance_configdata($recordid){
$fromenc = $globallang;
} else {
$sitelang = $CFG->lang;
- $courselang = get_course_lang($blockinstance->pageid); //Non existing!
- $userlang = get_main_teacher_lang($blockinstance->pageid); //N.E.!!
+ if ($blockinstance->pagetype == 'course-view') {
+ $courselang = get_course_lang($blockinstance->pageid); //Non existing!
+ $userlang = get_main_teacher_lang($blockinstance->pageid); //N.E.!!
+ } else {
+ $courselang = false;
+ $userlang = false;
+ }
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
}
@@ -42,8 +47,13 @@ function migrate2utf8_block_instance_configdata($recordid){
$fromenc = $globallang;
} else {
$sitelang = $CFG->lang;
- $courselang = get_course_lang($blockinstance->pageid); //Non existing!
- $userlang = get_main_teacher_lang($blockinstance->pageid); //N.E.!!
+ if ($blockinstance->pagetype == 'course-view') {
+ $courselang = get_course_lang($blockinstance->pageid); //Non existing!
+ $userlang = get_main_teacher_lang($blockinstance->pageid); //N.E.!!
+ } else {
+ $courselang = false;
+ $userlang = false;
+ }
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
}
@@ -68,8 +78,13 @@ function migrate2utf8_block_instance_configdata($recordid){
$fromenc = $globallang;
} else {
$sitelang = $CFG->lang;
- $courselang = get_course_lang($blockinstance->pageid); //Non existing!
- $userlang = get_main_teacher_lang($blockinstance->pageid); //N.E.!!
+ if ($blockinstance->pagetype == 'course-view') {
+ $courselang = get_course_lang($blockinstance->pageid); //Non existing!
+ $userlang = get_main_teacher_lang($blockinstance->pageid); //N.E.!!
+ } else {
+ $courselang = false;
+ $userlang = false;
+ }
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
}
@@ -110,10 +125,7 @@ function migrate2utf8_block_pinned_configdata($recordid){
$fromenc = $globallang;
} else {
$sitelang = $CFG->lang;
- $courselang = get_course_lang($blockpinned->pageid); //Non existing!
- $userlang = get_main_teacher_lang($blockpinned->pageid); //N.E.!!
-
- $fromenc = get_original_encoding($sitelang, $courselang, $userlang);
+ $fromenc = get_original_encoding($sitelang, false, false);
}
$blah = unserialize(base64_decode($blockpinned->configdata));
@@ -137,10 +149,7 @@ function migrate2utf8_block_pinned_configdata($recordid){
$fromenc = $globallang;
} else {
$sitelang = $CFG->lang;
- $courselang = get_course_lang($blockpinned->pageid); //Non existing!
- $userlang = get_main_teacher_lang($blockpinned->pageid); //N.E.!!
-
- $fromenc = get_original_encoding($sitelang, $courselang, $userlang);
+ $fromenc = get_original_encoding($sitelang, false, false);
}
$blah = unserialize(base64_decode($blockpinned->configdata));
@@ -163,10 +172,7 @@ function migrate2utf8_block_pinned_configdata($recordid){
$fromenc = $globallang;
} else {
$sitelang = $CFG->lang;
- $courselang = get_course_lang($blockpinned->pageid); //Non existing!
- $userlang = get_main_teacher_lang($blockpinned->pageid); //N.E.!!
-
- $fromenc = get_original_encoding($sitelang, $courselang, $userlang);
+ $fromenc = get_original_encoding($sitelang, false, false);
}
$blah = unserialize(base64_decode($blockpinned->configdata));
Please sign in to comment.
Something went wrong with that request. Please try again.