mirror of
https://github.com/moodle/moodle.git
synced 2025-04-20 16:04:25 +02:00
MDL-32117 - equella: prevent errors when no username
This commit is contained in:
parent
e3e4ca5ae9
commit
d66e5720a1
@ -138,6 +138,11 @@ class repository_equella extends repository {
|
||||
$ref = base64_decode($reference->reference);
|
||||
$url = $this->appendtoken($ref);
|
||||
|
||||
if (!$url) {
|
||||
// Occurs when the user isn't known..
|
||||
return false;
|
||||
}
|
||||
|
||||
// We use this cache to get the correct file size.
|
||||
$cachedfilepath = cache_file::get($url, array('ttl' => 0));
|
||||
if ($cachedfilepath === false) {
|
||||
@ -160,7 +165,9 @@ class repository_equella extends repository {
|
||||
public function send_file($stored_file, $lifetime=86400 , $filter=0, $forcedownload=false, array $options = null) {
|
||||
$reference = base64_decode($stored_file->get_reference());
|
||||
$url = $this->appendtoken($reference);
|
||||
header('Location: ' . $url);
|
||||
if ($url) {
|
||||
header('Location: ' . $url);
|
||||
}
|
||||
die;
|
||||
}
|
||||
|
||||
@ -251,7 +258,11 @@ class repository_equella extends repository {
|
||||
* @return string
|
||||
*/
|
||||
private function appendtoken($url, $readwrite = null) {
|
||||
return $url . (strpos($url, '?') != false ? '&' : '?') . 'token=' . urlencode($this->getssotoken($readwrite));
|
||||
$ssotoken = $this->getssotoken($readwrite);
|
||||
if (!$ssotoken) {
|
||||
return false;
|
||||
}
|
||||
return $url . (strpos($url, '?') != false ? '&' : '?') . 'token=' . urlencode($ssotoken);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -263,6 +274,10 @@ class repository_equella extends repository {
|
||||
private function getssotoken($readwrite = 'read') {
|
||||
global $USER;
|
||||
|
||||
if (empty($USER->username)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($readwrite == 'write') {
|
||||
|
||||
foreach (self::get_all_editing_roles() as $role) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user