Skip to content
Permalink
Browse files

MDL-33777 Equella repository properly set the source and display file…

… origin
  • Loading branch information...
marinaglancy committed Jun 22, 2012
1 parent ba3e7df commit c01f7628f790c3d7e26f8aa9070dad88b29e14f7
Showing with 36 additions and 6 deletions.
  1. +3 −1 repository/equella/callback.php
  2. +33 −5 repository/equella/lib.php
@@ -55,6 +55,8 @@
$license = s(clean_param($info->license, PARAM_ALPHAEXT));
}
$source = base64_encode(serialize((object)array('url'=>$url,'filename'=>$filename)));
$js =<<<EOD
<html>
<head>
@@ -63,7 +65,7 @@
window.onload = function() {
var resource = {};
resource.title = "$filename";
resource.source = "$url";
resource.source = "$source";
resource.thumbnail = '$thumbnail';
resource.author = "$author";
resource.license = "$license";
@@ -119,7 +119,7 @@ public function supported_returntypes() {
* @return string file referece
*/
public function get_file_reference($source) {
return base64_encode($source);
return $source;
}
/**
@@ -156,8 +156,8 @@ public function get_file($url, $filename = '') {
* @return null|stdClass containing attribute 'filepath'
*/
public function get_file_by_reference($reference) {
$ref = base64_decode($reference->reference);
$url = $this->appendtoken($ref);
$ref = unserialize(base64_decode($reference->reference));
$url = $this->appendtoken($ref->url);
if (!$url) {
// Occurs when the user isn't known..
@@ -188,8 +188,8 @@ public function get_file_by_reference($reference) {
* @param array $options additional options affecting the file serving
*/
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);
$reference = unserialize(base64_decode($stored_file->get_reference()));
$url = $this->appendtoken($reference->url);
if ($url) {
header('Location: ' . $url);
} else {
@@ -337,4 +337,32 @@ private static function get_all_editing_roles() {
private static function to_mime_type($value) {
return mimeinfo('type', $value);
}
/**
* Return the source information
*
* @param stdClass $url
* @return string|null
*/
public function get_file_source_info($url) {
$ref = unserialize(base64_decode($url));
return 'EQUELLA: ' . $ref->filename;
}
/**
* Return human readable reference information
* {@link stored_file::get_reference()}
*
* @param string $reference
* @param int $filestatus status of the file, 0 - ok, 666 - source missing
* @return string
*/
public function get_reference_details($reference, $filestatus = 0) {
if (!$filestatus) {
$ref = unserialize(base64_decode($reference));
return $this->get_name(). ': '. $ref->filename;
} else {
return get_string('lostsource', 'repository', '');
}
}
}

0 comments on commit c01f762

Please sign in to comment.
You can’t perform that action at this time.