Merge branch 'wip-MDL-33777-master' of git://github.com/marinaglancy/moodle

This commit is contained in:
Dan Poltawski
2012-06-25 16:18:27 +08:00
2 changed files with 36 additions and 6 deletions
+3 -1
View File
@@ -55,6 +55,8 @@ if (isset($info->license)) {
$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 @@ $js =<<<EOD
window.onload = function() {
var resource = {};
resource.title = "$filename";
resource.source = "$url";
resource.source = "$source";
resource.thumbnail = '$thumbnail';
resource.author = "$author";
resource.license = "$license";
+33 -5
View File
@@ -119,7 +119,7 @@ class repository_equella extends repository {
* @return string file referece
*/
public function get_file_reference($source) {
return base64_encode($source);
return $source;
}
/**
@@ -156,8 +156,8 @@ class repository_equella extends repository {
* @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 @@ class repository_equella extends repository {
* @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 @@ class repository_equella extends repository {
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', '');
}
}
}