diff --git a/lib/adminlib.php b/lib/adminlib.php index 3563fde4fbc..c812b3b7ab1 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -4001,10 +4001,14 @@ class admin_setting_sitesettext extends admin_setting_configtext { * @return mixed true or message string */ public function validate($data) { + global $DB; $cleaned = clean_param($data, PARAM_TEXT); if ($cleaned === '') { return get_string('required'); } + if ($this->name ==='shortname' && $DB->record_exists('course', array('shortname' => $data))) { + return get_string('shortnametaken', 'error', $data); + } if ("$data" == "$cleaned") { // implicit conversion to string is needed to do exact comparison return true; } else {