fix sorting

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
Arthur Schiwon 2017-10-26 16:23:41 +02:00
parent aa2fd30775
commit 7f58c41015
No known key found for this signature in database
GPG Key ID: 7424F1874854DF23
4 changed files with 17 additions and 5 deletions

View File

@ -19,6 +19,7 @@ return array(
'OCA\\Files_Sharing\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php',
'OCA\\Files_Sharing\\Cache' => $baseDir . '/../lib/Cache.php',
'OCA\\Files_Sharing\\Capabilities' => $baseDir . '/../lib/Capabilities.php',
'OCA\\Files_Sharing\\Collaboration\\ShareRecipientSorter' => $baseDir . '/../lib/Collaboration/ShareRecipientSorter.php',
'OCA\\Files_Sharing\\Command\\CleanupRemoteStorages' => $baseDir . '/../lib/Command/CleanupRemoteStorages.php',
'OCA\\Files_Sharing\\Controller\\ExternalSharesController' => $baseDir . '/../lib/Controller/ExternalSharesController.php',
'OCA\\Files_Sharing\\Controller\\PublicPreviewController' => $baseDir . '/../lib/Controller/PublicPreviewController.php',

View File

@ -34,6 +34,7 @@ class ComposerStaticInitf32f03f7cd82bff20d6a51be16689441
'OCA\\Files_Sharing\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php',
'OCA\\Files_Sharing\\Cache' => __DIR__ . '/..' . '/../lib/Cache.php',
'OCA\\Files_Sharing\\Capabilities' => __DIR__ . '/..' . '/../lib/Capabilities.php',
'OCA\\Files_Sharing\\Collaboration\\ShareRecipientSorter' => __DIR__ . '/..' . '/../lib/Collaboration/ShareRecipientSorter.php',
'OCA\\Files_Sharing\\Command\\CleanupRemoteStorages' => __DIR__ . '/..' . '/../lib/Command/CleanupRemoteStorages.php',
'OCA\\Files_Sharing\\Controller\\ExternalSharesController' => __DIR__ . '/..' . '/../lib/Controller/ExternalSharesController.php',
'OCA\\Files_Sharing\\Controller\\PublicPreviewController' => __DIR__ . '/..' . '/../lib/Controller/PublicPreviewController.php',

View File

@ -26,7 +26,9 @@ namespace OCA\Files_Sharing\Collaboration;
use OCP\Collaboration\AutoComplete\ISorter;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Files\Node;
use OCP\IUserSession;
use OCP\Share\IManager;
class ShareRecipientSorter implements ISorter {
@ -34,11 +36,14 @@ class ShareRecipientSorter implements ISorter {
/** @var IManager */
private $shareManager;
/** @var Folder */
private $userFolder;
private $rootFolder;
/** @var IUserSession */
private $userSession;
public function __construct(IManager $shareManager, Folder $userFolder) {
public function __construct(IManager $shareManager, IRootFolder $rootFolder, IUserSession $userSession) {
$this->shareManager = $shareManager;
$this->userFolder = $userFolder;
$this->rootFolder = $rootFolder;
$this->userSession = $userSession;
}
public function getId() {
@ -51,7 +56,12 @@ class ShareRecipientSorter implements ISorter {
return;
}
/** @var Node[] $nodes */
$nodes = $this->userFolder->getById((int)$context['itemId']);
$user = $this->userSession->getUser();
if($user === null) {
return;
}
$userFolder = $this->rootFolder->getUserFolder($user->getUID());
$nodes = $userFolder->getById((int)$context['itemId']);
if(count($nodes) === 0) {
return;
}

View File

@ -54,7 +54,7 @@ class Manager implements IManager {
}
public function registerSorter($className) {
$sorters[] = $className;
$this->sorters[] = $className;
}
protected function getSorters() {