mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
MDL-43021 course: corrections to the shortname and idnumber uniqueness validation
This commit is contained in:
parent
ad32dda90c
commit
e13016850c
@ -2597,14 +2597,14 @@ function update_course($data, $editoroptions = NULL) {
|
||||
|
||||
// Check we don't have a duplicate shortname.
|
||||
if (!empty($data->shortname) && $oldcourse->shortname != $data->shortname) {
|
||||
if ($DB->record_exists('course', array('shortname' => $data->shortname))) {
|
||||
if ($DB->record_exists_sql('SELECT id from {course} WHERE shortname = ? AND id <> ?', array($data->shortname, $data->id))) {
|
||||
throw new moodle_exception('shortnametaken', '', '', $data->shortname);
|
||||
}
|
||||
}
|
||||
|
||||
// Check we don't have a duplicate idnumber.
|
||||
if (!empty($data->idnumber) && $oldcourse->idnumber != $data->idnumber) {
|
||||
if ($DB->record_exists('course', array('idnumber' => $data->idnumber))) {
|
||||
if ($DB->record_exists_sql('SELECT id from {course} WHERE idnumber = ? AND id <> ?', array($data->idnumber, $data->id))) {
|
||||
throw new moodle_exception('courseidnumbertaken', '', '', $data->idnumber);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user