diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Controller/DocumentController.php | 6 | ||||
-rw-r--r-- | lib/Controller/WopiController.php | 59 |
2 files changed, 32 insertions, 33 deletions
diff --git a/lib/Controller/DocumentController.php b/lib/Controller/DocumentController.php index 4fde3599..d8df677a 100644 --- a/lib/Controller/DocumentController.php +++ b/lib/Controller/DocumentController.php @@ -104,7 +104,7 @@ class DocumentController extends Controller { $params = [ 'permissions' => $item->getPermissions(), 'title' => $item->getName(), - 'fileId' => $item->getId(), + 'fileId' => $item->getId() . '_' . $this->settings->getSystemValue('instanceid'), 'token' => $token, 'urlsrc' => $urlSrc, 'path' => '/', @@ -153,7 +153,7 @@ class DocumentController extends Controller { $params = [ 'permissions' => $share->getPermissions(), 'title' => $item->getName(), - 'fileId' => $item->getId(), + 'fileId' => $item->getId() . '_' . $this->settings->getSystemValue('instanceid'), 'token' => $token, 'urlsrc' => $urlSrc, 'path' => '/', @@ -233,7 +233,7 @@ class DocumentController extends Controller { $ret = $this->wopiParser->getUrlSrc($mimetype); $response = array( 'status' => 'success', - 'fileid' => $info['fileid'], + 'fileid' => $info['fileid'] . '_' . $this->settings->getSystemValue('instanceid'), 'urlsrc' => $ret['urlsrc'], 'action' => $ret['action'], 'lolang' => $this->settings->getUserValue($this->uid, 'core', 'lang', 'en'), diff --git a/lib/Controller/WopiController.php b/lib/Controller/WopiController.php index 0ced4669..561305e0 100644 --- a/lib/Controller/WopiController.php +++ b/lib/Controller/WopiController.php @@ -35,32 +35,42 @@ use OCP\AppFramework\Http\StreamResponse; class WopiController extends Controller { /** @var IRootFolder */ private $rootFolder; - /** @var string */ - private $userId; - /** @var IUserManager */ - private $userManager; - /** @var Parser */ - private $wopiParser; /** * @param string $appName * @param IRequest $request * @param IRootFolder $rootFolder * @param string $UserId - * @param IUserManager $userManager - * @param Parser $wopiParser */ public function __construct($appName, $UserId, IRequest $request, - IRootFolder $rootFolder, - IUserManager $userManager, - Parser $wopiParser) { + IRootFolder $rootFolder) { parent::__construct($appName, $request); $this->rootFolder = $rootFolder; - $this->userId = $UserId; - $this->userManager = $userManager; - $this->wopiParser = $wopiParser; + } + + /** + * @param string $fileId + * @return array + * @throws \Exception + */ + private function parseFileId($fileId) { + $arr = explode('_', $fileId, 2); + if (count($arr) === 2) { + list($fileId, $instanceId) = $arr; + $version = '0'; + } else if (count($arr) === 3) { + list($fileId, $instanceId, $version) = $arr; + } else { + throw new \Exception('$fileId has not the expected format'); + } + + return [ + $fileId, + $instanceId, + $version, + ]; } /** @@ -76,11 +86,7 @@ class WopiController extends Controller { public function checkFileInfo($fileId) { $token = $this->request->getParam('access_token'); - $arr = explode('_', $fileId, 2); - $version = '0'; - if (count($arr) === 2) { - list($fileId, $version) = $arr; - } + list($fileId, , $version) = $this->parseFileId($fileId); $row = new Wopi(); $row->loadBy('token', $token); @@ -130,11 +136,7 @@ class WopiController extends Controller { */ public function getFile($fileId, $access_token) { - $arr = explode('_', $fileId, 2); - $version = '0'; - if (count($arr) === 2) { - list($fileId, $version) = $arr; - } + list($fileId, , $version) = $this->parseFileId($fileId); $row = new Wopi(); $row->loadBy('token', $access_token); @@ -165,12 +167,9 @@ class WopiController extends Controller { * @param string $access_token * @return JSONResponse */ - public function putFile($fileId, $access_token) { - $arr = explode('_', $fileId, 2); - $version = '0'; - if (count($arr) === 2) { - list($fileId, $version) = $arr; - } + public function putFile($fileId, + $access_token) { + list($fileId, , $version) = $this->parseFileId($fileId); $row = new Wopi(); $row->loadBy('token', $access_token); |