Merge branch 'MDL-75789-400' of https://github.com/paulholden/moodle into MOODLE_400_STABLE
This commit is contained in:
@@ -1806,10 +1806,9 @@ abstract class restore_dbops {
|
||||
public static function calculate_course_names($courseid, $fullname, $shortname) {
|
||||
global $CFG, $DB;
|
||||
|
||||
$currentfullname = '';
|
||||
$currentshortname = '';
|
||||
$counter = 0;
|
||||
// Iteratere while the name exists
|
||||
|
||||
// Iterate while fullname or shortname exist.
|
||||
do {
|
||||
if ($counter) {
|
||||
$suffixfull = ' ' . get_string('copyasnoun') . ' ' . $counter;
|
||||
@@ -1818,8 +1817,11 @@ abstract class restore_dbops {
|
||||
$suffixfull = '';
|
||||
$suffixshort = '';
|
||||
}
|
||||
$currentfullname = $fullname.$suffixfull;
|
||||
$currentshortname = substr($shortname, 0, 100 - strlen($suffixshort)).$suffixshort; // < 100cc
|
||||
|
||||
// Ensure we don't overflow maximum length of name fields, in multi-byte safe manner.
|
||||
$currentfullname = core_text::substr($fullname, 0, 254 - strlen($suffixfull)) . $suffixfull;
|
||||
$currentshortname = core_text::substr($shortname, 0, 100 - strlen($suffixshort)) . $suffixshort;
|
||||
|
||||
$coursefull = $DB->get_record_select('course', 'fullname = ? AND id != ?',
|
||||
array($currentfullname, $courseid), '*', IGNORE_MULTIPLE);
|
||||
$courseshort = $DB->get_record_select('course', 'shortname = ? AND id != ?', array($currentshortname, $courseid));
|
||||
|
||||
Reference in New Issue
Block a user