2006-01-09 06:06:49 +00:00
|
|
|
<?
|
|
|
|
function migrate2utf8_data_fields_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;
|
|
|
|
}
|
|
|
|
|
|
|
|
$SQL = "SELECT d.course
|
|
|
|
FROM {$CFG->prefix}data_fields df,
|
|
|
|
{$CFG->prefix}data d
|
|
|
|
WHERE d.id = df.dataid
|
|
|
|
AND df.id = $recordid";
|
|
|
|
|
|
|
|
if (!$data = get_record_sql($SQL)) {
|
|
|
|
log_the_problem_somewhere();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$datafield = get_record('data_fields','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($data->course); //Non existing!
|
|
|
|
$userlang = get_main_teacher_lang($data->course); //N.E.!!
|
|
|
|
|
|
|
|
$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($datafield->name, $fromenc);
|
2006-01-09 06:06:49 +00:00
|
|
|
|
2006-02-24 08:20:13 +00:00
|
|
|
$newdatafield = new object;
|
|
|
|
$newdatafield->id = $recordid;
|
|
|
|
$newdatafield->name = $result;
|
|
|
|
update_record('data_fields',$newdatafield);
|
|
|
|
}
|
2006-01-09 06:06:49 +00:00
|
|
|
/// And finally, just return the converted field
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
function migrate2utf8_data_fields_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;
|
|
|
|
}
|
|
|
|
|
|
|
|
$SQL = "SELECT d.course
|
|
|
|
FROM {$CFG->prefix}data_fields df,
|
|
|
|
{$CFG->prefix}data d
|
|
|
|
WHERE d.id = df.dataid
|
|
|
|
AND df.id = $recordid";
|
|
|
|
|
|
|
|
if (!$data = get_record_sql($SQL)) {
|
|
|
|
log_the_problem_somewhere();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$datafield = get_record('data_fields','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($data->course); //Non existing!
|
|
|
|
$userlang = get_main_teacher_lang($data->course); //N.E.!!
|
|
|
|
|
|
|
|
$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($datafield->description, $fromenc);
|
2006-01-09 06:06:49 +00:00
|
|
|
|
2006-02-24 08:20:13 +00:00
|
|
|
$newdatafield = new object;
|
|
|
|
$newdatafield->id = $recordid;
|
|
|
|
$newdatafield->description = $result;
|
|
|
|
update_record('data_fields',$newdatafield);
|
|
|
|
}
|
2006-01-09 06:06:49 +00:00
|
|
|
/// And finally, just return the converted field
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
function migrate2utf8_data_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 (!$data = get_record('data','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($data->course); //Non existing!
|
|
|
|
$userlang = get_main_teacher_lang($data->course); //N.E.!!
|
|
|
|
|
|
|
|
$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($data->name, $fromenc);
|
2006-01-09 06:06:49 +00:00
|
|
|
|
2006-02-24 08:20:13 +00:00
|
|
|
$newdata= new object;
|
|
|
|
$newdata->id = $recordid;
|
|
|
|
$newdata->name = $result;
|
|
|
|
update_record('data',$newdata);
|
|
|
|
}
|
2006-01-09 06:06:49 +00:00
|
|
|
/// And finally, just return the converted field
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
function migrate2utf8_data_intro($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 (!$data = get_record('data','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($data->course); //Non existing!
|
|
|
|
$userlang = get_main_teacher_lang($data->course); //N.E.!!
|
|
|
|
|
|
|
|
$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($data->intro, $fromenc);
|
2006-01-09 06:06:49 +00:00
|
|
|
|
2006-02-24 08:20:13 +00:00
|
|
|
$newdata= new object;
|
|
|
|
$newdata->id = $recordid;
|
|
|
|
$newdata->intro = $result;
|
|
|
|
update_record('data',$newdata);
|
|
|
|
}
|
2006-01-09 06:06:49 +00:00
|
|
|
/// And finally, just return the converted field
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
function migrate2utf8_data_singletemplate($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 (!$data = get_record('data','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($data->course); //Non existing!
|
|
|
|
$userlang = get_main_teacher_lang($data->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($data->singletemplate, $fromenc);
|
2006-01-09 06:06:49 +00:00
|
|
|
|
2006-02-24 08:20:13 +00:00
|
|
|
$newdata= new object;
|
|
|
|
$newdata->id = $recordid;
|
|
|
|
$newdata->singletemplate = $result;
|
|
|
|
update_record('data',$newdata);
|
|
|
|
}
|
2006-01-09 06:06:49 +00:00
|
|
|
/// And finally, just return the converted field
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
function migrate2utf8_data_listtemplate($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 (!$data = get_record('data','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($data->course); //Non existing!
|
|
|
|
$userlang = get_main_teacher_lang($data->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($data->listtemplate, $fromenc);
|
2006-01-09 06:06:49 +00:00
|
|
|
|
2006-02-24 08:20:13 +00:00
|
|
|
$newdata= new object;
|
|
|
|
$newdata->id = $recordid;
|
|
|
|
$newdata->listtemplate = $result;
|
|
|
|
update_record('data',$newdata);
|
|
|
|
}
|
2006-01-09 06:06:49 +00:00
|
|
|
/// And finally, just return the converted field
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
function migrate2utf8_data_addtemplate($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 (!$data = get_record('data','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($data->course); //Non existing!
|
|
|
|
$userlang = get_main_teacher_lang($data->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($data->addtemplate, $fromenc);
|
2006-01-09 06:06:49 +00:00
|
|
|
|
2006-02-24 08:20:13 +00:00
|
|
|
$newdata= new object;
|
|
|
|
$newdata->id = $recordid;
|
|
|
|
$newdata->addtemplate = $result;
|
|
|
|
update_record('data',$newdata);
|
|
|
|
}
|
2006-01-09 06:06:49 +00:00
|
|
|
/// And finally, just return the converted field
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
function migrate2utf8_data_rsstemplate($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 (!$data = get_record('data','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($data->course); //Non existing!
|
|
|
|
$userlang = get_main_teacher_lang($data->course); //N.E.!!
|
|
|
|
$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($data->rsstemplate, $fromenc);
|
2006-01-09 06:06:49 +00:00
|
|
|
|
2006-02-24 08:20:13 +00:00
|
|
|
$newdata= new object;
|
|
|
|
$newdata->id = $recordid;
|
|
|
|
$newdata->rsstemplate = $result;
|
|
|
|
update_record('data',$newdata);
|
|
|
|
}
|
2006-01-09 06:06:49 +00:00
|
|
|
/// And finally, just return the converted field
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
function migrate2utf8_data_listtemplateheader($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 (!$data = get_record('data','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($data->course); //Non existing!
|
|
|
|
$userlang = get_main_teacher_lang($data->course); //N.E.!!
|
|
|
|
$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-02-24 08:20:13 +00:00
|
|
|
if (($fromenc != 'utf-8') && ($fromenc != 'UTF-8')) {
|
|
|
|
$result = utfconvert($data->listtemplateheader, $fromenc);
|
2006-01-09 06:06:49 +00:00
|
|
|
|
2006-02-24 08:20:13 +00:00
|
|
|
$newdata= new object;
|
|
|
|
$newdata->id = $recordid;
|
|
|
|
$newdata->listtemplateheader = $result;
|
|
|
|
update_record('data',$newdata);
|
|
|
|
}
|
2006-01-09 06:06:49 +00:00
|
|
|
/// And finally, just return the converted field
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
function migrate2utf8_data_listtemplatefooter($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 (!$data = get_record('data','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($data->course); //Non existing!
|
|
|
|
$userlang = get_main_teacher_lang($data->course); //N.E.!!
|
|
|
|
$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($data->listtemplatefooter, $fromenc);
|
2006-01-09 06:06:49 +00:00
|
|
|
|
2006-02-24 08:20:13 +00:00
|
|
|
$newdata= new object;
|
|
|
|
$newdata->id = $recordid;
|
|
|
|
$newdata->listtemplatefooter = $result;
|
|
|
|
update_record('data',$newdata);
|
|
|
|
}
|
2006-01-09 06:06:49 +00:00
|
|
|
/// And finally, just return the converted field
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|