From: skodak Date: Tue, 7 Nov 2006 09:07:40 +0000 (+0000) Subject: new unicode environment check for 1.8 and 1.7 MDL-6332; merged from MOODLE_17_STABLE X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=a392be33cfd60db302aced14c7e79dc4a8fc6b2b;p=moodle.git new unicode environment check for 1.8 and 1.7 MDL-6332; merged from MOODLE_17_STABLE --- diff --git a/admin/environment.xml b/admin/environment.xml index 161fbe73c6..24ce1e6678 100644 --- a/admin/environment.xml +++ b/admin/environment.xml @@ -35,6 +35,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lang/en_utf8/admin.php b/lang/en_utf8/admin.php index cf4cd00ea9..87d2845606 100644 --- a/lang/en_utf8/admin.php +++ b/lang/en_utf8/admin.php @@ -428,6 +428,8 @@ $string['timezoneisforcedto'] = 'Force all users to use'; $string['timezonenotforced'] = 'Users can choose their own timezone'; $string['unbookmarkthispage'] = 'unbookmark this page'; $string['unicodeupgradenotice'] = 'In Moodle 1.6 we have migrated all languages to Unicode. To complete the upgrade for this site, you need to convert all the data in your database to Unicode using our migration script. Click here to run the migration script now!'; +$string['unicoderecommended'] = 'UTF-8 database migration is recommended, new installations should be performed into unicode enabled databases'; +$string['unicoderequired'] = 'Unicode enabled database is required for installation or upgrade. Please make sure that database is properly migrated to unicode before upgrading to this version.'; $string['uninstall'] = 'Uninstall selected language pack'; $string['uninstallconfirm'] = 'You are about to completely uninstall language pack $a, are you sure?'; $string['unsupported'] = 'Unsupported'; diff --git a/lib/environmentlib.php b/lib/environmentlib.php index 515d4c56ed..28a8c096c4 100644 --- a/lib/environmentlib.php +++ b/lib/environmentlib.php @@ -46,6 +46,7 @@ define('NO_PHP_EXTENSIONS_SECTION_FOUND', 8); define('NO_PHP_EXTENSIONS_NAME_FOUND', 9); define('NO_DATABASE_VENDOR_VERSION_FOUND', 10); + define('NO_UNICODE_SECTION_FOUND', 11); /** * This function will perform the whole check, returning @@ -395,6 +396,7 @@ function environment_check($version) { $results = array(); //To store all the results + $results[] = environment_check_unicode($version); $results[] = environment_check_database($version); $results[] = environment_check_php($version); @@ -536,6 +538,59 @@ function environment_check_php($version) { } +/** + * This function will check if unicode database requirements are satisfied + * @param string $version xml version we are going to use to test this server + * @return object results encapsulated in one environment_result object + */ +function environment_check_unicode($version) { + global $db; + + $result = new environment_results('unicode'); + + /// Get the enviroment version we need + if (!$data = get_environment_for_version($version)) { + /// Error. No version data found + $result->setStatus(false); + $result->setErrorCode(NO_VERSION_DATA_FOUND); + return $result; + } + + /// Extract the unicode part + + if (!isset($data['#']['UNICODE'])) { + /// Error. No DATABASE section found + $result->setStatus(false); + $result->setErrorCode(NO_UNICODE_SECTION_FOUND); + return $result; + } else { + /// Extract level + if (isset($data['#']['UNICODE']['0']['@']['level'])) { + $level = $data['#']['UNICODE']['0']['@']['level']; + if ($level != 'optional') { + $level = 'required'; + } + } + } + + if (!$unicodedb = setup_is_unicodedb()) { + $result->setStatus(false); + } else { + $result->setStatus(true); + } + + $result->setLevel($level); + +/// Process messages, modifying the $result if needed. + process_environment_messages($data['#']['UNICODE'][0], $result); +/// Process bypass, modifying $result if needed. + process_environment_bypass($data['#']['UNICODE'][0], $result); +/// Process restrict, modifying $result if needed. + process_environment_restrict($data['#']['UNICODE'][0], $result); + + return $result; +} + /** * This function will check if database requirements are satisfied * @param string $version xml version we are going to use to test this server