registration MDL-24641 get language code from the full language list codes, not from...
authorjerome mouneyrac <jerome@moodle.com>
Wed, 13 Oct 2010 09:13:23 +0000 (09:13 +0000)
committerjerome mouneyrac <jerome@moodle.com>
Wed, 13 Oct 2010 09:13:23 +0000 (09:13 +0000)
admin/registration/forms.php
admin/registration/lib.php
admin/registration/register.php
lib/db/upgrade.php
version.php

index bf7b7b1..af5357a 100644 (file)
@@ -227,6 +227,10 @@ class site_registration_form extends moodleform {
         if ($country === false) {
             $country = $admin->country;
         }
+        $language = get_config('hub', 'site_language_' . $cleanhuburl);
+        if ($language === false) {
+            $language = current_language();
+        }
         $geolocation = get_config('hub', 'site_geolocation_' . $cleanhuburl);
         $contactable = get_config('hub', 'site_contactable_' . $cleanhuburl);
         $emailalert = get_config('hub', 'site_emailalert_' . $cleanhuburl);
@@ -277,10 +281,12 @@ class site_registration_form extends moodleform {
         $mform->addHelpButton('urlstring', 'siteurl', 'hub');
 
         $languages = get_string_manager()->get_list_of_languages();
-        $mform->addElement('static', 'langstring', get_string('sitelang', 'hub'), $languages[current_language()]);
-        $mform->addElement('hidden', 'language', current_language());
+        textlib_get_instance()->asort($languages);
+        $mform->addElement('select', 'language', get_string('sitelang', 'hub'),
+                $languages);
         $mform->setType('language', PARAM_ALPHANUMEXT);
-        $mform->addHelpButton('langstring', 'sitelang', 'hub');
+        $mform->addHelpButton('language', 'sitelang', 'hub');
+        $mform->setDefault('language', $language);
 
         $mform->addElement('static', 'versionstring', get_string('siteversion', 'hub'), $CFG->version);
         $mform->addElement('hidden', 'moodleversion', $CFG->version);
index b134038..8fc5dd2 100644 (file)
@@ -234,7 +234,7 @@ class registration_manager {
             $modulenumberaverage = average_number_of_courses_modules();
         }
         $siteinfo['modulenumberaverage'] = $modulenumberaverage;
-        $siteinfo['language'] = current_language();
+        $siteinfo['language'] = get_config('hub', 'site_language_' . $cleanhuburl);
         $siteinfo['moodleversion'] = $CFG->version;
         $siteinfo['moodlerelease'] = $CFG->release;
         $siteinfo['url'] = $CFG->wwwroot;
index 49d0351..a554ce8 100644 (file)
@@ -86,6 +86,7 @@ if (!empty($fromform) and confirm_sesskey()) {
     set_config('site_address_' . $cleanhuburl, $fromform->address, 'hub');
     set_config('site_region_' . $cleanhuburl, $fromform->regioncode, 'hub');
     set_config('site_country_' . $cleanhuburl, $fromform->countrycode, 'hub');
+    set_config('site_language_' . $cleanhuburl, $fromform->language, 'hub');
     set_config('site_geolocation_' . $cleanhuburl, $fromform->geolocation, 'hub');
     set_config('site_contactable_' . $cleanhuburl, $fromform->contactable, 'hub');
     set_config('site_emailalert_' . $cleanhuburl, $fromform->emailalert, 'hub');
index 3b7940a..f677480 100644 (file)
@@ -5280,6 +5280,20 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
         upgrade_main_savepoint(true, 2010092000);
     }
 
+    if ($oldversion < 2010101300) {
+        // Fix MDL-24641 : the registered language should not be empty otherwise cron will fail
+        $registeredhubs = $DB->get_records('registration_hubs', array('confirmed' => 1));
+        if (!empty($registeredhubs)) {
+            foreach ($registeredhubs as $hub) {
+                $cleanhuburl = clean_param($hub->huburl, PARAM_ALPHANUMEXT);
+                $sitelanguage = get_config('hub', 'site_language_' . $cleanhuburl);
+                if (empty($sitelanguage)) {
+                    set_config('site_language_' . $cleanhuburl, current_language(), 'hub');
+                }
+            }
+        }
+        upgrade_main_savepoint(true, 2010101300);
+    }
 
     return true;
 }
index 65d5290..a55a52a 100644 (file)
@@ -29,7 +29,7 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$version = 2010100900;  // YYYYMMDD   = date of the last version bump
+$version = 2010101300;  // YYYYMMDD   = date of the last version bump
                         //         XX = daily increments
 
 $release = '2.0 RC1 (Build: 20101013)';  // Human-friendly version name