]> git.mjollnir.org Git - moodle.git/commitdiff
merged backup-restore/db migrate for rsstitletemplate field
authortoyomoyo <toyomoyo>
Thu, 25 May 2006 02:31:15 +0000 (02:31 +0000)
committertoyomoyo <toyomoyo>
Thu, 25 May 2006 02:31:15 +0000 (02:31 +0000)
mod/data/backuplib.php
mod/data/db/migrate2utf8.php
mod/data/db/migrate2utf8.xml
mod/data/restorelib.php

index 280cd09fac3a70918f8765776101b0b3ebea7851..ab54da2f7a953ed190c729a288a14357e3be08c5 100644 (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));
index 5dde2c340105d90f98d27f1aedd6f00e1f04b195..6e277964a847a50c5ccd10a0d789b2ee02fadc51 100755 (executable)
@@ -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;
index fa48f5dd443c53c61cc37eb0365b5057729075f6..85bd0715b1b3958102f9b92b27daea19323e98e2 100755 (executable)
            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)
index 4251ad04e2c0d9fbfcaf813aabcdb25b66f7e84d..93def2de888e5fc5966512ec179d7abb4440dd6b 100644 (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']['#']);