MDL-46705 admin: Check if course with same shortname already exists
This commit is contained in:
committed by
David Monllao
parent
e544b6b02a
commit
68bd2b3132
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user