diff --git a/admin/settings/appearance.php b/admin/settings/appearance.php index 824a647e1fb..4730c3217ad 100644 --- a/admin/settings/appearance.php +++ b/admin/settings/appearance.php @@ -76,6 +76,24 @@ preferences,moodle|/user/preferences.php|t/preferences', $ADMIN->add('appearance', $temp); + // Course colours section. + $temp = new admin_settingpage('coursecolors', new lang_string('coursecolorsettings', 'admin')); + $temp->add(new admin_setting_heading('coursecolorheading', '', + new lang_string('coursecolorheading_desc', 'admin'))); + + $basecolors = ['#81ecec', '#74b9ff', '#a29bfe', '#dfe6e9', '#00b894', + '#0984e3', '#b2bec3', '#fdcb6e', '#fd79a8', '#6c5ce7']; + + foreach ($basecolors as $key => $color) { + $number = $key + 1; + $name = 'core_admin/coursecolor' . $number; + $title = get_string('coursecolor', 'admin', $number); + $setting = new admin_setting_configcolourpicker($name, $title, '', $color); + $temp->add($setting); + } + + $ADMIN->add('appearance', $temp); + // Calendar settings. $temp = new admin_settingpage('calendar', new lang_string('calendarsettings','admin')); diff --git a/lang/en/admin.php b/lang/en/admin.php index 680aa0711a0..f020090d762 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -390,6 +390,9 @@ $string['cookiehttponly'] = 'Only http cookies'; $string['cookiesecure'] = 'Secure cookies only'; $string['country'] = 'Default country'; $string['course_customfield'] = 'Course custom fields'; +$string['coursecolor'] = 'Colour {$a}'; +$string['coursecolorheading_desc'] = 'Any courses without a course image set in the course settings are displayed on the Dashboard with a patterned course card. The colours used in the pattern may be specified below.'; +$string['coursecolorsettings'] = 'Course card colours'; $string['coursecontact'] = 'Course contacts'; $string['coursecontact_desc'] = 'This setting allows you to control who appears on the course description. Users need to have at least one of these roles in a course to be shown on the course description for that course.'; $string['coursecontactduplicates'] = 'Display all course contact roles'; diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index a259c6ea872..048ae58cb56 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -3402,5 +3402,19 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2019062900.00); } + if ($oldversion < 2019070400.01) { + + $basecolors = ['#81ecec', '#74b9ff', '#a29bfe', '#dfe6e9', '#00b894', + '#0984e3', '#b2bec3', '#fdcb6e', '#fd79a8', '#6c5ce7']; + + $colornr = 1; + foreach ($basecolors as $color) { + set_config('coursecolor' . $colornr, $color, 'core_admin'); + $colornr++; + } + + upgrade_main_savepoint(true, 2019070400.01); + } + return true; } diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index 3328e4cdb1d..fc94f17d7b6 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -1570,9 +1570,11 @@ class core_renderer extends renderer_base { * @return string hex color code. */ public function get_generated_color_for_id($id) { - // The colour palette is hardcoded for now. It would make sense to combine it with theme settings. - $basecolors = ['#81ecec', '#74b9ff', '#a29bfe', '#dfe6e9', '#00b894', - '#0984e3', '#b2bec3', '#fdcb6e', '#fd79a8', '#6c5ce7']; + $colornumbers = range(1, 10); + $basecolors = []; + foreach ($colornumbers as $number) { + $basecolors[] = get_config('core_admin', 'coursecolor' . $number); + } $color = $basecolors[$id % 10]; return $color; diff --git a/version.php b/version.php index b111fac9855..0a1f3e267c5 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2019071200.00; // YYYYMMDD = weekly release date of this DEV branch. +$version = 2019071200.01; // YYYYMMDD = weekly release date of this DEV branch. // RR = release increments - 00 in DEV branches. // .XX = incremental changes.