/** * * @return string owner of the current file item * @throws \Exception */ public function getOwnerViewAndPath() { if ($this->isPublicShare()) { $rootLinkItem = \OCP\Share::resolveReShare($this->sharing[0]); if (isset($rootLinkItem['uid_owner'])) { $owner = $rootLinkItem['uid_owner']; } else { throw new \Exception($this->fileId . ' is a broken share'); } $view = new View('/' . $owner . '/files'); $path = $rootLinkItem['file_target']; } else { $owner = \OCP\User::getUser(); $view = new View('/' . $this->owner); $path = $view->getPath($this->fileId); } if (!$path) { throw new \Exception($this->fileId . ' can not be resolved'); } $this->path = $path; $this->owner = $owner; if (!$view->file_exists($this->path)) { throw new \Exception($this->path . ' doesn\'t exist'); } return array($view, $this->path); }
/** * * @return string owner of the current file item * @throws \Exception */ public function getOwnerViewAndPath($useDefaultRoot = false) { if ($this->isPublicShare()) { $rootLinkItem = \OCP\Share::resolveReShare($this->sharing[0]); if (isset($rootLinkItem['uid_owner'])) { $owner = $rootLinkItem['uid_owner']; \OCP\JSON::checkUserExists($rootLinkItem['uid_owner']); \OC_Util::tearDownFS(); \OC_Util::setupFS($rootLinkItem['uid_owner']); } else { throw new \Exception($this->fileId . ' is a broken share'); } $view = new View('/' . $owner . '/files'); } else { $owner = \OCP\User::getUser(); $root = '/' . $owner; if ($useDefaultRoot) { $root .= '/' . 'files'; } $view = new View($root); } $path = $view->getPath($this->fileId); if (!$path) { throw new \Exception($this->fileId . ' can not be resolved'); } $this->path = $path; $this->owner = $owner; if (!$view->file_exists($this->path)) { throw new \Exception($this->path . ' doesn\'t exist'); } return array($view, $this->path); }
/** * * @return string owner of the current file item * @throws \Exception */ public function getOwnerViewAndPath() { if (!$this->owner || !$this->path) { $info = $this->getSharedFileOwnerAndPath(); if (is_array($info) && count($info)) { $owner = $info[0]; $path = $info[1]; } else { list($owner, $path) = $this->getLocalFileOwnerAndPath(); } if (!$path) { throw new \Exception($this->fileId . ' can not be resolved'); } $this->path = $path; $this->owner = $owner; } /* to emit hooks properly, view root should contain /user/files */ if (strpos($this->path, 'files') === 0) { $path = preg_replace('|^files|', '', $this->path); $view = new View('/' . $this->owner . '/files'); } else { $path = $this->path; $view = new View('/' . $this->owner); } if (!$view->file_exists($path)) { throw new \Exception($this->path . ' doesn\'t exist'); } return array($view, $path); }