MDL-35542 Fixed a bug when trying to directly link to a file from Dropbox
authorMarina Glancy <marina@moodle.com>
Thu, 20 Sep 2012 02:21:42 +0000 (10:21 +0800)
committerMarina Glancy <marina@moodle.com>
Thu, 20 Sep 2012 07:37:48 +0000 (15:37 +0800)
repository/dropbox/lib.php

index 768580e..508c05e 100644 (file)
@@ -506,6 +506,10 @@ class repository_dropbox extends repository {
      */
     public function get_link($reference) {
         $ref = unserialize($reference);
+        if (!isset($ref->url)) {
+            $this->dropbox->set_access_token($ref->access_key, $ref->access_secret);
+            $ref->url = $this->dropbox->get_file_share_link($ref->path, self::GETFILE_TIMEOUT);
+        }
         return $this->get_file_download_link($ref->url);
     }