diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2019-11-12 23:53:33 +0100 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2019-11-28 17:03:33 +0100 |
commit | be85d00a386dfc8c60f413e7000009237855ce7e (patch) | |
tree | 5390a23a6d71e6021672e188b85dfbdf4e224876 /apps/files_external/lib/Service | |
parent | 6b97f6af48ba8dc029e616cf778a1cbcd0fea001 (diff) | |
download | nextcloud-server-be85d00a386dfc8c60f413e7000009237855ce7e.tar.gz nextcloud-server-be85d00a386dfc8c60f413e7000009237855ce7e.zip |
when a user was delete remove them from applicable list, unless
it is the only user, then remove the mount
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/files_external/lib/Service')
-rw-r--r-- | apps/files_external/lib/Service/DBConfigService.php | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/apps/files_external/lib/Service/DBConfigService.php b/apps/files_external/lib/Service/DBConfigService.php index 65995b21cc4..0d8d048fc1d 100644 --- a/apps/files_external/lib/Service/DBConfigService.php +++ b/apps/files_external/lib/Service/DBConfigService.php @@ -114,6 +114,30 @@ class DBConfigService { return $this->getMountsFromQuery($query); } + public function modifyMountsOnUserDelete(string $uid) { + $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)) + ) + ) + ->groupBy(['a.mount_id']); + $stmt = $query->execute(); + $result = $stmt->fetchAll(); + $stmt->closeCursor(); + + foreach ($result as $row) { + if((int)$row['count'] > 1) { + $this->removeApplicable($row['mount_id'], self::APPLICABLE_TYPE_USER, $uid); + } else { + $this->removeMount($row['mount_id']); + } + } + } + /** * Get admin defined mounts * |