From a3cc3b3ce3d597200fe51bae108ebf362278ef4a Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Thu, 10 Apr 2014 19:53:56 +0300 Subject: [PATCH] Pass file instance to genesys --- lib/db/session.php | 11 +++-------- lib/genesis.php | 9 +++++---- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/lib/db/session.php b/lib/db/session.php index 37fb47eb..aa9bdff9 100644 --- a/lib/db/session.php +++ b/lib/db/session.php @@ -38,12 +38,10 @@ class Db_Session extends \OCA\Documents\Db { public static function start($uid, $fileId, $isGuest){ $file = new File($fileId); - list($ownerView, $path) = $file->getOwnerViewAndPath(); - // Create a directory to store genesis + $genesis = new Genesis($file); - $genesis = new Genesis($ownerView, $path, $file->getOwner()); - + list($ownerView, $path) = $file->getOwnerViewAndPath(); $oldSession = new Db_Session(); $oldSession->loadBy('file_id', $file->getFileId()); @@ -65,10 +63,8 @@ class Db_Session extends \OCA\Documents\Db { ->loadBy('file_id', $file->getFileId()) ->getData() ; - $session['title'] = basename($path); $memberColor = Helper::getMemberColor($uid); - $member = new Db_Member(array( $session['es_id'], $uid, @@ -100,8 +96,7 @@ class Db_Session extends \OCA\Documents\Db { throw new \Exception('Failed to add member into database'); } - - + $session['title'] = basename($path); $session['permissions'] = $ownerView->getFilePermissions($path); return $session; diff --git a/lib/genesis.php b/lib/genesis.php index c038d699..02c047b5 100644 --- a/lib/genesis.php +++ b/lib/genesis.php @@ -35,11 +35,12 @@ class Genesis { /** * Create new genesis document - * @param OCA\Documents\View $view Filesystem view with root '/user/files' - * @param string $path relative path - * @param string $owner file owner + * @param OCA\Documents\File $file * */ - public function __construct(\OCA\Documents\View $view, $path, $owner){ + public function __construct(\OCA\Documents\File $file){ + $owner = $file->getOwner(); + list($ownerView, $path) = $file->getOwnerViewAndPath(); + $this->view = new View('/' . $owner); if (!$this->view->file_exists(self::DOCUMENTS_DIRNAME)){