$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) {
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;
}
* @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);
}
/**
private function getssotoken($readwrite = 'read') {
global $USER;
+ if (empty($USER->username)) {
+ return false;
+ }
+
if ($readwrite == 'write') {
foreach (self::get_all_editing_roles() as $role) {