merged backup-restore/db migrate for rsstitletemplate field

This commit is contained in:
toyomoyo 2006-05-25 02:31:15 +00:00
parent 22a92ee224
commit 7dbc6b5891
4 changed files with 45 additions and 0 deletions

View File

@ -85,6 +85,7 @@ function data_backup_one_mod($bf,$preferences,$data) {
fwrite ($bf,full_tag("LISTTEMPLATE",4,false,$data->listtemplate));
fwrite ($bf,full_tag("ADDTEMPLATE",4,false,$data->addtemplate));
fwrite ($bf,full_tag("RSSTEMPLATE",4,false,$data->rsstemplate));
fwrite ($bf,full_tag("RSSTITLETEMPLATE",4,false,$data->rsstitletemplate));
fwrite ($bf,full_tag("LISTTEMPLATEHEADER",4,false,$data->listtemplateheader));
fwrite ($bf,full_tag("LISTTEMPLATEFOOTER",4,false,$data->listtemplatefooter));
fwrite ($bf,full_tag("APPROVAL",4,false,$data->approval));

View File

@ -328,6 +328,44 @@ function migrate2utf8_data_rsstemplate($recordid){
return $result;
}
function migrate2utf8_data_rsstitletemplate($recordid){
global $CFG, $globallang;
/// 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;
}
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);
}
/// We are going to use textlib facilities
/// Convert the text
if (($fromenc != 'utf-8') && ($fromenc != 'UTF-8')) {
$result = utfconvert($data->rsstitletemplate, $fromenc);
$newdata= new object;
$newdata->id = $recordid;
$newdata->rsstitletemplate = $result;
migrate2utf8_update_record('data',$newdata);
}
/// And finally, just return the converted field
return $result;
}
function migrate2utf8_data_csstemplate($recordid){
global $CFG, $globallang;

View File

@ -163,6 +163,11 @@
migrate2utf_data_rsstemplate(RECORDID)
</PHP_FUNCTION>
</FIELD>
<FIELD name="rsstitletemplate" method="PHP_FUNCTION" type="text" length="0">
<PHP_FUNCTION>
migrate2utf_data_rsstitletemplate(RECORDID)
</PHP_FUNCTION>
</FIELD>
<FIELD name="listtemplateheader" method="PHP_FUNCTION" type="text" length="0">
<PHP_FUNCTION>
migrate2utf_data_listtemplateheader(RECORDID)

View File

@ -70,6 +70,7 @@ function data_restore_mods($mod,$restore) {
$database->listtemplate = backup_todb($info['MOD']['#']['LISTTEMPLATE']['0']['#']);
$database->addtemplate = backup_todb($info['MOD']['#']['ADDTEMPLATE']['0']['#']);
$database->rsstemplate = backup_todb($info['MOD']['#']['RSSTEMPLATE']['0']['#']);
$database->rsstitletemplate = backup_todb($info['MOD']['#']['RSSTITLETEMPLATE']['0']['#']);
$database->listtemplateheader = backup_todb($info['MOD']['#']['LISTTEMPLATEHEADER']['0']['#']);
$database->listtemplatefooter = backup_todb($info['MOD']['#']['LISTTEMPLATEFOOTER']['0']['#']);
$database->approval = backup_todb($info['MOD']['#']['APPROVAL']['0']['#']);