Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-28221 Legacy resource URL pointing to the course itself are migra…

…ted as File module

This patch replays the logic of resource_20_migrate() function. If a
file is referred via URL to the course files of the course being
backed up, then such a resource is converted to the File module
(mod/resource) rather than URL module.
  • Loading branch information...
commit 665120d4e644079570c5e283f58e9165409f5a31 1 parent b0e79df
@mudrd8mz mudrd8mz authored
Showing with 12 additions and 2 deletions.
  1. +12 −2 mod/resource/backup/moodle1/lib.php
View
14 mod/resource/backup/moodle1/lib.php
@@ -185,13 +185,17 @@ public function process_resource(array $data, array $raw) {
$resource['intro'] = moodle1_converter::migrate_referenced_files($resource['intro'], $this->fileman);
// convert the referenced file itself as a main file in the content area
+ $reference = $data['reference'];
+ if (strpos($reference, '$@FILEPHP@$') === 0) {
+ $reference = str_replace(array('$@FILEPHP@$', '$@SLASH@$', '$@FORCEDOWNLOAD@$'), array('', '/', ''), $reference);
+ }
$this->fileman->filearea = 'content';
$this->fileman->itemid = 0;
try {
- $this->fileman->migrate_file('course_files/'.$data['reference'], '/', null, 1);
+ $this->fileman->migrate_file('course_files/'.$reference, '/', null, 1);
} catch (moodle1_convert_exception $e) {
// the file probably does not exist
- $this->log('error migrating the resource main file', backup::LOG_WARNING, 'course_files/'.$data['reference']);
+ $this->log('error migrating the resource main file', backup::LOG_WARNING, 'course_files/'.$reference);
}
// write resource.xml
@@ -247,6 +251,12 @@ protected function get_successor($type, $reference) {
$name = 'imscp';
break;
case 'file':
+ // if starts with $@FILEPHP@$ then it is URL link to a local course file
+ // to be migrated to the new resource module
+ if (strpos($reference, '$@FILEPHP@$') === 0) {
+ $name = null;
+ break;
+ }
// if http:// https:// ftp:// OR starts with slash need to be converted to URL
if (strpos($reference, '://') or strpos($reference, '/') === 0) {
$name = 'url';
Please sign in to comment.
Something went wrong with that request. Please try again.