mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
41 lines
1 KiB
PHP
Executable file
41 lines
1 KiB
PHP
Executable file
<?php // $Id$
|
|
|
|
function migrate2utf8_backup_ids_info($recordid){
|
|
global $CFG, $globallang;
|
|
|
|
/// Some trivial checks
|
|
if (empty($recordid)) {
|
|
log_the_problem_somewhere();
|
|
return false;
|
|
}
|
|
|
|
if (!$backupids= get_record('backup_ids', 'id', $recordid)) {
|
|
log_the_problem_somewhere();
|
|
return false;
|
|
}
|
|
|
|
if ($globallang) {
|
|
$fromenc = $globallang;
|
|
} else {
|
|
$sitelang = $CFG->lang;
|
|
$courselang = null;
|
|
$userlang = null; //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($backupids->info, $fromenc);
|
|
|
|
$newbackupids = new object;
|
|
$newbackupids->id = $recordid;
|
|
$newbackupids->info = $result;
|
|
migrate2utf8_update_record('backup_ids',$newbackupids);
|
|
}
|
|
/// And finally, just return the converted field
|
|
return $result;
|
|
}
|
|
?>
|