function migrate2utf8_netpublish_name($recordid) { global $CFG, $globallang; /// Some trivial checks if (empty($recordid)) { log_the_problem_somewhere(); return false; } if (!($netpublish = get_record('netpublish', 'id', $recordid))) { log_the_problem_somewhere(); return false; } if ($globallang) { $fromenc = $globallang; } else { $sitelang = $CFG->lang; $courselang = get_course_lang($netpublish->course); //Non existing! $userlang = get_main_teacher_lang($netpublish->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($netpublish->name, $fromenc); $newpublish = new object(); $newpublish->id = $recordid; $newpublish->name = $result; migrate2utf8_update_record('netpublish', $newpublish); } /// And finally, just return the converted field return $result; }
function migrate2utf8_questionnaire_response_other_response($recordid) { global $CFG, $globallang; /// Some trivial checks if (empty($recordid)) { log_the_problem_somewhere(); return false; } if (!($rother = get_record('questionnaire_response_other', 'id', $recordid))) { log_the_problem_somewhere(); return false; } if (!($courseid = get_field('questionnaire_survey', 'owner', 'id', get_field('questionnaire_question', 'survey_id', 'id', $rother->question_id)))) { log_the_problem_somewhere(); return false; } if ($globallang) { $fromenc = $globallang; } else { $sitelang = $CFG->lang; $courselang = get_course_lang($courseid); //Non existing! $userid = get_field('questionnaire_response', 'username', 'id', $rother->response_id); if (is_numeric($userid)) { $userlang = get_user_lang($userid); } else { $userlang = false; } $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($rother->response, $fromenc); $newrother = new object(); $newrother->id = $recordid; $newrother->response = $result; migrate2utf8_update_record('questionnaire_response_other', $newrother); } /// And finally, just return the converted field return $result; }
function migrate2utf8_wiki_votes_username($recordid) { global $CFG, $globallang; /// Some trivial checks if (empty($recordid)) { log_the_problem_somewhere(); return false; } $SQL = "SELECT w.course\n FROM {$CFG->prefix}wiki w,\n {$CFG->prefix}wiki_votes ws\n WHERE w.id = ws.dfwiki\n AND ws.id = {$recordid}"; if (!($wiki = get_record_sql($SQL))) { log_the_problem_somewhere(); return false; } if (!($wikivotes = get_record('wiki_votes', 'id', $recordid))) { log_the_problem_somewhere(); return false; } if ($globallang) { $fromenc = $globallang; } else { $sitelang = $CFG->lang; $courselang = get_course_lang($wiki->course); //Non existing! $userlang = get_main_teacher_lang($wiki->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($wikivotes->username, $fromenc); $newwikiwikivotes = new object(); $newwikiwikivotes->id = $recordid; $newwikiwikivotes->username = $result; migrate2utf8_update_record('wiki_votes', $newwikiwikivotes); } /// And finally, just return the converted field return $result; }