mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 04:30:15 +01:00
Merge branch 'w07_MDL-26452_20_resmess' of git://github.com/skodak/moodle
This commit is contained in:
commit
2e629eb861
@ -228,24 +228,22 @@ function xmldb_resource_upgrade($oldversion) {
|
||||
|
||||
$instances = $DB->get_recordset_sql($sql);
|
||||
foreach ($instances as $instance) {
|
||||
$context = get_context_instance(CONTEXT_MODULE, $instance->cmid);
|
||||
$component = 'mod_resource';
|
||||
$filearea = 'content';
|
||||
$itemid = 0;
|
||||
$filepath = file_correct_filepath(dirname($instance->mainfile));
|
||||
$filename = basename($instance->mainfile);
|
||||
file_set_sortorder($context->id, $component, $filearea, $itemid, $filepath, $filename, 1);
|
||||
if (empty($instance->mainfile)) {
|
||||
// weird
|
||||
continue;
|
||||
}
|
||||
$context = get_context_instance(CONTEXT_MODULE, $instance->cmid, MUST_EXIST);
|
||||
$parts = explode('/', $instance->mainfile);
|
||||
$filename = array_pop($parts);
|
||||
$filepath = implode('/', $parts);
|
||||
file_set_sortorder($context->id, 'mod_resource', 'content', 0, $filepath, $filename, 1);
|
||||
}
|
||||
$instances->close();
|
||||
|
||||
/// Define field mainfile to be dropped from resource
|
||||
$table = new xmldb_table('resource');
|
||||
$field = new xmldb_field('mainfile');
|
||||
|
||||
/// Conditionally launch drop field mainfile
|
||||
if ($dbman->field_exists($table, $field)) {
|
||||
$dbman->drop_field($table, $field);
|
||||
}
|
||||
$dbman->drop_field($table, $field);
|
||||
|
||||
/// resource savepoint reached
|
||||
upgrade_mod_savepoint(true, 2009080501, 'resource');
|
||||
|
@ -67,12 +67,13 @@ if ($resource->tobemigrated) {
|
||||
}
|
||||
|
||||
$fs = get_file_storage();
|
||||
$files = $fs->get_area_files($context->id, 'mod_resource', 'content', 0, 'sortorder');
|
||||
$files = $fs->get_area_files($context->id, 'mod_resource', 'content', 0, 'sortorder DESC, id ASC', false); // TODO: this is not very efficient!!
|
||||
if (count($files) < 1) {
|
||||
resource_print_filenotfound($resource, $cm, $course);
|
||||
die;
|
||||
} else {
|
||||
$file = array_pop($files);
|
||||
$file = reset($files);
|
||||
unset($files);
|
||||
}
|
||||
|
||||
if ($redirect) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user