From ab519e888b99624046ba670bf97f1c9bc849a79a Mon Sep 17 00:00:00 2001 From: Lorenzo Nicora Date: Sun, 10 Jun 2012 09:25:19 +0200 Subject: [PATCH 1/3] MDL-33531 Fixed the regexp to find old backup files, considering backup_shortname backup option --- backup/util/helper/backup_cron_helper.class.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/backup/util/helper/backup_cron_helper.class.php b/backup/util/helper/backup_cron_helper.class.php index 4bc6b6191a9..917101fbdbb 100644 --- a/backup/util/helper/backup_cron_helper.class.php +++ b/backup/util/helper/backup_cron_helper.class.php @@ -508,7 +508,17 @@ abstract class backup_cron_automated_helper { if (!empty($dir) && ($storage == 1 || $storage == 2)) { // Calculate backup filename regex, ignoring the date/time/info parts that can be // variable, depending of languages, formats and automated backup settings - $filename = $backupword . '-' . backup::FORMAT_MOODLE . '-' . backup::TYPE_1COURSE . '-' .$course->id . '-'; + + + // MDL-33531: use different filenames depending on backup_shortname option + if ( $config->backup_shortname ) { + $courseref = $course->shortname; + $courseref = str_replace(' ', '_', $courseref); + $courseref = textlib::strtolower(trim(clean_filename($courseref), '_')); + } else { + $courseref = $course->id; + } + $filename = $backupword . '-' . backup::FORMAT_MOODLE . '-' . backup::TYPE_1COURSE . '-' .$courseref . '-'; $regex = '#^'.preg_quote($filename, '#').'.*\.mbz$#'; // Store all the matching files into fullpath => timemodified array From bde0eac589a543d427f79ecc956ac5ad5249ee94 Mon Sep 17 00:00:00 2001 From: David Monllao Date: Fri, 6 Jul 2012 15:43:33 +0800 Subject: [PATCH 2/3] MDL-33531 backup Avoiding possible Notice --- backup/util/helper/backup_cron_helper.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backup/util/helper/backup_cron_helper.class.php b/backup/util/helper/backup_cron_helper.class.php index 917101fbdbb..a584b441211 100644 --- a/backup/util/helper/backup_cron_helper.class.php +++ b/backup/util/helper/backup_cron_helper.class.php @@ -511,7 +511,7 @@ abstract class backup_cron_automated_helper { // MDL-33531: use different filenames depending on backup_shortname option - if ( $config->backup_shortname ) { + if ( !empty($config->backup_shortname) ) { $courseref = $course->shortname; $courseref = str_replace(' ', '_', $courseref); $courseref = textlib::strtolower(trim(clean_filename($courseref), '_')); From f4162effebc82759c755854ac50b8d48b3331e8c Mon Sep 17 00:00:00 2001 From: David Monllao Date: Mon, 16 Jul 2012 10:20:20 +0800 Subject: [PATCH 3/3] MDL-33531 backup Added format_string to course shortname --- backup/util/helper/backup_cron_helper.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backup/util/helper/backup_cron_helper.class.php b/backup/util/helper/backup_cron_helper.class.php index a584b441211..68e92987f49 100644 --- a/backup/util/helper/backup_cron_helper.class.php +++ b/backup/util/helper/backup_cron_helper.class.php @@ -512,7 +512,8 @@ abstract class backup_cron_automated_helper { // MDL-33531: use different filenames depending on backup_shortname option if ( !empty($config->backup_shortname) ) { - $courseref = $course->shortname; + $context = get_context_instance(CONTEXT_COURSE, $course->id); + $courseref = format_string($course->shortname, true, array('context' => $context)); $courseref = str_replace(' ', '_', $courseref); $courseref = textlib::strtolower(trim(clean_filename($courseref), '_')); } else {