Index: moodlelib.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/moodlelib.php,v retrieving revision 1.960.2.24 diff -c -r1.960.2.24 moodlelib.php *** moodlelib.php 1 Jan 2008 17:21:54 -0000 1.960.2.24 --- moodlelib.php 19 Jan 2008 23:02:07 -0000 *************** *** 5333,5352 **** /** * Returns a list of country names in the current language * * @uses $CFG * @uses $USER * @return array */ ! function get_list_of_countries() { global $CFG, $USER; $lang = current_language(); ! if (!file_exists($CFG->dirroot .'/lang/'. $lang .'/countries.php') && ! !file_exists($CFG->dataroot.'/lang/'. $lang .'/countries.php')) { if ($parentlang = get_string('parentlanguage')) { ! if (file_exists($CFG->dirroot .'/lang/'. $parentlang .'/countries.php') || ! file_exists($CFG->dataroot.'/lang/'. $parentlang .'/countries.php')) { $lang = $parentlang; } else { $lang = 'en_utf8'; // countries.php must exist in this pack --- 5333,5359 ---- /** * Returns a list of country names in the current language * + * There are three possible locations of the list to use: 1) current language, 2) parent language, 3) en_utf8. + * The function uses an attempt counter to pick the lang pack containing the list. Please note, + * simple checking of the countries.php existence is not enough as the file might be empty (MDL-12465). + * + * @param int $attempt The first (default), second or third attempt to get the list * @uses $CFG * @uses $USER * @return array */ ! function get_list_of_countries($attempt=1) { global $CFG, $USER; $lang = current_language(); ! if ($attempt > 1 || ! (!file_exists($CFG->dirroot .'/lang/'. $lang .'/countries.php') && ! !file_exists($CFG->dataroot.'/lang/'. $lang .'/countries.php'))) { if ($parentlang = get_string('parentlanguage')) { ! if (($attempt == 2) && ! (file_exists($CFG->dirroot .'/lang/'. $parentlang .'/countries.php') || ! file_exists($CFG->dataroot.'/lang/'. $parentlang .'/countries.php'))) { $lang = $parentlang; } else { $lang = 'en_utf8'; // countries.php must exist in this pack *************** *** 5364,5369 **** --- 5371,5378 ---- if (!empty($string)) { asort($string); + } else if ($attempt < 3) { + return get_list_of_countries($attempt+1); } return $string;