Skip to content

Commit

Permalink
Merge branch 'MDL-33812-master' of git://github.com/FMCorz/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Sep 3, 2012
2 parents bf14738 + 61d71da commit edeb39d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 18 deletions.
17 changes: 17 additions & 0 deletions backup/upgrade.txt
@@ -0,0 +1,17 @@
This files describes API changes in /backup/*,
information provided here is intended especially for developers.

=== 2.4 ===

* Since 2.3.1+ the backup file name schema has changed. The ID of the course will always be part of
the filename regardless of the setting 'backup_shortname'. See MDL-33812.

=== 2.3 ===

* Since 2.3.1+ the backup file name schema has changed. The ID of the course will always be part of
the filename regardless of the setting 'backup_shortname'. See MDL-33812.

=== 2.2 ===

* Since 2.2.4+ the backup file name schema has changed. The ID of the course will always be part of
the filename regardless of the setting 'backup_shortname'. See MDL-33812.
14 changes: 9 additions & 5 deletions backup/util/dbops/backup_plan_dbops.class.php
Expand Up @@ -197,19 +197,19 @@ public static function get_mnet_localhost_wwwroot() {
* @param int $courseid/$sectionid/$cmid
* @param bool $users Should be true is users were included in the backup
* @param bool $anonymised Should be true is user information was anonymized.
* @param bool $useidasname true to use id, false to use strings (default)
* @param bool $useidonly only use the ID in the file name
* @return string The filename to use
*/
public static function get_default_backup_filename($format, $type, $id, $users, $anonymised, $useidasname = false) {
public static function get_default_backup_filename($format, $type, $id, $users, $anonymised, $useidonly = false) {
global $DB;

// Calculate backup word
$backupword = str_replace(' ', '_', textlib::strtolower(get_string('backupfilename')));
$backupword = trim(clean_filename($backupword), '_');

// Not $useidonly, lets fetch the name
$shortname = '';
// Not $useidasname, lets calculate it, else $id will be used
if (!$useidasname) {
if (!$useidonly) {
// Calculate proper name element (based on type)
switch ($type) {
case backup::TYPE_1COURSE:
Expand All @@ -231,7 +231,11 @@ public static function get_default_backup_filename($format, $type, $id, $users,
$shortname = textlib::strtolower(trim(clean_filename($shortname), '_'));
}

$name = empty($shortname) ? $id : $shortname;
// The name will always contain the ID, but we append the course short name if requested.
$name = $id;
if (!$useidonly && $shortname != '') {
$name .= '-' . $shortname;
}

// Calculate date
$backupdateformat = str_replace(' ', '_', get_string('backupnameformat', 'langconfig'));
Expand Down
13 changes: 1 addition & 12 deletions backup/util/helper/backup_cron_helper.class.php
Expand Up @@ -561,18 +561,7 @@ public static function remove_excess_backups($course) {
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


// MDL-33531: use different filenames depending on backup_shortname option
if ( !empty($config->backup_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 {
$courseref = $course->id;
}
$filename = $backupword . '-' . backup::FORMAT_MOODLE . '-' . backup::TYPE_1COURSE . '-' .$courseref . '-';
$filename = $backupword . '-' . backup::FORMAT_MOODLE . '-' . backup::TYPE_1COURSE . '-' .$course->id . '-';
$regex = '#^'.preg_quote($filename, '#').'.*\.mbz$#';

// Store all the matching files into fullpath => timemodified array
Expand Down
2 changes: 1 addition & 1 deletion lang/en/admin.php
Expand Up @@ -68,7 +68,7 @@
$string['backgroundcolour'] = 'Transparent colour';
$string['backups'] = 'Backups';
$string['backup_shortname'] = 'Use course name in backup filename';
$string['backup_shortnamehelp'] = 'Use the course name as part of the backup filename instead of the course id number.';
$string['backup_shortnamehelp'] = 'Use the course name as part of the backup filename.';
$string['badwordsconfig'] = 'Enter your list of bad words separated by commas.';
$string['badwordsdefault'] = 'If the custom list is empty, a default list from the language pack will be used.';
$string['badwordslist'] = 'Custom bad words list';
Expand Down

0 comments on commit edeb39d

Please sign in to comment.