Move systemtags and comments to new accesslist functions

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2017-04-20 14:34:28 +02:00
parent 799b229a68
commit 4004e39f75
No known key found for this signature in database
GPG Key ID: F941078878347C0C
2 changed files with 18 additions and 14 deletions

View File

@ -31,6 +31,7 @@ use OCP\Files\Node;
use OCP\IUser; use OCP\IUser;
use OCP\IUserSession; use OCP\IUserSession;
use OCP\Share; use OCP\Share;
use OCP\Share\IShareHelper;
class Listener { class Listener {
/** @var IManager */ /** @var IManager */
@ -43,6 +44,8 @@ class Listener {
protected $mountCollection; protected $mountCollection;
/** @var \OCP\Files\IRootFolder */ /** @var \OCP\Files\IRootFolder */
protected $rootFolder; protected $rootFolder;
/** @var IShareHelper */
protected $shareHelper;
/** /**
* Listener constructor. * Listener constructor.
@ -52,17 +55,20 @@ class Listener {
* @param IAppManager $appManager * @param IAppManager $appManager
* @param IMountProviderCollection $mountCollection * @param IMountProviderCollection $mountCollection
* @param IRootFolder $rootFolder * @param IRootFolder $rootFolder
* @param IShareHelper $shareHelper
*/ */
public function __construct(IManager $activityManager, public function __construct(IManager $activityManager,
IUserSession $session, IUserSession $session,
IAppManager $appManager, IAppManager $appManager,
IMountProviderCollection $mountCollection, IMountProviderCollection $mountCollection,
IRootFolder $rootFolder) { IRootFolder $rootFolder,
IShareHelper $shareHelper) {
$this->activityManager = $activityManager; $this->activityManager = $activityManager;
$this->session = $session; $this->session = $session;
$this->appManager = $appManager; $this->appManager = $appManager;
$this->mountCollection = $mountCollection; $this->mountCollection = $mountCollection;
$this->rootFolder = $rootFolder; $this->rootFolder = $rootFolder;
$this->shareHelper = $shareHelper;
} }
/** /**
@ -91,12 +97,8 @@ class Listener {
if (!empty($nodes)) { if (!empty($nodes)) {
/** @var Node $node */ /** @var Node $node */
$node = array_shift($nodes); $node = array_shift($nodes);
$path = $node->getPath(); $al = $this->shareHelper->getPathsForAccessList($node);
if (strpos($path, '/' . $owner . '/files/') === 0) { $users = array_merge($users, $al['users']);
$path = substr($path, strlen('/' . $owner . '/files'));
}
// Get all users that have access to the mount point
$users = array_merge($users, Share::getUsersSharingFile($path, $owner, true, true));
} }
} }

View File

@ -34,6 +34,7 @@ use OCP\IGroupManager;
use OCP\IUser; use OCP\IUser;
use OCP\IUserSession; use OCP\IUserSession;
use OCP\Share; use OCP\Share;
use OCP\Share\IShareHelper;
use OCP\SystemTag\ISystemTag; use OCP\SystemTag\ISystemTag;
use OCP\SystemTag\ISystemTagManager; use OCP\SystemTag\ISystemTagManager;
use OCP\SystemTag\ManagerEvent; use OCP\SystemTag\ManagerEvent;
@ -57,6 +58,8 @@ class Listener {
protected $mountCollection; protected $mountCollection;
/** @var \OCP\Files\IRootFolder */ /** @var \OCP\Files\IRootFolder */
protected $rootFolder; protected $rootFolder;
/** @var IShareHelper */
protected $shareHelper;
/** /**
* Listener constructor. * Listener constructor.
@ -69,6 +72,7 @@ class Listener {
* @param IAppManager $appManager * @param IAppManager $appManager
* @param IMountProviderCollection $mountCollection * @param IMountProviderCollection $mountCollection
* @param IRootFolder $rootFolder * @param IRootFolder $rootFolder
* @param IShareHelper $shareHelper
*/ */
public function __construct(IGroupManager $groupManager, public function __construct(IGroupManager $groupManager,
IManager $activityManager, IManager $activityManager,
@ -77,7 +81,8 @@ class Listener {
ISystemTagManager $tagManager, ISystemTagManager $tagManager,
IAppManager $appManager, IAppManager $appManager,
IMountProviderCollection $mountCollection, IMountProviderCollection $mountCollection,
IRootFolder $rootFolder) { IRootFolder $rootFolder,
IShareHelper $shareHelper) {
$this->groupManager = $groupManager; $this->groupManager = $groupManager;
$this->activityManager = $activityManager; $this->activityManager = $activityManager;
$this->session = $session; $this->session = $session;
@ -86,6 +91,7 @@ class Listener {
$this->appManager = $appManager; $this->appManager = $appManager;
$this->mountCollection = $mountCollection; $this->mountCollection = $mountCollection;
$this->rootFolder = $rootFolder; $this->rootFolder = $rootFolder;
$this->shareHelper = $shareHelper;
} }
/** /**
@ -177,12 +183,8 @@ class Listener {
if (!empty($nodes)) { if (!empty($nodes)) {
/** @var Node $node */ /** @var Node $node */
$node = array_shift($nodes); $node = array_shift($nodes);
$path = $node->getPath(); $al = $this->shareHelper->getPathsForAccessList($node);
if (strpos($path, '/' . $owner . '/files/') === 0) { $users = array_merge($users, $al['users']);
$path = substr($path, strlen('/' . $owner . '/files'));
}
// Get all users that have access to the mount point
$users = array_merge($users, Share::getUsersSharingFile($path, $owner, true, true));
} }
} }