From dbd46203658c8d87a2dd11db200d36cd3f9c419e Mon Sep 17 00:00:00 2001 From: Mihail Geshoski Date: Wed, 28 Apr 2021 12:56:46 +0800 Subject: [PATCH] MDL-71470 repository_googledocs: Use file name in the source attribute Instead of using the file title when generating the source attribute, we should be using only the name of the Google Drive file in order to avoid having the original extension within the filename after the file is imported and added into Moodle. --- repository/googledocs/classes/local/node/file_node.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/repository/googledocs/classes/local/node/file_node.php b/repository/googledocs/classes/local/node/file_node.php index bbcb7f032a5..142714c9469 100644 --- a/repository/googledocs/classes/local/node/file_node.php +++ b/repository/googledocs/classes/local/node/file_node.php @@ -31,6 +31,9 @@ class file_node implements node { /** @var string|null The title of the file node. */ private $title; + /** @var string The name of the file. */ + private $name; + /** @var string|null The file's export format. */ private $exportformat; @@ -54,6 +57,7 @@ class file_node implements node { public function __construct(\stdClass $gdfile) { $this->id = $gdfile->id; $this->title = $this->generate_file_title($gdfile); + $this->name = $gdfile->name; $this->exportformat = $this->generate_file_export_format($gdfile); $this->link = $this->generate_file_link($gdfile); $this->modified = ($gdfile->modifiedTime) ? strtotime($gdfile->modifiedTime) : ''; @@ -90,7 +94,7 @@ class file_node implements node { 'source' => json_encode( [ 'id' => $this->id, - 'name' => $this->title, + 'name' => $this->name, 'link' => $this->link, 'exportformat' => $this->exportformat, ]