Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2019-11-13 14:28:23 +0300
committerArthur Schiwon <blizzz@arthur-schiwon.de>2020-01-22 14:01:10 +0300
commit54d9df26813aeb62cba4f95a9c77973d7fcd2187 (patch)
tree1b20a8730fbb3ee0536cfa042aac6c7a4769cc3d /apps
parent0172fb7aadfde7b808c8c149ec5949451bc6aa89 (diff)
extend with group deletion handling
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps')
-rw-r--r--apps/files_external/lib/AppInfo/Application.php11
-rw-r--r--apps/files_external/lib/Service/DBConfigService.php20
2 files changed, 25 insertions, 6 deletions
diff --git a/apps/files_external/lib/AppInfo/Application.php b/apps/files_external/lib/AppInfo/Application.php
index 07a669fcd94..25f94b3b2eb 100644
--- a/apps/files_external/lib/AppInfo/Application.php
+++ b/apps/files_external/lib/AppInfo/Application.php
@@ -63,6 +63,7 @@ use OCA\Files_External\Lib\Backend\DAV;
use OCA\Files_External\Lib\Backend\FTP;
use OCA\Files_External\Lib\Backend\Local;
use OCP\Files\Config\IUserMountCache;
+use OCP\IGroup;
use OCP\IUser;
use Symfony\Component\EventDispatcher\GenericEvent;
@@ -110,6 +111,16 @@ class Application extends App implements IBackendProvider, IAuthMechanismProvide
$config->modifyMountsOnUserDelete($user->getUID());
}
);
+ $dispatcher->addListener(
+ IGroup::class . '::postDelete',
+ function (GenericEvent $event) {
+ /** @var IGroup $group */
+ $group = $event->getSubject();
+ /** @var DBConfigService $config */
+ $config = $this->getContainer()->query(DBConfigService::class);
+ $config->modifyMountsOnGroupDelete($group->getGID());
+ }
+ );
}
/**
diff --git a/apps/files_external/lib/Service/DBConfigService.php b/apps/files_external/lib/Service/DBConfigService.php
index 0d8d048fc1d..9394924d396 100644
--- a/apps/files_external/lib/Service/DBConfigService.php
+++ b/apps/files_external/lib/Service/DBConfigService.php
@@ -114,15 +114,23 @@ class DBConfigService {
return $this->getMountsFromQuery($query);
}
- public function modifyMountsOnUserDelete(string $uid) {
+ public function modifyMountsOnUserDelete(string $uid): void {
+ $this->modifyMountsOnDelete($uid, self::APPLICABLE_TYPE_USER);
+ }
+
+ public function modifyMountsOnGroupDelete(string $gid): void {
+ $this->modifyMountsOnDelete($gid, self::APPLICABLE_TYPE_GROUP);
+ }
+
+ protected function modifyMountsOnDelete(string $applicableId, int $applicableType): void {
$builder = $this->connection->getQueryBuilder();
$query = $builder->select(['a.mount_id', $builder->func()->count('a.mount_id', 'count')])
->from('external_applicable', 'a')
->rightJoin('a', 'external_applicable', 'b', $builder->expr()->eq('a.mount_id', 'b.mount_id'))
- ->where($builder->expr()->andX( // mounts for user
- $builder->expr()->eq('a.type', $builder->createNamedParameter(self::APPLICABLE_TYPE_USER, IQueryBuilder::PARAM_INT)),
- $builder->expr()->eq('a.value', $builder->createNamedParameter($uid))
- )
+ ->where($builder->expr()->andX(
+ $builder->expr()->eq('a.type', $builder->createNamedParameter($applicableType, IQueryBuilder::PARAM_INT)),
+ $builder->expr()->eq('a.value', $builder->createNamedParameter($applicableId))
+ )
)
->groupBy(['a.mount_id']);
$stmt = $query->execute();
@@ -131,7 +139,7 @@ class DBConfigService {
foreach ($result as $row) {
if((int)$row['count'] > 1) {
- $this->removeApplicable($row['mount_id'], self::APPLICABLE_TYPE_USER, $uid);
+ $this->removeApplicable($row['mount_id'], $applicableType, $applicableId);
} else {
$this->removeMount($row['mount_id']);
}