Skip to content
Browse files

bug fixes

  • Loading branch information...
1 parent 43b48b8 commit 0c25b4534e9bcb892ff7cf3d33d075194d76bf4b moodler committed Jan 23, 2006
Showing with 55 additions and 16 deletions.
  1. +2 −1 lib/db/migrate2utf8.php
  2. +45 −11 mod/hotpot/db/migrate2utf8.php
  3. +8 −4 mod/hotpot/db/migrate2utf8.xml
View
3 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;
}
View
56 mod/hotpot/db/migrate2utf8.php
@@ -1,5 +1,39 @@
<?
-function migrate2utf_hotpot_questions_name($recordid){
+
+function migrate2utf8_hotpot_strings_string($recordid){
+ global $CFG;
+
+/// Some trivial checks
+ if (empty($recordid)) {
+ log_the_problem_somewhere();
+ return false;
+ }
+
+ if (!$hotpotstrings = get_record('hotpot_strings','id',$recordid)) {
+ log_the_problem_somewhere();
+ return false;
+ }
+
+ $sitelang = $CFG->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,15 +118,15 @@ 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;
}
$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;
}
View
12 mod/hotpot/db/migrate2utf8.xml
@@ -3,7 +3,11 @@
<TABLE name="hotpot_attempts" />
<TABLE name="hotpot_strings">
<FIELDS>
- <FIELD name="string" method="NO_CONV" type="TEXT" length="0" />
+ <FIELD name="string" method="PHP_FUNCTION" type="TEXT" length="0">
+ <PHP_FUNCTION>
+ migrate2utf8_hotpot_strings_string(RECORDID)
+ </PHP_FUNCTION>
+ </FIELD>
</FIELDS>
</TABLE>
<TABLE name="hotpot_responses">
@@ -46,18 +50,18 @@
</TABLE>
<TABLE name="hotpot">
<FIELDS>
- <FIELD name="name" method="PLAIN_SQL_UPDATE" type="varchar" length="255">
+ <FIELD name="name" method="PHP_FUNCTION" type="varchar" length="255">
<PHP_FUNCTION>
migrate2utf8_hotpot_name(RECORDID)
</PHP_FUNCTION>
</FIELD>
<FIELD name="reference" method="NO_CONV" type="varchar" length="255" />
- <FIELD name="summary" method="PLAIN_SQL_UPDATE" type="text" length="0">
+ <FIELD name="summary" method="PHP_FUNCTION" type="text" length="0">
<PHP_FUNCTION>
migrate2utf8_hotpot_summary(RECORDID)
</PHP_FUNCTION>
</FIELD>
- <FIELD name="password" method="PLAIN_SQL_UPDATE" type="varchar" length="255">
+ <FIELD name="password" method="PHP_FUNCTION" type="varchar" length="255">
<PHP_FUNCTION>
migrate2utf8_hotpot_password(RECORDID)
</PHP_FUNCTION>

0 comments on commit 0c25b45

Please sign in to comment.
Something went wrong with that request. Please try again.