Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
69b530a
Basic implementation of resource and collection handling
nickvergessen Sep 14, 2018
65a9ab4
Add a controller with the most important methods
nickvergessen Oct 16, 2018
136d2c3
Provider functionality
nickvergessen Oct 17, 2018
5dfc56e
Allow to create collections
nickvergessen Oct 18, 2018
702dcfb
Make names mandatory
nickvergessen Oct 24, 2018
ab4b293
Insert new collection into database
juliusknorr Oct 29, 2018
d6aae43
Move files_sharing to webpack
juliusknorr Jan 17, 2019
322f7c3
Add vue app for collaboration resources
juliusknorr Jan 17, 2019
a72a6d7
Adjust parameter names on createCollectionOnResource
juliusknorr Jan 22, 2019
7a4b2db
Add javascript API for collaboration resources
juliusknorr Oct 22, 2018
51057c5
Use proper public javascript methods
juliusknorr Jan 23, 2019
7843b8b
Adjust OCP.Collaboration
juliusknorr Jan 23, 2019
555afff
Make sure we query the node before fetching the name
juliusknorr Jan 23, 2019
88aa3de
Add iconClass to resources
juliusknorr Jan 23, 2019
d85e3e3
Allow apps to register resource providers
juliusknorr Jan 24, 2019
506eb88
Only call resource provider if type matches
juliusknorr Jan 24, 2019
3777df6
Add link to resource provider
juliusknorr Jan 24, 2019
53ac9bd
Implement frontend for search/rename
juliusknorr Jan 29, 2019
e404ce7
Implement search and rename in backend
juliusknorr Jan 29, 2019
d1a4856
Add eslint settings and reorganize files
juliusknorr Jan 31, 2019
31340b8
Add icon for resource type and icons for folder/file
juliusknorr Jan 31, 2019
dee6f7f
Fix doc blocks
nickvergessen Feb 7, 2019
ece471d
Start implementing access cache
nickvergessen Feb 7, 2019
59c92a7
Further work on the access cache
nickvergessen Feb 11, 2019
a8a5472
Improve searchCollections()
nickvergessen Feb 11, 2019
c8c59e6
Make sure the results are always sorted the same
nickvergessen Feb 11, 2019
103298e
Use icon-close to remove resources
juliusknorr Feb 14, 2019
fd434da
Fix SQL statement and provider method call
juliusknorr Feb 16, 2019
cab704f
Merge webpack into main one
juliusknorr Feb 20, 2019
7207a77
Use nextcloud-vue-collections library
juliusknorr Feb 21, 2019
43c8d0c
Add default value, because null does not trigger unique-key
nickvergessen Feb 22, 2019
eecd932
Also check the access to collections on preparing
nickvergessen Feb 22, 2019
995cad0
Cache the access manually too
nickvergessen Feb 22, 2019
901f1d4
Don't throw on UniqueConstraintViolationException since a written val…
nickvergessen Feb 22, 2019
30dff37
Add invalidation methods to the interface
nickvergessen Feb 22, 2019
1a73cab
Fix doc block
nickvergessen Feb 22, 2019
066238a
Fix unused variable $access
nickvergessen Feb 22, 2019
4113505
Also cache the resource type because it is part of the identifier
nickvergessen Feb 22, 2019
55ae7fa
Invalidate the cache when a share is updated
nickvergessen Feb 22, 2019
01b4db6
Add dispatcher events to User and Group objects
nickvergessen Feb 22, 2019
752276f
Add a listener for the events
nickvergessen Feb 22, 2019
fdfe984
Register providers via class names
nickvergessen Feb 22, 2019
1c4436d
Access for a collection can only become true
nickvergessen Feb 22, 2019
55cd9ea
Update autoloader
nickvergessen Feb 22, 2019
37e6488
Use nextcloud-vue-collection 0.1.2
juliusknorr Feb 22, 2019
ba2b542
Listen to IUser::postDelete
juliusknorr Feb 24, 2019
6ee7286
Fix tests
juliusknorr Feb 24, 2019
c778032
Properly handle null as ownerId if file system access is denied by ac…
juliusknorr Feb 24, 2019
e5162fb
Fix tests
juliusknorr Feb 24, 2019
f0e50bc
Fetch node and filename also if access cache was used
juliusknorr Feb 24, 2019
0c32b21
Fix files_external tests
nickvergessen Feb 25, 2019
48f34b8
Add bundled files
juliusknorr Feb 21, 2019
ca0624d
Remove unneeded files
juliusknorr Mar 1, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/files/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
'OCA\\Files\\BackgroundJob\\DeleteOrphanedItems' => $baseDir . '/../lib/BackgroundJob/DeleteOrphanedItems.php',
'OCA\\Files\\BackgroundJob\\ScanFiles' => $baseDir . '/../lib/BackgroundJob/ScanFiles.php',
'OCA\\Files\\Capabilities' => $baseDir . '/../lib/Capabilities.php',
'OCA\\Files\\Collaboration\\Resources\\Listener' => $baseDir . '/../lib/Collaboration/Resources/Listener.php',
'OCA\\Files\\Collaboration\\Resources\\ResourceProvider' => $baseDir . '/../lib/Collaboration/Resources/ResourceProvider.php',
'OCA\\Files\\Command\\DeleteOrphanedFiles' => $baseDir . '/../lib/Command/DeleteOrphanedFiles.php',
'OCA\\Files\\Command\\Scan' => $baseDir . '/../lib/Command/Scan.php',
'OCA\\Files\\Command\\ScanAppData' => $baseDir . '/../lib/Command/ScanAppData.php',
Expand Down
2 changes: 2 additions & 0 deletions apps/files/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class ComposerStaticInitFiles
'OCA\\Files\\BackgroundJob\\DeleteOrphanedItems' => __DIR__ . '/..' . '/../lib/BackgroundJob/DeleteOrphanedItems.php',
'OCA\\Files\\BackgroundJob\\ScanFiles' => __DIR__ . '/..' . '/../lib/BackgroundJob/ScanFiles.php',
'OCA\\Files\\Capabilities' => __DIR__ . '/..' . '/../lib/Capabilities.php',
'OCA\\Files\\Collaboration\\Resources\\Listener' => __DIR__ . '/..' . '/../lib/Collaboration/Resources/Listener.php',
'OCA\\Files\\Collaboration\\Resources\\ResourceProvider' => __DIR__ . '/..' . '/../lib/Collaboration/Resources/ResourceProvider.php',
'OCA\\Files\\Command\\DeleteOrphanedFiles' => __DIR__ . '/..' . '/../lib/Command/DeleteOrphanedFiles.php',
'OCA\\Files\\Command\\Scan' => __DIR__ . '/..' . '/../lib/Command/Scan.php',
'OCA\\Files\\Command\\ScanAppData' => __DIR__ . '/..' . '/../lib/Command/ScanAppData.php',
Expand Down
11 changes: 11 additions & 0 deletions apps/files/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@
namespace OCA\Files\AppInfo;

use OCA\Files\Activity\Helper;
use OCA\Files\Collaboration\Resources\Listener;
use OCA\Files\Collaboration\Resources\ResourceProvider;
use OCA\Files\Controller\ApiController;
use OCP\AppFramework\App;
use \OCA\Files\Service\TagService;
use OCP\Collaboration\Resources\IManager;
use \OCP\IContainer;
use OCA\Files\Controller\ViewController;
use OCA\Files\Capabilities;
Expand Down Expand Up @@ -99,5 +102,13 @@ public function __construct(array $urlParams=array()) {
* Register capabilities
*/
$container->registerCapability(Capabilities::class);

/**
* Register Collaboration ResourceProvider
*/
/** @var IManager $resourceManager */
$resourceManager = $container->query(IManager::class);
$resourceManager->registerResourceProvider(ResourceProvider::class);
Listener::register($server->getEventDispatcher());
}
}
44 changes: 44 additions & 0 deletions apps/files/lib/Collaboration/Resources/Listener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2019 Joas Schilling <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

namespace OCA\Files\Collaboration\Resources;


use OCP\Collaboration\Resources\IManager;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

class Listener {
public static function register(EventDispatcherInterface $dispatcher): void {
$dispatcher->addListener('OCP\Share::postShare', [self::class, 'shareModification']);
$dispatcher->addListener('OCP\Share::postUnshare', [self::class, 'shareModification']);
$dispatcher->addListener('OCP\Share::postUnshareFromSelf', [self::class, 'shareModification']);
}

public static function shareModification(): void {
/** @var IManager $resourceManager */
$resourceManager = \OC::$server->query(IManager::class);
/** @var ResourceProvider $resourceProvider */
$resourceProvider = \OC::$server->query(ResourceProvider::class);

$resourceManager->invalidateAccessCacheForProvider($resourceProvider);
}
}
140 changes: 140 additions & 0 deletions apps/files/lib/Collaboration/Resources/ResourceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<?php
/**
* @copyright Copyright (c) 2018 Joas Schilling <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

namespace OCA\Files\Collaboration\Resources;


use OCP\Collaboration\Resources\IProvider;
use OCP\Collaboration\Resources\IResource;
use OCP\Collaboration\Resources\ResourceException;
use OCP\Files\IRootFolder;
use OCP\Files\Node;
use OCP\IURLGenerator;
use OCP\IUser;

class ResourceProvider implements IProvider {

const RESOURCE_TYPE = 'files';

/** @var IRootFolder */
protected $rootFolder;

/** @var IURLGenerator */
private $urlGenerator;

/** @var array */
protected $nodes = [];

public function __construct(IRootFolder $rootFolder, IURLGenerator $urlGenerator) {
$this->rootFolder = $rootFolder;
$this->urlGenerator = $urlGenerator;
}

private function getNode(IResource $resource): ?Node {
if (isset($this->nodes[(int) $resource->getId()])) {
return $this->nodes[(int) $resource->getId()];
}
$nodes = $this->rootFolder->getById((int) $resource->getId());
if (!empty($nodes)) {
$this->nodes[(int) $resource->getId()] = array_shift($nodes);
return $this->nodes[(int) $resource->getId()];
}
return null;
}

/**
* Get the display name of a resource
*
* @param IResource $resource
* @return string
* @since 15.0.0
*/
public function getName(IResource $resource): string {
if (isset($this->nodes[(int) $resource->getId()])) {
return $this->nodes[(int) $resource->getId()]->getPath();
}
$node = $this->getNode($resource);
if ($node) {
return $node->getName();
}
return '';
}

/**
* Can a user/guest access the collection
*
* @param IResource $resource
* @param IUser $user
* @return bool
* @since 15.0.0
*/
public function canAccessResource(IResource $resource, IUser $user = null): bool {
if (!$user instanceof IUser) {
return false;
}

$userFolder = $this->rootFolder->getUserFolder($user->getUID());
$nodes = $userFolder->getById((int) $resource->getId());

if (!empty($nodes)) {
$this->nodes[(int) $resource->getId()] = array_shift($nodes);
return true;
}

return false;
}

/**
* Get the icon class of a resource
*
* @param IResource $resource
* @return string
* @since 15.0.0
*/
public function getIconClass(IResource $resource): string {
$node = $this->getNode($resource);
if ($node && $node->getMimetype() === 'httpd/unix-directory') {
return 'icon-files-dark';
}
return 'icon-filetype-file';
}

/**
* Get the resource type of the provider
*
* @return string
* @since 15.0.0
*/
public function getType(): string {
return self::RESOURCE_TYPE;
}

/**
* Get the link to a resource
*
* @param IResource $resource
* @return string
* @since 15.0.0
*/
public function getLink(IResource $resource): string {
return $this->urlGenerator->linkToRoute('files.viewcontroller.showFile', ['fileid' => $resource->getId()]);
}
}
4 changes: 2 additions & 2 deletions apps/files/tests/Service/TagServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use OC\Tags;
use OCA\Files\Service\TagService;
use OCP\Activity\IManager;
use OCP\IUser;
use OCP\IUserSession;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

Expand Down Expand Up @@ -75,8 +76,7 @@ protected function setUp() {
\OC::$server->getUserManager()->createUser($this->user, 'test');
\OC_User::setUserId($this->user);
\OC_Util::setupFS($this->user);
/** @var \OCP\IUser */
$user = new \OC\User\User($this->user, null);
$user = $this->createMock(IUser::class);
/**
* @var \OCP\IUserSession
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function setUp() {

$this->globalStoragesService = $this->service;

$this->user = new \OC\User\User(self::USER_ID, null);
$this->user = new \OC\User\User(self::USER_ID, null, \OC::$server->getEventDispatcher());
/** @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject $userSession */
$userSession = $this->createMock(IUserSession::class);
$userSession
Expand Down
13 changes: 13 additions & 0 deletions apps/files_sharing/.babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {
browsers: ['last 2 versions', 'ie >= 11']
}
}
]
],
plugins: ['@babel/plugin-syntax-dynamic-import']
}
22 changes: 22 additions & 0 deletions apps/files_sharing/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = {
env: {
browser: true,
es6: true
},
globals: {
t: true,
n: true,
OC: true,
OCA: true
},
extends: 'eslint:recommended',
parserOptions: {
sourceType: 'module'
},
rules: {
indent: ['error', 'tab'],
'linebreak-style': ['error', 'unix'],
quotes: ['error', 'single'],
semi: ['error', 'always']
}
};
2 changes: 1 addition & 1 deletion apps/files_sharing/appinfo/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
$eventDispatcher->addListener(
'OCA\Files::loadAdditionalScripts',
function() {
\OCP\Util::addScript('files_sharing', 'additionalScripts');
\OCP\Util::addScript('files_sharing', 'dist/additionalScripts');
}
);

Expand Down
Loading