2006-03-07 21:35:13 +00:00
|
|
|
<?php // $Id$
|
2006-01-09 06:06:49 +00:00
|
|
|
function migrate2utf8_assignment_name($recordid){
|
2006-02-24 08:20:13 +00:00
|
|
|
global $CFG, $globallang;
|
2006-01-09 06:06:49 +00:00
|
|
|
|
|
|
|
/// Some trivial checks
|
|
|
|
if (empty($recordid)) {
|
|
|
|
log_the_problem_somewhere();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!$assignment = get_record('assignment', 'id', $recordid)) {
|
|
|
|
log_the_problem_somewhere();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-02-24 08:20:13 +00:00
|
|
|
if ($globallang) {
|
|
|
|
$fromenc = $globallang;
|
|
|
|
} else {
|
|
|
|
$sitelang = $CFG->lang;
|
|
|
|
$courselang = get_course_lang($assignment->course); //Non existing!
|
|
|
|
$userlang = get_main_teacher_lang($assignment->course); //N.E.!!
|
2006-01-09 06:06:49 +00:00
|
|
|
|
2006-02-24 08:20:13 +00:00
|
|
|
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
|
|
|
}
|
2006-01-09 06:06:49 +00:00
|
|
|
/// We are going to use textlib facilities
|
2006-01-31 02:15:21 +00:00
|
|
|
|
2006-01-09 06:06:49 +00:00
|
|
|
/// Convert the text
|
2006-02-24 08:20:13 +00:00
|
|
|
if (($fromenc != 'utf-8') && ($fromenc != 'UTF-8')) {
|
|
|
|
$result = utfconvert($assignment->name, $fromenc);
|
|
|
|
|
|
|
|
$newassignment = new object;
|
|
|
|
$newassignment->id = $recordid;
|
|
|
|
$newassignment->name = $result;
|
2006-03-10 03:43:33 +00:00
|
|
|
migrate2utf8_update_record('assignment',$newassignment);
|
2006-02-24 08:20:13 +00:00
|
|
|
}
|
2006-01-09 06:06:49 +00:00
|
|
|
/// And finally, just return the converted field
|
2006-01-16 07:57:56 +00:00
|
|
|
|
2006-01-09 06:06:49 +00:00
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
function migrate2utf8_assignment_description($recordid){
|
2006-02-24 08:20:13 +00:00
|
|
|
global $CFG, $globallang;
|
2006-01-09 06:06:49 +00:00
|
|
|
|
|
|
|
/// Some trivial checks
|
|
|
|
if (empty($recordid)) {
|
|
|
|
log_the_problem_somewhere();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!$assignment = get_record('assignment', 'id', $recordid)) {
|
|
|
|
log_the_problem_somewhere();
|
|
|
|
return false;
|
|
|
|
}
|
2006-02-24 08:20:13 +00:00
|
|
|
if ($globallang) {
|
|
|
|
$fromenc = $globallang;
|
|
|
|
} else {
|
|
|
|
$sitelang = $CFG->lang;
|
|
|
|
$courselang = get_course_lang($assignment->course); //Non existing!
|
|
|
|
$userlang = get_main_teacher_lang($assignment->course); //N.E.!!
|
2006-01-09 06:06:49 +00:00
|
|
|
|
2006-02-24 08:20:13 +00:00
|
|
|
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
|
|
|
}
|
2006-01-09 06:06:49 +00:00
|
|
|
|
|
|
|
/// We are going to use textlib facilities
|
2006-01-31 02:15:21 +00:00
|
|
|
|
2006-01-09 06:06:49 +00:00
|
|
|
/// Convert the text
|
2006-02-24 08:20:13 +00:00
|
|
|
if (($fromenc != 'utf-8') && ($fromenc != 'UTF-8')) {
|
|
|
|
$result = utfconvert($assignment->description, $fromenc);
|
2006-01-09 06:06:49 +00:00
|
|
|
|
2006-02-24 08:20:13 +00:00
|
|
|
$newassignment = new object;
|
|
|
|
$newassignment->id = $recordid;
|
|
|
|
$newassignment->description = $result;
|
2006-03-10 03:43:33 +00:00
|
|
|
migrate2utf8_update_record('assignment',$newassignment);
|
2006-02-24 08:20:13 +00:00
|
|
|
}
|
2006-01-09 06:06:49 +00:00
|
|
|
/// And finally, just return the converted field
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|