diff options
author | Pranav Kant <pranavk@collabora.co.uk> | 2016-10-19 18:28:10 +0300 |
---|---|---|
committer | Pranav Kant <pranavk@collabora.co.uk> | 2016-10-19 18:42:29 +0300 |
commit | 7e64777f4a36cd7feefd164be86ab1353334601f (patch) | |
tree | 8294d86550883a6a6e5b26a29384ac22fb6d0081 /lib | |
parent | c1588590404054aba41f8dce3e346c79b00f63a9 (diff) |
Store canwrite property in DB
Move whether the file is editable or not logic when generating a
token and store it in the DB with the access token instead of
checking it dynamically in WOPI calls.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/db/wopi.php | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/db/wopi.php b/lib/db/wopi.php index c826a1a5..c4ea3830 100644 --- a/lib/db/wopi.php +++ b/lib/db/wopi.php @@ -29,8 +29,8 @@ class Wopi extends \OCA\Richdocuments\Db{ protected $tableName = '`*PREFIX*richdocuments_wopi`'; - protected $insertStatement = 'INSERT INTO `*PREFIX*richdocuments_wopi` (`owner_uid`, `editor_uid`, `fileid`, `version`, `path`, `token`, `expiry`) - VALUES (?, ?, ?, ?, ?, ?, ?)'; + protected $insertStatement = 'INSERT INTO `*PREFIX*richdocuments_wopi` (`owner_uid`, `editor_uid`, `fileid`, `version`, `path`, `canwrite`, `token`, `expiry`) + VALUES (?, ?, ?, ?, ?, ?, ?, ?)'; protected $loadStatement = 'SELECT * FROM `*PREFIX*richdocuments_wopi` WHERE `token`= ?'; @@ -41,7 +41,7 @@ class Wopi extends \OCA\Richdocuments\Db{ * its the version number as stored by files_version app * Returns the token. */ - public function generateFileToken($fileId, $version){ + public function generateFileToken($fileId, $version, $updatable){ // Get the FS view of the current user. $view = \OC\Files\Filesystem::getView(); @@ -79,6 +79,7 @@ class Wopi extends \OCA\Richdocuments\Db{ $fileId, $version, $path, + $updatable, $token, time() + self::TOKEN_LIFETIME_SECONDS ]); @@ -120,6 +121,11 @@ class Wopi extends \OCA\Richdocuments\Db{ return false; } - return array('owner' => $row['owner_uid'], 'editor' => $row['editor_uid'], 'path' => $row['path']); + return array( + 'owner' => $row['owner_uid'], + 'editor' => $row['editor_uid'], + 'path' => $row['path'], + 'canwrite' => $row['canwrite'] + ); } } |