Merge branch 'MDL-37014_webdav_folders_23' of git://github.com/davosmith/moodle into...
authorDan Poltawski <dan@moodle.com>
Tue, 18 Dec 2012 06:52:41 +0000 (14:52 +0800)
committerDan Poltawski <dan@moodle.com>
Tue, 18 Dec 2012 06:52:41 +0000 (14:52 +0800)
1  2 
repository/webdav/lib.php

@@@ -71,13 -71,17 +71,13 @@@ class repository_webdav extends reposit
          return true;
      }
      public function get_file($url, $title = '') {
 -        global $CFG;
          $url = urldecode($url);
          $path = $this->prepare_file($title);
 -        $buffer = '';
          if (!$this->dav->open()) {
              return false;
          }
          $webdavpath = rtrim('/'.ltrim($this->options['webdav_path'], '/ '), '/ '); // without slash in the end
 -        $this->dav->get($webdavpath. $url, $buffer);
 -        $fp = fopen($path, 'wb');
 -        fwrite($fp, $buffer);
 +        $this->dav->get_file($webdavpath. $url, $path);
          return array('path'=>$path);
      }
      public function global_search() {
                  $v['lastmodified'] = null;
              }
  
+             // Remove the server URL from the path (if present), otherwise links will not work - MDL-37014
+             $server = preg_quote($this->options['webdav_server']);
+             $v['href'] = preg_replace("#https?://{$server}#", '', $v['href']);
              // Extracting object title from absolute path
              $v['href'] = substr(urldecode($v['href']), strlen($webdavpath));
              $title = substr($v['href'], strlen($path));