From 0c25b4534e9bcb892ff7cf3d33d075194d76bf4b Mon Sep 17 00:00:00 2001 From: moodler Date: Mon, 23 Jan 2006 03:15:45 +0000 Subject: [PATCH] bug fixes --- lib/db/migrate2utf8.php | 3 +- mod/hotpot/db/migrate2utf8.php | 56 +++++++++++++++++++++++++++------- mod/hotpot/db/migrate2utf8.xml | 12 +++++--- 3 files changed, 55 insertions(+), 16 deletions(-) diff --git a/lib/db/migrate2utf8.php b/lib/db/migrate2utf8.php index 86889f026a1..f35b707e9c5 100755 --- a/lib/db/migrate2utf8.php +++ b/lib/db/migrate2utf8.php @@ -1290,11 +1290,12 @@ function migrate2utf8_course_lang($recordid){ return false; } - if (strstr($course->lang,'utf8')===false){ + if (strstr($course->lang,'utf8')===false and !empty($course->lang)){ $course->lang = $course->lang.'_utf8'; } update_record('course',$course); + rebuild_course_cache($recordid); //takes care of serialized modinfo /// And finally, just return the converted field return $result; } diff --git a/mod/hotpot/db/migrate2utf8.php b/mod/hotpot/db/migrate2utf8.php index 84e513269ef..c4173663024 100755 --- a/mod/hotpot/db/migrate2utf8.php +++ b/mod/hotpot/db/migrate2utf8.php @@ -1,5 +1,39 @@ lang; + $courselang = null; //Non existing! + $userlang = null; //N.E.!! + + $fromenc = get_original_encoding($sitelang, $courselang, $userlang); + +/// We are going to use textlib facilities + $textlib = textlib_get_instance(); +/// Convert the text + $result = $textlib->convert($hotpotstrings->string, $fromenc); + + $newhotpotstrings = new object; + $newhotpotstrings->id = $recordid; + $newhotpotstrings->string = $result; + update_record('hotpot_strings',$newhotpotstrings); +/// And finally, just return the converted field + return $result; +} + +function migrate2utf8_hotpot_questions_name($recordid){ global $CFG; /// Some trivial checks @@ -13,12 +47,12 @@ function migrate2utf_hotpot_questions_name($recordid){ WHERE h.id = hq.hotpot AND hq.id = $recordid"; - if (!$hotpot = get_record_sql($SQL) { + if (!$hotpot = get_record_sql($SQL)) { log_the_problem_somewhere(); return false; } - if (!$hotpotquestion = get_record_sql('hotpot_questions','id',$recordid) { + if (!$hotpotquestion = get_record('hotpot_questions','id',$recordid)) { log_the_problem_somewhere(); return false; } @@ -28,7 +62,7 @@ function migrate2utf_hotpot_questions_name($recordid){ $userlang = get_main_teacher_lang($hotpot->course); //N.E.!! $fromenc = get_original_encoding($sitelang, $courselang, $userlang); - + /// We are going to use textlib facilities $textlib = textlib_get_instance(); /// Convert the text @@ -42,7 +76,7 @@ function migrate2utf_hotpot_questions_name($recordid){ return $result; } -function migrate2utf_hotpot_name($recordid){ +function migrate2utf8_hotpot_name($recordid){ global $CFG; /// Some trivial checks @@ -51,7 +85,7 @@ function migrate2utf_hotpot_name($recordid){ return false; } - if (!$hotpot = get_record('hotpot','id',$recordid) { + if (!$hotpot = get_record('hotpot','id',$recordid)) { log_the_problem_somewhere(); return false; } @@ -75,7 +109,7 @@ function migrate2utf_hotpot_name($recordid){ return $result; } -function migrate2utf_hotpot_summary($recordid){ +function migrate2utf8_hotpot_summary($recordid){ global $CFG; /// Some trivial checks @@ -84,7 +118,7 @@ function migrate2utf_hotpot_summary($recordid){ return false; } - if (!$hotpot = get_record('hotpot','id',$recordid) { + if (!$hotpot = get_record('hotpot','id',$recordid)) { log_the_problem_somewhere(); return false; } @@ -92,7 +126,7 @@ function migrate2utf_hotpot_summary($recordid){ $sitelang = $CFG->lang; $courselang = get_course_lang($hotpot->course); //Non existing! $userlang = get_main_teacher_lang($hotpot->course); //N.E.!! - + $fromenc = get_original_encoding($sitelang, $courselang, $userlang); /// We are going to use textlib facilities @@ -108,7 +142,7 @@ function migrate2utf_hotpot_summary($recordid){ return $result; } -function migrate2utf_hotpot_password($recordid){ +function migrate2utf8_hotpot_password($recordid){ global $CFG; /// Some trivial checks @@ -117,7 +151,7 @@ function migrate2utf_hotpot_password($recordid){ return false; } - if (!$hotpot = get_record('hotpot','id',$recordid) { + if (!$hotpot = get_record('hotpot','id',$recordid)) { log_the_problem_somewhere(); return false; } diff --git a/mod/hotpot/db/migrate2utf8.xml b/mod/hotpot/db/migrate2utf8.xml index e9629b2d7ad..33d847d8c85 100755 --- a/mod/hotpot/db/migrate2utf8.xml +++ b/mod/hotpot/db/migrate2utf8.xml @@ -3,7 +3,11 @@
- + + + migrate2utf8_hotpot_strings_string(RECORDID) + +
@@ -46,18 +50,18 @@
- + migrate2utf8_hotpot_name(RECORDID) - + migrate2utf8_hotpot_summary(RECORDID) - + migrate2utf8_hotpot_password(RECORDID)