MDL-31015 File/URL resource 'Open' and 'Force download' options should work consistently

This commit is contained in:
sam marshall 2012-01-04 11:44:18 +00:00
parent 216f6d8e9d
commit 68828cc431
4 changed files with 23 additions and 31 deletions

View file

@ -285,30 +285,6 @@ function resource_get_coursemodule_info($coursemodule) {
$fullurl = "$CFG->wwwroot/mod/resource/view.php?id=$coursemodule->id&redirect=1";
$info->onclick = "window.open('$fullurl'); return false;";
} else if ($display == RESOURCELIB_DISPLAY_OPEN) {
$fullurl = "$CFG->wwwroot/mod/resource/view.php?id=$coursemodule->id&redirect=1";
$info->onclick = "window.location.href ='$fullurl';return false;";
} else if ($display == RESOURCELIB_DISPLAY_DOWNLOAD) {
if (empty($mainfile)) {
return NULL;
}
// do not open any window because it would be left there after download
$path = '/'.$context->id.'/mod_resource/content/'.$resource->revision.$mainfile->get_filepath().$mainfile->get_filename();
$fullurl = addslashes_js(file_encode_url($CFG->wwwroot.'/pluginfile.php', $path, true));
// When completion information is enabled for download files, make
// the JavaScript version go to the view page with redirect set,
// instead of directly to the file, otherwise we can't make it tick
// the box for them
if (!$course = $DB->get_record('course', array('id'=>$coursemodule->course), 'id, enablecompletion')) {
return NULL;
}
$completion = new completion_info($course);
if ($completion->is_enabled($coursemodule) == COMPLETION_TRACKING_AUTOMATIC) {
$fullurl = "$CFG->wwwroot/mod/resource/view.php?id=$coursemodule->id&redirect=1";
}
$info->onclick = "window.open('$fullurl'); return false;";
}
// If any optional extra details are turned on, store in custom data