Pass file instance to genesys

This commit is contained in:
Victor Dubiniuk 2014-04-10 19:53:56 +03:00
parent 461c3ef999
commit a3cc3b3ce3
2 changed files with 8 additions and 12 deletions

View File

@ -38,12 +38,10 @@ class Db_Session extends \OCA\Documents\Db {
public static function start($uid, $fileId, $isGuest){ public static function start($uid, $fileId, $isGuest){
$file = new File($fileId); $file = new File($fileId);
list($ownerView, $path) = $file->getOwnerViewAndPath();
// Create a directory to store genesis // 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 = new Db_Session();
$oldSession->loadBy('file_id', $file->getFileId()); $oldSession->loadBy('file_id', $file->getFileId());
@ -65,10 +63,8 @@ class Db_Session extends \OCA\Documents\Db {
->loadBy('file_id', $file->getFileId()) ->loadBy('file_id', $file->getFileId())
->getData() ->getData()
; ;
$session['title'] = basename($path);
$memberColor = Helper::getMemberColor($uid); $memberColor = Helper::getMemberColor($uid);
$member = new Db_Member(array( $member = new Db_Member(array(
$session['es_id'], $session['es_id'],
$uid, $uid,
@ -100,8 +96,7 @@ class Db_Session extends \OCA\Documents\Db {
throw new \Exception('Failed to add member into database'); throw new \Exception('Failed to add member into database');
} }
$session['title'] = basename($path);
$session['permissions'] = $ownerView->getFilePermissions($path); $session['permissions'] = $ownerView->getFilePermissions($path);
return $session; return $session;

View File

@ -35,11 +35,12 @@ class Genesis {
/** /**
* Create new genesis document * Create new genesis document
* @param OCA\Documents\View $view Filesystem view with root '/user/files' * @param OCA\Documents\File $file
* @param string $path relative path
* @param string $owner file owner
* */ * */
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); $this->view = new View('/' . $owner);
if (!$this->view->file_exists(self::DOCUMENTS_DIRNAME)){ if (!$this->view->file_exists(self::DOCUMENTS_DIRNAME)){