mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-41259 when duplicate course shortname exists an exception is thrown and sync is aborted
This commit is contained in:
parent
d2aa53be1b
commit
fdb04f62e9
@ -53,6 +53,7 @@ $string['course_summary_key'] = 'Summary';
|
||||
$string['createcourseextid'] = 'CREATE User enrolled to a nonexistant course \'{$a->courseextid}\'';
|
||||
$string['createnotcourseextid'] = 'User enrolled to a nonexistant course \'{$a->courseextid}\'';
|
||||
$string['creatingcourse'] = 'Creating course \'{$a}\'...';
|
||||
$string['duplicateshortname'] = "Course creation failed. Duplicate short name. Skipping course with idnumber '{\$a->idnumber}'...";
|
||||
$string['editlock'] = 'Lock value';
|
||||
$string['emptyenrolment'] = "Empty enrolment for role '{\$a->role_shortname}' in course '{\$a->course_shortname}'\n";
|
||||
$string['enrolname'] = 'LDAP';
|
||||
|
@ -990,6 +990,12 @@ class enrol_ldap_plugin extends enrol_plugin {
|
||||
$course->summary = $course_ext[$this->get_config('course_summary')][0];
|
||||
}
|
||||
|
||||
// Check if the shortname already exists if it does - skip course creation.
|
||||
if ($DB->record_exists('course', array('shortname' => $course->shortname))) {
|
||||
$trace->output(get_string('duplicateshortname', 'enrol_ldap', $course));
|
||||
return false;
|
||||
}
|
||||
|
||||
$newcourse = create_course($course);
|
||||
return $newcourse->id;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user