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

@ -286,9 +286,6 @@ function url_get_coursemodule_info($coursemodule) {
$fullurl = "$CFG->wwwroot/mod/url/view.php?id=$coursemodule->id&redirect=1";
$info->onclick = "window.open('$fullurl'); return false;";
} else if ($display == RESOURCELIB_DISPLAY_OPEN) {
$fullurl = "$CFG->wwwroot/mod/url/view.php?id=$coursemodule->id&redirect=1";
$info->onclick = "window.location.href ='$fullurl';return false;";
}
if ($coursemodule->showdescription) {

View file

@ -67,6 +67,15 @@ if (empty($exturl) or $exturl === 'http://') {
}
unset($exturl);
$displaytype = url_get_final_display_type($url);
if ($displaytype == RESOURCELIB_DISPLAY_OPEN) {
// For 'open' links, we always redirect to the content - except if the user
// just chose 'save and display' from the form then that would be confusing
if (!isset($_SERVER['HTTP_REFERER']) || strpos($_SERVER['HTTP_REFERER'], 'modedit.php') === false) {
$redirect = true;
}
}
if ($redirect) {
// coming from course page or url index page,
// the redirection is needed for completion tracking and logging
@ -74,7 +83,7 @@ if ($redirect) {
redirect(str_replace('&', '&', $fullurl));
}
switch (url_get_final_display_type($url)) {
switch ($displaytype) {
case RESOURCELIB_DISPLAY_EMBED:
url_display_embed($url, $cm, $course);
break;