Remove View model. Get permissions from FileInfo
This commit is contained in:
parent
4fad41db45
commit
932684b782
@ -24,7 +24,7 @@ use \OCA\Documents\Download;
|
|||||||
use \OCA\Documents\DownloadResponse;
|
use \OCA\Documents\DownloadResponse;
|
||||||
use \OCA\Documents\File;
|
use \OCA\Documents\File;
|
||||||
use OCA\Documents\Genesis;
|
use OCA\Documents\Genesis;
|
||||||
use \OCA\Documents\View;
|
use \OC\Files\View;
|
||||||
|
|
||||||
class DocumentController extends Controller{
|
class DocumentController extends Controller{
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ class DocumentController extends Controller{
|
|||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
*/
|
*/
|
||||||
public function create(){
|
public function create(){
|
||||||
$view = new \OC\Files\View('/' . $this->uid . '/files');
|
$view = new View('/' . $this->uid . '/files');
|
||||||
$dir = $this->settings->getUserValue($this->uid, $this->appName, 'save_path', '/');
|
$dir = $this->settings->getUserValue($this->uid, $this->appName, 'save_path', '/');
|
||||||
if (!$view->is_dir($dir)){
|
if (!$view->is_dir($dir)){
|
||||||
$dir = '/';
|
$dir = '/';
|
||||||
|
@ -21,6 +21,7 @@ use \OCA\Documents\Db;
|
|||||||
use \OCA\Documents\File;
|
use \OCA\Documents\File;
|
||||||
use \OCA\Documents\Helper;
|
use \OCA\Documents\Helper;
|
||||||
use OCA\Documents\Filter;
|
use OCA\Documents\Filter;
|
||||||
|
use \OC\Files\View;
|
||||||
|
|
||||||
class BadRequestException extends \Exception {
|
class BadRequestException extends \Exception {
|
||||||
|
|
||||||
@ -264,7 +265,7 @@ class SessionController extends Controller{
|
|||||||
//File was deleted or unshared. We need to save content as new file anyway
|
//File was deleted or unshared. We need to save content as new file anyway
|
||||||
//Sorry, but for guests it would be lost :(
|
//Sorry, but for guests it would be lost :(
|
||||||
if ($this->uid){
|
if ($this->uid){
|
||||||
$view = new \OC\Files\View('/' . $this->uid . '/files');
|
$view = new View('/' . $this->uid . '/files');
|
||||||
|
|
||||||
$dir = \OCP\Config::getUserValue($this->uid, 'documents', 'save_path', '');
|
$dir = \OCP\Config::getUserValue($this->uid, 'documents', 'save_path', '');
|
||||||
$path = Helper::getNewFileName($view, $dir . 'New Document.odt');
|
$path = Helper::getNewFileName($view, $dir . 'New Document.odt');
|
||||||
|
@ -103,7 +103,8 @@ class Session extends \OCA\Documents\Db {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$sessionData['title'] = basename($path);
|
$sessionData['title'] = basename($path);
|
||||||
$sessionData['permissions'] = $ownerView->getFilePermissions($path);
|
$fileInfo = $ownerView->getFileInfo($path);
|
||||||
|
$sessionData['permissions'] = $fileInfo->getPermissions();
|
||||||
|
|
||||||
return $sessionData;
|
return $sessionData;
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ namespace OCA\Documents;
|
|||||||
|
|
||||||
use \OCP\AppFramework\Http;
|
use \OCP\AppFramework\Http;
|
||||||
use \OCP\IRequest;
|
use \OCP\IRequest;
|
||||||
|
use \OC\Files\View;
|
||||||
|
|
||||||
class DownloadResponse extends \OCP\AppFramework\Http\Response {
|
class DownloadResponse extends \OCP\AppFramework\Http\Response {
|
||||||
private $request;
|
private $request;
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
namespace OCA\Documents;
|
namespace OCA\Documents;
|
||||||
|
|
||||||
|
use \OC\Files\View;
|
||||||
|
|
||||||
class File {
|
class File {
|
||||||
protected $fileId;
|
protected $fileId;
|
||||||
protected $owner;
|
protected $owner;
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
namespace OCA\Documents;
|
namespace OCA\Documents;
|
||||||
|
|
||||||
|
use \OC\Files\View;
|
||||||
|
|
||||||
class Genesis {
|
class Genesis {
|
||||||
|
|
||||||
const DOCUMENTS_DIRNAME='/documents';
|
const DOCUMENTS_DIRNAME='/documents';
|
||||||
@ -37,7 +39,7 @@ class Genesis {
|
|||||||
* Create new genesis document
|
* Create new genesis document
|
||||||
* @param File $file
|
* @param File $file
|
||||||
* */
|
* */
|
||||||
public function __construct(\OCA\Documents\File $file){
|
public function __construct(File $file){
|
||||||
list($view, $path) = $file->getOwnerViewAndPath();
|
list($view, $path) = $file->getOwnerViewAndPath();
|
||||||
$owner = $file->getOwner();
|
$owner = $file->getOwner();
|
||||||
|
|
||||||
@ -96,7 +98,7 @@ class Genesis {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if genesis is valid
|
* Check if genesis is valid
|
||||||
* @param OCA\Documents\View $view
|
* @param \OC\Files\View $view
|
||||||
* @param string $path relative to the view
|
* @param string $path relative to the view
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
|
27
lib/view.php
27
lib/view.php
@ -1,27 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* ownCloud - Documents App
|
|
||||||
*
|
|
||||||
* @author Victor Dubiniuk
|
|
||||||
* @copyright 2013 Victor Dubiniuk victor.dubiniuk@gmail.com
|
|
||||||
*
|
|
||||||
* This file is licensed under the Affero General Public License version 3 or
|
|
||||||
* later.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace OCA\Documents;
|
|
||||||
|
|
||||||
class View extends \OC\Files\View{
|
|
||||||
|
|
||||||
public function getFilePermissions($path){
|
|
||||||
$permissions = 0;
|
|
||||||
if ($this->isReadable($path)) {
|
|
||||||
$permissions |= \OCP\PERMISSION_READ;
|
|
||||||
}
|
|
||||||
if ($this->isSharable($path)) {
|
|
||||||
$permissions |= \OCP\PERMISSION_SHARE;
|
|
||||||
}
|
|
||||||
return $permissions;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user