<?php // $Id$
+function migrate2utf8_post_subject($recordid){
+ global $CFG, $globallang;
+
+/// Some trivial checks
+ if (empty($recordid)) {
+ log_the_problem_somewhere();
+ return false;
+ }
+
+ if (!$post = get_record('post', 'id', $recordid)) {
+ log_the_problem_somewhere();
+ return false;
+ }
+ if ($globallang) {
+ $fromenc = $globallang;
+ } else {
+ $sitelang = $CFG->lang;
+ $courselang = null; //Non existing!
+ if ($post->userid) {
+ $userlang = get_user_lang($post->userid);
+ }
+ $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($post->subject, $fromenc);
+
+ $newpost = new object;
+ $newpost->id = $recordid;
+ $newpost->subject = $result;
+ migrate2utf8_update_record('event',$newpost);
+ }
+/// And finally, just return the converted field
+ return $result;
+}
+
+function migrate2utf8_post_summary($recordid){
+ global $CFG, $globallang;
+
+/// Some trivial checks
+ if (empty($recordid)) {
+ log_the_problem_somewhere();
+ return false;
+ }
+
+ if (!$post = get_record('post', 'id', $recordid)) {
+ log_the_problem_somewhere();
+ return false;
+ }
+ if ($globallang) {
+ $fromenc = $globallang;
+ } else {
+ $sitelang = $CFG->lang;
+ $courselang = null; //Non existing!
+ if ($post->userid) {
+ $userlang = get_user_lang($post->userid);
+ }
+ $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($post->summary, $fromenc);
+
+ $newpost = new object;
+ $newpost->id = $recordid;
+ $newpost->summary = $result;
+ migrate2utf8_update_record('event',$newpost);
+ }
+/// And finally, just return the converted field
+ return $result;
+}
+
+function migrate2utf8_post_content($recordid){
+ global $CFG, $globallang;
+
+/// Some trivial checks
+ if (empty($recordid)) {
+ log_the_problem_somewhere();
+ return false;
+ }
+
+ if (!$post = get_record('post', 'id', $recordid)) {
+ log_the_problem_somewhere();
+ return false;
+ }
+ if ($globallang) {
+ $fromenc = $globallang;
+ } else {
+ $sitelang = $CFG->lang;
+ $courselang = null; //Non existing!
+ if ($post->userid) {
+ $userlang = get_user_lang($post->userid);
+ }
+ $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($post->content, $fromenc);
+
+ $newpost = new object;
+ $newpost->id = $recordid;
+ $newpost->content = $result;
+ migrate2utf8_update_record('event',$newpost);
+ }
+/// And finally, just return the converted field
+ return $result;
+}
+
+function migrate2utf8_tags_text($recordid){
+ global $CFG, $globallang;
+
+/// Some trivial checks
+ if (empty($recordid)) {
+ log_the_problem_somewhere();
+ return false;
+ }
+
+ if (!$tags = get_record('tags', 'id', $recordid)) {
+ log_the_problem_somewhere();
+ return false;
+ }
+ if ($globallang) {
+ $fromenc = $globallang;
+ } else {
+ $sitelang = $CFG->lang;
+ $courselang = null; //Non existing!
+ if ($tags->userid) {
+ $userlang = get_user_lang($tags->userid);
+ }
+ $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($tags->text, $fromenc);
+
+ $newtags = new object;
+ $newtags->id = $recordid;
+ $newtags->text = $result;
+ migrate2utf8_update_record('tags',$newtags);
+ }
+/// And finally, just return the converted field
+ return $result;
+}
function migrate2utf8_event_name($recordid){
global $CFG, $globallang;
<DBMIGRATION type="lib" VERSION="2005120100">
<TABLES>
+ <TABLE name="blog_tag_instance" />
+ <TABLE name="post">
+ <FIELDS>
+ <FIELD name="module" method="NO_CONV" type="varchar" length="20" dropindex="post_module_idx" addindex="post_module_idx(module(20))"/>
+ <FIELD name="subject" method="PHP_FUNCTION" type="varchar" length="128" dropindex="post_subject_idx" addindex=" post_subject_idx(subject(128))">
+ <PHP_FUNCTION>
+ migrate2utf8_post_subject(RECORDID)
+ </PHP_FUNCTION>
+ </FIELD>
+ <FIELD name="summary" method="PHP_FUNCTION" type="longtext" length="0">
+ <PHP_FUNCTION>
+ migrate2utf8_post_summary(RECORDID)
+ </PHP_FUNCTION>
+ </FIELD>
+ <FIELD name="content" method="PHP_FUNCTION" type="longtext" length="0">
+ <PHP_FUNCTION>
+ migrate2utf8_post_content(RECORDID)
+ </PHP_FUNCTION>
+ </FIELD>
+ <FIELD name="uniquehash" method="NO_CONV" type="varchar" length="128" />
+ <FIELD name="publishstate" method="NO_CONV" type="enum('draft', 'site', 'public')" length="0" default="draft" />
+ </FIELDS>
+ </TABLE>
+ <TABLE name="tags">
+ <FIELDS>
+ <FIELD name="type" method="NO_CONV" type="varchar" length="255" />
+ <FIELD name="text" method="PHP_FUNCTION" type="varchar" length="255">
+ <PHP_FUNCTION>
+ migrate2utf8_tags_text(RECORDID)
+ </PHP_FUNCTION>
+ </FIELD>
+ </FIELDS>
+ </TABLE>
<TABLE name="config">
<FIELDS>
<FIELD name="name" method="NO_CONV" type="varchar" length="255" dropindex="name" adduniqueindex="name (name(255))"/>