Commit 1b323791 authored by Mike Kelly's avatar Mike Kelly
Browse files

Fix PDFs SAMEORIGIN error when using subdomains (Bug #1399246)



Previous fix didn't work when page was viewed by third parties.
The subdomain address for the iframe needs to be derived from the page
author, not the current user.

Change-Id: Ic3669dd01fbe600ed2e9cf74b939ef96a84addca
Signed-off-by: default avatarMike Kelly <m.f.kelly@arts.ac.uk>
parent 16892d04
......@@ -48,10 +48,11 @@ class PluginBlocktypePdf extends PluginBlocktype {
$urlbase = get_config('wwwroot');
// edit view doesn't use subdomains, neither do groups
if (get_config('cleanurls') && get_config('cleanurlusersubdomains') && !$editing && empty($group)) {
global $USER;
$userurlid = $USER->get('urlid');
if ($urlallowed = !is_null($userurlid) && strlen($userurlid)) {
$urlbase = profile_url($USER) . '/';
$viewauthor = new User();
$viewauthor->find_by_id($view->get('owner'));
$viewauthorurlid = $viewauthor->get('urlid');
if ($urlallowed = !is_null($viewauthorurlid) && strlen($viewauthorurlid)) {
$urlbase = profile_url($viewauthor) . '/';
}
}
......
......@@ -38,10 +38,12 @@ if (!($file instanceof ArtefactTypeFile)) {
$urlbase = get_config('wwwroot');
if (get_config('cleanurls') && get_config('cleanurlusersubdomains') && !$editing && !$ingroup) {
global $USER;
$userurlid = $USER->get('urlid');
if ($urlallowed = !is_null($userurlid) && strlen($userurlid)) {
$urlbase = profile_url($USER) . '/';
$view = new View($viewid);
$viewauthor = new User();
$viewauthor->find_by_id($view->get('owner'));
$viewauthorurlid = $viewauthor->get('urlid');
if ($urlallowed = !is_null($viewauthorurlid) && strlen($viewauthorurlid)) {
$urlbase = profile_url($viewauthor) . '/';
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment