Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

backup-restore, utfmigrate for rsstitletemplate field

  • Loading branch information...
commit f6c74641dd76f59b656537ebb321e151f76e246d 1 parent 3141843
toyomoyo authored
1  mod/data/backuplib.php
View
@@ -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));
38 mod/data/db/migrate2utf8.php
View
@@ -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;
5 mod/data/db/migrate2utf8.xml
View
@@ -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)
1  mod/data/restorelib.php
View
@@ -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']['#']);
Please sign in to comment.
Something went wrong with that request. Please try again.