mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 17:36:38 +02:00
MDL-41417 course: prevent duplicate idnumbers being used when updating a course
This commit is contained in:
parent
b69ec2889e
commit
5536a5617c
4 changed files with 77 additions and 16 deletions
|
@ -717,20 +717,14 @@ class core_course_external extends external_api {
|
|||
require_capability('moodle/course:changefullname', $context);
|
||||
}
|
||||
|
||||
// Check if the shortname already exist and user have capability.
|
||||
// Check if the user can change shortname.
|
||||
if (array_key_exists('shortname', $course) && ($oldcourse->shortname != $course['shortname'])) {
|
||||
require_capability('moodle/course:changeshortname', $context);
|
||||
if ($DB->record_exists('course', array('shortname' => $course['shortname']))) {
|
||||
throw new moodle_exception('shortnametaken', '', '', $course['shortname']);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the id number already exist and user have capability.
|
||||
// Check if the user can change the idnumber.
|
||||
if (array_key_exists('idnumber', $course) && ($oldcourse->idnumber != $course['idnumber'])) {
|
||||
require_capability('moodle/course:changeidnumber', $context);
|
||||
if ($DB->record_exists('course', array('idnumber' => $course['idnumber']))) {
|
||||
throw new moodle_exception('courseidnumbertaken', '', '', $course['idnumber']);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if user can change summary.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue