diff --git a/admin/settings/server.php b/admin/settings/server.php
index 7f6647fec2e..807bf75f8e9 100644
--- a/admin/settings/server.php
+++ b/admin/settings/server.php
@@ -227,6 +227,8 @@ $ADMIN->add('server', new admin_externalpage('phpinfo', get_string('phpinfo'), "
// "performance" settingpage
$temp = new admin_settingpage('performance', get_string('performance', 'admin'));
+$temp->add(new admin_setting_configtext('numcoursesincombo', get_string('numcoursesincombo', 'admin'), get_string('numcoursesincombo_help', 'admin'), 500));
+
$temp->add(new admin_setting_configselect('extramemorylimit', get_string('extramemorylimit', 'admin'),
get_string('configextramemorylimit', 'admin'), '512M',
// if this option is set to 0, default 128M will be used
diff --git a/index.php b/index.php
index 8aa5b3a3e15..7c3472d464b 100644
--- a/index.php
+++ b/index.php
@@ -206,7 +206,19 @@
echo html_writer::tag('a', get_string('skipa', 'access', moodle_strtolower(get_string('courses'))), array('href'=>'#skipcourses', 'class'=>'skip-block'));
echo $OUTPUT->heading(get_string('courses'), 2, 'headingblock header');
$renderer = $PAGE->get_renderer('core','course');
- echo $renderer->course_category_tree(get_course_category_tree());
+ // if there are too many courses, budiling course category tree could be slow,
+ // users should go to course index page to see the whole list.
+ $coursecount = $DB->count_records('course');
+ if (empty($CFG->numcoursesincombo)) {
+ // if $CFG->numcoursesincombo hasn't been set, use default value 500
+ $CFG->numcoursesincombo = 500;
+ }
+ if ($coursecount > $CFG->numcoursesincombo) {
+ $link = new moodle_url('/course/');
+ echo $OUTPUT->notification(get_string('maxnumcoursesincombo', 'moodle', array('link'=>$link->out(), 'maxnumofcourses'=>$CFG->numcoursesincombo, 'numberofcourses'=>$coursecount)));
+ } else {
+ echo $renderer->course_category_tree(get_course_category_tree());
+ }
print_course_search('', false, 'short');
echo html_writer::tag('span', '', array('class'=>'skip-block-to', 'id'=>'skipcourses'));
break;
diff --git a/lang/en/admin.php b/lang/en/admin.php
index 178c85c3d24..915cb7a9bfd 100644
--- a/lang/en/admin.php
+++ b/lang/en/admin.php
@@ -764,6 +764,8 @@ $string['numberofmissingstrings'] = 'Number of missing strings: {$a}';
$string['numberofstrings'] = 'Total number of strings: {$a->strings}
Missing: {$a->missing} ({$a->missingpercent} %)';
$string['numquestions'] = 'No. questions';
$string['numquestionsandhidden'] = '{$a->numquestions} (+{$a->numhidden} hidden)';
+$string['numcoursesincombo'] = 'Maximum number of courses in combo list';
+$string['numcoursesincombo_help'] = 'The combo list doesn\'t work well with large numbers of courses. When the total number of courses in the site is higher than this setting then a link to the dedicated course listing will be shown instead of trying to display all the courses on the front page.';
$string['opensslrecommended'] = 'Installing the optional OpenSSL library is highly recommended -- it enables Moodle Networking functionality.';
$string['opentogoogle'] = 'Open to Google';
$string['optionalmaintenancemessage'] = 'Optional maintenance message';
diff --git a/lang/en/moodle.php b/lang/en/moodle.php
index 1958e418b98..faa6d9cbbb4 100644
--- a/lang/en/moodle.php
+++ b/lang/en/moodle.php
@@ -980,6 +980,7 @@ $string['maximumupload'] = 'Maximum upload size';
$string['maximumupload_help'] = 'This setting determines the largest size of file that can be uploaded to the course, limited by the site-wide setting set by an administrator. Activity modules also include a maximum upload size setting for further restricting the file size.';
$string['maxsize'] = 'Max size: {$a}';
$string['maxfilesize'] = 'Maximum size for new files: {$a}';
+$string['maxnumcoursesincombo'] = 'Browse {$a->numberofcourses} courses.';
$string['memberincourse'] = 'People in the course';
$string['messagebody'] = 'Message body';
$string['messagedselectedusers'] = 'Selected users have been messaged and the recipient list has been reset.';
diff --git a/version.php b/version.php
index 4a51179a846..41cd7ddc952 100644
--- a/version.php
+++ b/version.php
@@ -30,7 +30,7 @@
defined('MOODLE_INTERNAL') || die();
-$version = 2011031600.00; // YYYYMMDD = date of the last version bump
+$version = 2011032100.00; // YYYYMMDD = date of the last version bump
// XX = daily increments
$release = '2.0.2+ (Build: 20110316)'; // Human-friendly version name