1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
<?php // $Id: migrate2utf8.php,v 1.6 2006/03/10 03:43:31 patrickslee Exp $
function migrate2utf8_chat_name($recordid){
global $CFG, $globallang;
/// Some trivial checks
if (empty($recordid)) {
log_the_problem_somewhere();
return false;
}
if (!$chat = get_record('chat', 'id', $recordid)) {
log_the_problem_somewhere();
return false;
}
if ($globallang) {
$fromenc = $globallang;
} else {
$sitelang = $CFG->lang;
$courselang = get_course_lang($chat->course); //Non existing!
$userlang = get_main_teacher_lang($chat->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($chat->name, $fromenc);
$newchat = new object;
$newchat->id = $recordid;
$newchat->name = $result;
migrate2utf8_update_record('chat',$newchat);
}
/// And finally, just return the converted field
return $result;
}
function migrate2utf8_chat_intro($recordid){
global $CFG, $globallang;
/// Some trivial checks
if (empty($recordid)) {
log_the_problem_somewhere();
return false;
}
if (!$chat = get_record('chat', 'id', $recordid)) {
log_the_problem_somewhere();
return false;
}
if ($globallang) {
$fromenc = $globallang;
} else {
$sitelang = $CFG->lang;
$courselang = get_course_lang($chat->course); //Non existing!
$userlang = get_main_teacher_lang($chat->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($chat->intro, $fromenc);
$newchat = new object;
$newchat->id = $recordid;
$newchat->intro = $result;
migrate2utf8_update_record('chat',$newchat);
}
/// And finally, just return the converted field
return $result;
}
?>
|