Completed
Push — master ( e67f8e...cddd66 )
by
unknown
29:25
created
core/templates/loginflowv2/authpicker.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
 	<h2><?php p($l->t('Connect to your account')) ?></h2>
31 31
 	<p class="info">
32 32
 		<?php print_unescaped($l->t('Please log in before granting %1$s access to your %2$s account.', [
33
-			'<strong>' . \OCP\Util::sanitizeHTML($_['client']) . '</strong>',
33
+			'<strong>'.\OCP\Util::sanitizeHTML($_['client']).'</strong>',
34 34
 			\OCP\Util::sanitizeHTML($_['instanceName'])
35 35
 		])) ?>
36 36
 	</p>
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -31,9 +31,9 @@
 block discarded – undo
31 31
 	<h2><?php p($l->t('Connect to your account')) ?></h2>
32 32
 	<p class="info">
33 33
 		<?php print_unescaped($l->t('Please log in before granting %1$s access to your %2$s account.', [
34
-			'<strong>' . \OCP\Util::sanitizeHTML($_['client']) . '</strong>',
35
-			\OCP\Util::sanitizeHTML($_['instanceName'])
36
-		])) ?>
34
+            '<strong>' . \OCP\Util::sanitizeHTML($_['client']) . '</strong>',
35
+            \OCP\Util::sanitizeHTML($_['instanceName'])
36
+        ])) ?>
37 37
 	</p>
38 38
 
39 39
 	<div class="notecard warning">
Please login to merge, or discard this patch.
apps/files_trashbin/lib/Sabre/TrashFolderFile.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
 namespace OCA\Files_Trashbin\Sabre;
29 29
 
30 30
 class TrashFolderFile extends AbstractTrashFile {
31
-	public function get() {
32
-		return $this->data->getStorage()->fopen($this->data->getInternalPath(), 'rb');
33
-	}
31
+    public function get() {
32
+        return $this->data->getStorage()->fopen($this->data->getInternalPath(), 'rb');
33
+    }
34 34
 }
Please login to merge, or discard this patch.
lib/private/Authentication/Token/INamedToken.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -28,11 +28,11 @@
 block discarded – undo
28 28
 namespace OC\Authentication\Token;
29 29
 
30 30
 interface INamedToken extends IToken {
31
-	/**
32
-	 * Set token name
33
-	 *
34
-	 * @param string $name
35
-	 * @return void
36
-	 */
37
-	public function setName(string $name): void;
31
+    /**
32
+     * Set token name
33
+     *
34
+     * @param string $name
35
+     * @return void
36
+     */
37
+    public function setName(string $name): void;
38 38
 }
Please login to merge, or discard this patch.
apps/twofactor_backupcodes/lib/Provider/BackupCodesProvider.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -143,7 +143,7 @@
 block discarded – undo
143 143
 	 * @return boolean
144 144
 	 */
145 145
 	public function isActive(IUser $user): bool {
146
-		$appIds = array_filter($this->appManager->getEnabledAppsForUser($user), function ($appId) {
146
+		$appIds = array_filter($this->appManager->getEnabledAppsForUser($user), function($appId) {
147 147
 			return $appId !== $this->appName;
148 148
 		});
149 149
 		foreach ($appIds as $appId) {
Please login to merge, or discard this patch.
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -21,110 +21,110 @@
 block discarded – undo
21 21
 use OCP\Template\ITemplateManager;
22 22
 
23 23
 class BackupCodesProvider implements IDeactivatableByAdmin, IProvidesPersonalSettings {
24
-	public function __construct(
25
-		private string $appName,
26
-		private BackupCodeStorage $storage,
27
-		private IL10N $l10n,
28
-		private AppManager $appManager,
29
-		private IInitialState $initialState,
30
-		private ITemplateManager $templateManager,
31
-	) {
32
-	}
24
+    public function __construct(
25
+        private string $appName,
26
+        private BackupCodeStorage $storage,
27
+        private IL10N $l10n,
28
+        private AppManager $appManager,
29
+        private IInitialState $initialState,
30
+        private ITemplateManager $templateManager,
31
+    ) {
32
+    }
33 33
 
34
-	/**
35
-	 * Get unique identifier of this 2FA provider
36
-	 *
37
-	 * @return string
38
-	 */
39
-	public function getId(): string {
40
-		return 'backup_codes';
41
-	}
34
+    /**
35
+     * Get unique identifier of this 2FA provider
36
+     *
37
+     * @return string
38
+     */
39
+    public function getId(): string {
40
+        return 'backup_codes';
41
+    }
42 42
 
43
-	/**
44
-	 * Get the display name for selecting the 2FA provider
45
-	 *
46
-	 * @return string
47
-	 */
48
-	public function getDisplayName(): string {
49
-		return $this->l10n->t('Backup code');
50
-	}
43
+    /**
44
+     * Get the display name for selecting the 2FA provider
45
+     *
46
+     * @return string
47
+     */
48
+    public function getDisplayName(): string {
49
+        return $this->l10n->t('Backup code');
50
+    }
51 51
 
52
-	/**
53
-	 * Get the description for selecting the 2FA provider
54
-	 *
55
-	 * @return string
56
-	 */
57
-	public function getDescription(): string {
58
-		return $this->l10n->t('Use backup code');
59
-	}
52
+    /**
53
+     * Get the description for selecting the 2FA provider
54
+     *
55
+     * @return string
56
+     */
57
+    public function getDescription(): string {
58
+        return $this->l10n->t('Use backup code');
59
+    }
60 60
 
61
-	/**
62
-	 * Get the template for rending the 2FA provider view
63
-	 *
64
-	 * @param IUser $user
65
-	 * @return ITemplate
66
-	 */
67
-	public function getTemplate(IUser $user): ITemplate {
68
-		return $this->templateManager->getTemplate('twofactor_backupcodes', 'challenge');
69
-	}
61
+    /**
62
+     * Get the template for rending the 2FA provider view
63
+     *
64
+     * @param IUser $user
65
+     * @return ITemplate
66
+     */
67
+    public function getTemplate(IUser $user): ITemplate {
68
+        return $this->templateManager->getTemplate('twofactor_backupcodes', 'challenge');
69
+    }
70 70
 
71
-	/**
72
-	 * Verify the given challenge
73
-	 *
74
-	 * @param IUser $user
75
-	 * @param string $challenge
76
-	 * @return bool
77
-	 */
78
-	public function verifyChallenge(IUser $user, string $challenge): bool {
79
-		return $this->storage->validateCode($user, $challenge);
80
-	}
71
+    /**
72
+     * Verify the given challenge
73
+     *
74
+     * @param IUser $user
75
+     * @param string $challenge
76
+     * @return bool
77
+     */
78
+    public function verifyChallenge(IUser $user, string $challenge): bool {
79
+        return $this->storage->validateCode($user, $challenge);
80
+    }
81 81
 
82
-	/**
83
-	 * Decides whether 2FA is enabled for the given user
84
-	 *
85
-	 * @param IUser $user
86
-	 * @return boolean
87
-	 */
88
-	public function isTwoFactorAuthEnabledForUser(IUser $user): bool {
89
-		return $this->storage->hasBackupCodes($user);
90
-	}
82
+    /**
83
+     * Decides whether 2FA is enabled for the given user
84
+     *
85
+     * @param IUser $user
86
+     * @return boolean
87
+     */
88
+    public function isTwoFactorAuthEnabledForUser(IUser $user): bool {
89
+        return $this->storage->hasBackupCodes($user);
90
+    }
91 91
 
92
-	/**
93
-	 * Determine whether backup codes should be active or not
94
-	 *
95
-	 * Backup codes only make sense if at least one 2FA provider is active,
96
-	 * hence this method checks all enabled apps on whether they provide 2FA
97
-	 * functionality or not. If there's at least one app, backup codes are
98
-	 * enabled on the personal settings page.
99
-	 *
100
-	 * @param IUser $user
101
-	 * @return boolean
102
-	 */
103
-	public function isActive(IUser $user): bool {
104
-		$appIds = array_filter($this->appManager->getEnabledAppsForUser($user), function ($appId) {
105
-			return $appId !== $this->appName;
106
-		});
107
-		foreach ($appIds as $appId) {
108
-			$info = $this->appManager->getAppInfo($appId);
109
-			if (isset($info['two-factor-providers']) && count($info['two-factor-providers']) > 0) {
110
-				return true;
111
-			}
112
-		}
113
-		return false;
114
-	}
92
+    /**
93
+     * Determine whether backup codes should be active or not
94
+     *
95
+     * Backup codes only make sense if at least one 2FA provider is active,
96
+     * hence this method checks all enabled apps on whether they provide 2FA
97
+     * functionality or not. If there's at least one app, backup codes are
98
+     * enabled on the personal settings page.
99
+     *
100
+     * @param IUser $user
101
+     * @return boolean
102
+     */
103
+    public function isActive(IUser $user): bool {
104
+        $appIds = array_filter($this->appManager->getEnabledAppsForUser($user), function ($appId) {
105
+            return $appId !== $this->appName;
106
+        });
107
+        foreach ($appIds as $appId) {
108
+            $info = $this->appManager->getAppInfo($appId);
109
+            if (isset($info['two-factor-providers']) && count($info['two-factor-providers']) > 0) {
110
+                return true;
111
+            }
112
+        }
113
+        return false;
114
+    }
115 115
 
116
-	/**
117
-	 * @param IUser $user
118
-	 *
119
-	 * @return IPersonalProviderSettings
120
-	 */
121
-	public function getPersonalSettings(IUser $user): IPersonalProviderSettings {
122
-		$state = $this->storage->getBackupCodesState($user);
123
-		$this->initialState->provideInitialState('state', $state);
124
-		return new Personal();
125
-	}
116
+    /**
117
+     * @param IUser $user
118
+     *
119
+     * @return IPersonalProviderSettings
120
+     */
121
+    public function getPersonalSettings(IUser $user): IPersonalProviderSettings {
122
+        $state = $this->storage->getBackupCodesState($user);
123
+        $this->initialState->provideInitialState('state', $state);
124
+        return new Personal();
125
+    }
126 126
 
127
-	public function disableFor(IUser $user): void {
128
-		$this->storage->deleteCodes($user);
129
-	}
127
+    public function disableFor(IUser $user): void {
128
+        $this->storage->deleteCodes($user);
129
+    }
130 130
 }
Please login to merge, or discard this patch.
lib/private/Authentication/TwoFactorAuth/ProviderSet.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@
 block discarded – undo
72 72
 	 * @return IProvider[]
73 73
 	 */
74 74
 	public function getPrimaryProviders(): array {
75
-		return array_filter($this->providers, function (IProvider $provider) {
75
+		return array_filter($this->providers, function(IProvider $provider) {
76 76
 			return !($provider instanceof BackupCodesProvider);
77 77
 		});
78 78
 	}
Please login to merge, or discard this patch.
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -33,49 +33,49 @@
 block discarded – undo
33 33
  * Contains all two-factor provider information for the two-factor login challenge
34 34
  */
35 35
 class ProviderSet {
36
-	/** @var IProvider */
37
-	private $providers;
36
+    /** @var IProvider */
37
+    private $providers;
38 38
 
39
-	/** @var bool */
40
-	private $providerMissing;
39
+    /** @var bool */
40
+    private $providerMissing;
41 41
 
42
-	/**
43
-	 * @param IProvider[] $providers
44
-	 * @param bool $providerMissing
45
-	 */
46
-	public function __construct(array $providers, bool $providerMissing) {
47
-		$this->providers = [];
48
-		foreach ($providers as $provider) {
49
-			$this->providers[$provider->getId()] = $provider;
50
-		}
51
-		$this->providerMissing = $providerMissing;
52
-	}
42
+    /**
43
+     * @param IProvider[] $providers
44
+     * @param bool $providerMissing
45
+     */
46
+    public function __construct(array $providers, bool $providerMissing) {
47
+        $this->providers = [];
48
+        foreach ($providers as $provider) {
49
+            $this->providers[$provider->getId()] = $provider;
50
+        }
51
+        $this->providerMissing = $providerMissing;
52
+    }
53 53
 
54
-	/**
55
-	 * @param string $providerId
56
-	 * @return IProvider|null
57
-	 */
58
-	public function getProvider(string $providerId) {
59
-		return $this->providers[$providerId] ?? null;
60
-	}
54
+    /**
55
+     * @param string $providerId
56
+     * @return IProvider|null
57
+     */
58
+    public function getProvider(string $providerId) {
59
+        return $this->providers[$providerId] ?? null;
60
+    }
61 61
 
62
-	/**
63
-	 * @return IProvider[]
64
-	 */
65
-	public function getProviders(): array {
66
-		return $this->providers;
67
-	}
62
+    /**
63
+     * @return IProvider[]
64
+     */
65
+    public function getProviders(): array {
66
+        return $this->providers;
67
+    }
68 68
 
69
-	/**
70
-	 * @return IProvider[]
71
-	 */
72
-	public function getPrimaryProviders(): array {
73
-		return array_filter($this->providers, function (IProvider $provider) {
74
-			return !($provider instanceof BackupCodesProvider);
75
-		});
76
-	}
69
+    /**
70
+     * @return IProvider[]
71
+     */
72
+    public function getPrimaryProviders(): array {
73
+        return array_filter($this->providers, function (IProvider $provider) {
74
+            return !($provider instanceof BackupCodesProvider);
75
+        });
76
+    }
77 77
 
78
-	public function isProviderMissing(): bool {
79
-		return $this->providerMissing;
80
-	}
78
+    public function isProviderMissing(): bool {
79
+        return $this->providerMissing;
80
+    }
81 81
 }
Please login to merge, or discard this patch.
lib/private/Collaboration/Resources/Collection.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 * @since 16.0.0
127 127
 	 */
128 128
 	public function addResource(IResource $resource): void {
129
-		array_map(function (IResource $r) use ($resource) {
129
+		array_map(function(IResource $r) use ($resource) {
130 130
 			if ($this->isSameResource($r, $resource)) {
131 131
 				throw new ResourceException('Already part of the collection');
132 132
 			}
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	 * @since 16.0.0
159 159
 	 */
160 160
 	public function removeResource(IResource $resource): void {
161
-		$this->resources = array_filter($this->getResources(), function (IResource $r) use ($resource) {
161
+		$this->resources = array_filter($this->getResources(), function(IResource $r) use ($resource) {
162 162
 			return !$this->isSameResource($r, $resource);
163 163
 		});
164 164
 
Please login to merge, or discard this patch.
Indentation   +159 added lines, -159 removed lines patch added patch discarded remove patch
@@ -18,163 +18,163 @@
 block discarded – undo
18 18
 use OCP\IUser;
19 19
 
20 20
 class Collection implements ICollection {
21
-	/** @var IResource[] */
22
-	protected array $resources = [];
23
-
24
-	public function __construct(
25
-		/** @var Manager $manager */
26
-		protected IManager $manager,
27
-		protected IDBConnection $connection,
28
-		protected int $id,
29
-		protected string $name,
30
-		protected ?IUser $userForAccess = null,
31
-		protected ?bool $access = null,
32
-	) {
33
-	}
34
-
35
-	/**
36
-	 * @since 16.0.0
37
-	 */
38
-	public function getId(): int {
39
-		return $this->id;
40
-	}
41
-
42
-	/**
43
-	 * @since 16.0.0
44
-	 */
45
-	public function getName(): string {
46
-		return $this->name;
47
-	}
48
-
49
-	/**
50
-	 * @since 16.0.0
51
-	 */
52
-	public function setName(string $name): void {
53
-		$query = $this->connection->getQueryBuilder();
54
-		$query->update(Manager::TABLE_COLLECTIONS)
55
-			->set('name', $query->createNamedParameter($name))
56
-			->where($query->expr()->eq('id', $query->createNamedParameter($this->getId(), IQueryBuilder::PARAM_INT)));
57
-		$query->executeStatement();
58
-
59
-		$this->name = $name;
60
-	}
61
-
62
-	/**
63
-	 * @return IResource[]
64
-	 * @since 16.0.0
65
-	 */
66
-	public function getResources(): array {
67
-		if (empty($this->resources)) {
68
-			$this->resources = $this->manager->getResourcesByCollectionForUser($this, $this->userForAccess);
69
-		}
70
-
71
-		return $this->resources;
72
-	}
73
-
74
-	/**
75
-	 * Adds a resource to a collection
76
-	 *
77
-	 * @throws ResourceException when the resource is already part of the collection
78
-	 * @since 16.0.0
79
-	 */
80
-	public function addResource(IResource $resource): void {
81
-		array_map(function (IResource $r) use ($resource) {
82
-			if ($this->isSameResource($r, $resource)) {
83
-				throw new ResourceException('Already part of the collection');
84
-			}
85
-		}, $this->getResources());
86
-
87
-		$this->resources[] = $resource;
88
-
89
-		$query = $this->connection->getQueryBuilder();
90
-		$query->insert(Manager::TABLE_RESOURCES)
91
-			->values([
92
-				'collection_id' => $query->createNamedParameter($this->id, IQueryBuilder::PARAM_INT),
93
-				'resource_type' => $query->createNamedParameter($resource->getType()),
94
-				'resource_id' => $query->createNamedParameter($resource->getId()),
95
-			]);
96
-
97
-		try {
98
-			$query->executeStatement();
99
-		} catch (ConstraintViolationException $e) {
100
-			throw new ResourceException('Already part of the collection');
101
-		}
102
-
103
-		$this->manager->invalidateAccessCacheForCollection($this);
104
-	}
105
-
106
-	/**
107
-	 * Removes a resource from a collection
108
-	 *
109
-	 * @since 16.0.0
110
-	 */
111
-	public function removeResource(IResource $resource): void {
112
-		$this->resources = array_filter($this->getResources(), function (IResource $r) use ($resource) {
113
-			return !$this->isSameResource($r, $resource);
114
-		});
115
-
116
-		$query = $this->connection->getQueryBuilder();
117
-		$query->delete(Manager::TABLE_RESOURCES)
118
-			->where($query->expr()->eq('collection_id', $query->createNamedParameter($this->id, IQueryBuilder::PARAM_INT)))
119
-			->andWhere($query->expr()->eq('resource_type', $query->createNamedParameter($resource->getType())))
120
-			->andWhere($query->expr()->eq('resource_id', $query->createNamedParameter($resource->getId())));
121
-		$query->executeStatement();
122
-
123
-		if (empty($this->resources)) {
124
-			$this->removeCollection();
125
-		} else {
126
-			$this->manager->invalidateAccessCacheForCollection($this);
127
-		}
128
-	}
129
-
130
-	/**
131
-	 * Can a user/guest access the collection
132
-	 *
133
-	 * @since 16.0.0
134
-	 */
135
-	public function canAccess(?IUser $user): bool {
136
-		if ($user instanceof IUser) {
137
-			return $this->canUserAccess($user);
138
-		}
139
-		return $this->canGuestAccess();
140
-	}
141
-
142
-	protected function canUserAccess(IUser $user): bool {
143
-		if (\is_bool($this->access) && $this->userForAccess instanceof IUser && $user->getUID() === $this->userForAccess->getUID()) {
144
-			return $this->access;
145
-		}
146
-
147
-		$access = $this->manager->canAccessCollection($this, $user);
148
-		if ($this->userForAccess instanceof IUser && $user->getUID() === $this->userForAccess->getUID()) {
149
-			$this->access = $access;
150
-		}
151
-		return $access;
152
-	}
153
-
154
-	protected function canGuestAccess(): bool {
155
-		if (\is_bool($this->access) && !$this->userForAccess instanceof IUser) {
156
-			return $this->access;
157
-		}
158
-
159
-		$access = $this->manager->canAccessCollection($this, null);
160
-		if (!$this->userForAccess instanceof IUser) {
161
-			$this->access = $access;
162
-		}
163
-		return $access;
164
-	}
165
-
166
-	protected function isSameResource(IResource $resource1, IResource $resource2): bool {
167
-		return $resource1->getType() === $resource2->getType()
168
-			&& $resource1->getId() === $resource2->getId();
169
-	}
170
-
171
-	protected function removeCollection(): void {
172
-		$query = $this->connection->getQueryBuilder();
173
-		$query->delete(Manager::TABLE_COLLECTIONS)
174
-			->where($query->expr()->eq('id', $query->createNamedParameter($this->id, IQueryBuilder::PARAM_INT)));
175
-		$query->executeStatement();
176
-
177
-		$this->manager->invalidateAccessCacheForCollection($this);
178
-		$this->id = 0;
179
-	}
21
+    /** @var IResource[] */
22
+    protected array $resources = [];
23
+
24
+    public function __construct(
25
+        /** @var Manager $manager */
26
+        protected IManager $manager,
27
+        protected IDBConnection $connection,
28
+        protected int $id,
29
+        protected string $name,
30
+        protected ?IUser $userForAccess = null,
31
+        protected ?bool $access = null,
32
+    ) {
33
+    }
34
+
35
+    /**
36
+     * @since 16.0.0
37
+     */
38
+    public function getId(): int {
39
+        return $this->id;
40
+    }
41
+
42
+    /**
43
+     * @since 16.0.0
44
+     */
45
+    public function getName(): string {
46
+        return $this->name;
47
+    }
48
+
49
+    /**
50
+     * @since 16.0.0
51
+     */
52
+    public function setName(string $name): void {
53
+        $query = $this->connection->getQueryBuilder();
54
+        $query->update(Manager::TABLE_COLLECTIONS)
55
+            ->set('name', $query->createNamedParameter($name))
56
+            ->where($query->expr()->eq('id', $query->createNamedParameter($this->getId(), IQueryBuilder::PARAM_INT)));
57
+        $query->executeStatement();
58
+
59
+        $this->name = $name;
60
+    }
61
+
62
+    /**
63
+     * @return IResource[]
64
+     * @since 16.0.0
65
+     */
66
+    public function getResources(): array {
67
+        if (empty($this->resources)) {
68
+            $this->resources = $this->manager->getResourcesByCollectionForUser($this, $this->userForAccess);
69
+        }
70
+
71
+        return $this->resources;
72
+    }
73
+
74
+    /**
75
+     * Adds a resource to a collection
76
+     *
77
+     * @throws ResourceException when the resource is already part of the collection
78
+     * @since 16.0.0
79
+     */
80
+    public function addResource(IResource $resource): void {
81
+        array_map(function (IResource $r) use ($resource) {
82
+            if ($this->isSameResource($r, $resource)) {
83
+                throw new ResourceException('Already part of the collection');
84
+            }
85
+        }, $this->getResources());
86
+
87
+        $this->resources[] = $resource;
88
+
89
+        $query = $this->connection->getQueryBuilder();
90
+        $query->insert(Manager::TABLE_RESOURCES)
91
+            ->values([
92
+                'collection_id' => $query->createNamedParameter($this->id, IQueryBuilder::PARAM_INT),
93
+                'resource_type' => $query->createNamedParameter($resource->getType()),
94
+                'resource_id' => $query->createNamedParameter($resource->getId()),
95
+            ]);
96
+
97
+        try {
98
+            $query->executeStatement();
99
+        } catch (ConstraintViolationException $e) {
100
+            throw new ResourceException('Already part of the collection');
101
+        }
102
+
103
+        $this->manager->invalidateAccessCacheForCollection($this);
104
+    }
105
+
106
+    /**
107
+     * Removes a resource from a collection
108
+     *
109
+     * @since 16.0.0
110
+     */
111
+    public function removeResource(IResource $resource): void {
112
+        $this->resources = array_filter($this->getResources(), function (IResource $r) use ($resource) {
113
+            return !$this->isSameResource($r, $resource);
114
+        });
115
+
116
+        $query = $this->connection->getQueryBuilder();
117
+        $query->delete(Manager::TABLE_RESOURCES)
118
+            ->where($query->expr()->eq('collection_id', $query->createNamedParameter($this->id, IQueryBuilder::PARAM_INT)))
119
+            ->andWhere($query->expr()->eq('resource_type', $query->createNamedParameter($resource->getType())))
120
+            ->andWhere($query->expr()->eq('resource_id', $query->createNamedParameter($resource->getId())));
121
+        $query->executeStatement();
122
+
123
+        if (empty($this->resources)) {
124
+            $this->removeCollection();
125
+        } else {
126
+            $this->manager->invalidateAccessCacheForCollection($this);
127
+        }
128
+    }
129
+
130
+    /**
131
+     * Can a user/guest access the collection
132
+     *
133
+     * @since 16.0.0
134
+     */
135
+    public function canAccess(?IUser $user): bool {
136
+        if ($user instanceof IUser) {
137
+            return $this->canUserAccess($user);
138
+        }
139
+        return $this->canGuestAccess();
140
+    }
141
+
142
+    protected function canUserAccess(IUser $user): bool {
143
+        if (\is_bool($this->access) && $this->userForAccess instanceof IUser && $user->getUID() === $this->userForAccess->getUID()) {
144
+            return $this->access;
145
+        }
146
+
147
+        $access = $this->manager->canAccessCollection($this, $user);
148
+        if ($this->userForAccess instanceof IUser && $user->getUID() === $this->userForAccess->getUID()) {
149
+            $this->access = $access;
150
+        }
151
+        return $access;
152
+    }
153
+
154
+    protected function canGuestAccess(): bool {
155
+        if (\is_bool($this->access) && !$this->userForAccess instanceof IUser) {
156
+            return $this->access;
157
+        }
158
+
159
+        $access = $this->manager->canAccessCollection($this, null);
160
+        if (!$this->userForAccess instanceof IUser) {
161
+            $this->access = $access;
162
+        }
163
+        return $access;
164
+    }
165
+
166
+    protected function isSameResource(IResource $resource1, IResource $resource2): bool {
167
+        return $resource1->getType() === $resource2->getType()
168
+            && $resource1->getId() === $resource2->getId();
169
+    }
170
+
171
+    protected function removeCollection(): void {
172
+        $query = $this->connection->getQueryBuilder();
173
+        $query->delete(Manager::TABLE_COLLECTIONS)
174
+            ->where($query->expr()->eq('id', $query->createNamedParameter($this->id, IQueryBuilder::PARAM_INT)));
175
+        $query->executeStatement();
176
+
177
+        $this->manager->invalidateAccessCacheForCollection($this);
178
+        $this->id = 0;
179
+    }
180 180
 }
Please login to merge, or discard this patch.
lib/public/Accounts/PropertyDoesNotExistException.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
 	 * @since 15.0.0
39 39
 	 */
40 40
 	public function __construct($property) {
41
-		parent::__construct('Property ' . $property . ' does not exist.');
41
+		parent::__construct('Property '.$property.' does not exist.');
42 42
 	}
43 43
 
44 44
 }
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -30,12 +30,12 @@
 block discarded – undo
30 30
  *
31 31
  */
32 32
 class PropertyDoesNotExistException extends \Exception {
33
-	/**
34
-	 * Constructor
35
-	 * @param string $msg the error message
36
-	 * @since 15.0.0
37
-	 */
38
-	public function __construct($property) {
39
-		parent::__construct('Property ' . $property . ' does not exist.');
40
-	}
33
+    /**
34
+     * Constructor
35
+     * @param string $msg the error message
36
+     * @since 15.0.0
37
+     */
38
+    public function __construct($property) {
39
+        parent::__construct('Property ' . $property . ' does not exist.');
40
+    }
41 41
 }
Please login to merge, or discard this patch.
lib/private/Collaboration/Collaborators/RemotePlugin.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 							$searchResult->markExactIdMatch($resultType);
113 113
 						}
114 114
 						$result['exact'][] = [
115
-							'label' => $contact['FN'] . " ($cloudId)",
115
+							'label' => $contact['FN']." ($cloudId)",
116 116
 							'uuid' => $contact['UID'],
117 117
 							'name' => $contact['FN'],
118 118
 							'type' => $cloudIdType,
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 						];
125 125
 					} else {
126 126
 						$result['wide'][] = [
127
-							'label' => $contact['FN'] . " ($cloudId)",
127
+							'label' => $contact['FN']." ($cloudId)",
128 128
 							'uuid' => $contact['UID'],
129 129
 							'name' => $contact['FN'],
130 130
 							'type' => $cloudIdType,
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 				$localUser = $this->userManager->get($remoteUser);
155 155
 				if ($localUser === null || $search !== $localUser->getCloudId()) {
156 156
 					$result['exact'][] = [
157
-						'label' => $remoteUser . " ($serverUrl)",
157
+						'label' => $remoteUser." ($serverUrl)",
158 158
 						'uuid' => $remoteUser,
159 159
 						'name' => $remoteUser,
160 160
 						'value' => [
Please login to merge, or discard this patch.
Indentation   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -19,160 +19,160 @@
 block discarded – undo
19 19
 use OCP\Share\IShare;
20 20
 
21 21
 class RemotePlugin implements ISearchPlugin {
22
-	protected bool $shareeEnumeration;
22
+    protected bool $shareeEnumeration;
23 23
 
24
-	private string $userId;
24
+    private string $userId;
25 25
 
26
-	public function __construct(
27
-		private IManager $contactsManager,
28
-		private ICloudIdManager $cloudIdManager,
29
-		private IConfig $config,
30
-		private IUserManager $userManager,
31
-		IUserSession $userSession,
32
-		private IAppConfig $appConfig,
33
-		private ?TrustedServers $trustedServers,
34
-	) {
35
-		$this->userId = $userSession->getUser()?->getUID() ?? '';
36
-		$this->shareeEnumeration = $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') === 'yes';
37
-	}
26
+    public function __construct(
27
+        private IManager $contactsManager,
28
+        private ICloudIdManager $cloudIdManager,
29
+        private IConfig $config,
30
+        private IUserManager $userManager,
31
+        IUserSession $userSession,
32
+        private IAppConfig $appConfig,
33
+        private ?TrustedServers $trustedServers,
34
+    ) {
35
+        $this->userId = $userSession->getUser()?->getUID() ?? '';
36
+        $this->shareeEnumeration = $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') === 'yes';
37
+    }
38 38
 
39 39
 
40
-	public function search($search, $limit, $offset, ISearchResult $searchResult): bool {
41
-		$result = ['wide' => [], 'exact' => []];
42
-		$resultType = new SearchResultType('remotes');
40
+    public function search($search, $limit, $offset, ISearchResult $searchResult): bool {
41
+        $result = ['wide' => [], 'exact' => []];
42
+        $resultType = new SearchResultType('remotes');
43 43
 
44
-		// Search in contacts
45
-		$addressBookContacts = $this->contactsManager->search($search, ['CLOUD', 'FN', 'EMAIL'], [
46
-			'limit' => $limit,
47
-			'offset' => $offset,
48
-			'enumeration' => false,
49
-			'fullmatch' => false,
50
-		]);
51
-		foreach ($addressBookContacts as $contact) {
52
-			if (isset($contact['isLocalSystemBook'])) {
53
-				continue;
54
-			}
55
-			if (isset($contact['CLOUD'])) {
56
-				$cloudIds = $contact['CLOUD'];
57
-				if (is_string($cloudIds)) {
58
-					$cloudIds = [$cloudIds];
59
-				}
60
-				$lowerSearch = strtolower($search);
61
-				foreach ($cloudIds as $cloudId) {
62
-					$cloudIdType = '';
63
-					if (\is_array($cloudId)) {
64
-						$cloudIdData = $cloudId;
65
-						$cloudId = $cloudIdData['value'];
66
-						$cloudIdType = $cloudIdData['type'];
67
-					}
68
-					try {
69
-						[$remoteUser, $serverUrl] = $this->splitUserRemote($cloudId);
70
-					} catch (\InvalidArgumentException $e) {
71
-						continue;
72
-					}
44
+        // Search in contacts
45
+        $addressBookContacts = $this->contactsManager->search($search, ['CLOUD', 'FN', 'EMAIL'], [
46
+            'limit' => $limit,
47
+            'offset' => $offset,
48
+            'enumeration' => false,
49
+            'fullmatch' => false,
50
+        ]);
51
+        foreach ($addressBookContacts as $contact) {
52
+            if (isset($contact['isLocalSystemBook'])) {
53
+                continue;
54
+            }
55
+            if (isset($contact['CLOUD'])) {
56
+                $cloudIds = $contact['CLOUD'];
57
+                if (is_string($cloudIds)) {
58
+                    $cloudIds = [$cloudIds];
59
+                }
60
+                $lowerSearch = strtolower($search);
61
+                foreach ($cloudIds as $cloudId) {
62
+                    $cloudIdType = '';
63
+                    if (\is_array($cloudId)) {
64
+                        $cloudIdData = $cloudId;
65
+                        $cloudId = $cloudIdData['value'];
66
+                        $cloudIdType = $cloudIdData['type'];
67
+                    }
68
+                    try {
69
+                        [$remoteUser, $serverUrl] = $this->splitUserRemote($cloudId);
70
+                    } catch (\InvalidArgumentException $e) {
71
+                        continue;
72
+                    }
73 73
 
74
-					$localUser = $this->userManager->get($remoteUser);
75
-					if ($localUser !== null && $remoteUser !== $this->userId && $cloudId === $localUser->getCloudId()) {
76
-						$result['wide'][] = [
77
-							'label' => $contact['FN'],
78
-							'uuid' => $contact['UID'],
79
-							'value' => [
80
-								'shareType' => IShare::TYPE_USER,
81
-								'shareWith' => $remoteUser
82
-							],
83
-							'shareWithDisplayNameUnique' => $contact['EMAIL'] !== null && $contact['EMAIL'] !== '' ? $contact['EMAIL'] : $contact['UID'],
84
-						];
85
-					}
74
+                    $localUser = $this->userManager->get($remoteUser);
75
+                    if ($localUser !== null && $remoteUser !== $this->userId && $cloudId === $localUser->getCloudId()) {
76
+                        $result['wide'][] = [
77
+                            'label' => $contact['FN'],
78
+                            'uuid' => $contact['UID'],
79
+                            'value' => [
80
+                                'shareType' => IShare::TYPE_USER,
81
+                                'shareWith' => $remoteUser
82
+                            ],
83
+                            'shareWithDisplayNameUnique' => $contact['EMAIL'] !== null && $contact['EMAIL'] !== '' ? $contact['EMAIL'] : $contact['UID'],
84
+                        ];
85
+                    }
86 86
 
87
-					$emailMatch = false;
88
-					if (isset($contact['EMAIL'])) {
89
-						$emails = is_array($contact['EMAIL']) ? $contact['EMAIL'] : [$contact['EMAIL']];
90
-						foreach ($emails as $email) {
91
-							if (is_string($email) && strtolower($email) === $lowerSearch) {
92
-								$emailMatch = true;
93
-								break;
94
-							}
95
-						}
96
-					}
97
-					if ($emailMatch || strtolower($contact['FN']) === $lowerSearch || strtolower($cloudId) === $lowerSearch) {
98
-						if (strtolower($cloudId) === $lowerSearch) {
99
-							$searchResult->markExactIdMatch($resultType);
100
-						}
101
-						$result['exact'][] = [
102
-							'label' => $contact['FN'] . " ($cloudId)",
103
-							'uuid' => $contact['UID'],
104
-							'name' => $contact['FN'],
105
-							'type' => $cloudIdType,
106
-							'value' => [
107
-								'shareType' => IShare::TYPE_REMOTE,
108
-								'shareWith' => $cloudId,
109
-								'server' => $serverUrl,
110
-								'isTrustedServer' => $this->trustedServers?->isTrustedServer($serverUrl) ?? false,
111
-							],
112
-						];
113
-					} else {
114
-						$result['wide'][] = [
115
-							'label' => $contact['FN'] . " ($cloudId)",
116
-							'uuid' => $contact['UID'],
117
-							'name' => $contact['FN'],
118
-							'type' => $cloudIdType,
119
-							'value' => [
120
-								'shareType' => IShare::TYPE_REMOTE,
121
-								'shareWith' => $cloudId,
122
-								'server' => $serverUrl,
123
-								'isTrustedServer' => $this->trustedServers?->isTrustedServer($serverUrl) ?? false,
124
-							],
125
-						];
126
-					}
127
-				}
128
-			}
129
-		}
87
+                    $emailMatch = false;
88
+                    if (isset($contact['EMAIL'])) {
89
+                        $emails = is_array($contact['EMAIL']) ? $contact['EMAIL'] : [$contact['EMAIL']];
90
+                        foreach ($emails as $email) {
91
+                            if (is_string($email) && strtolower($email) === $lowerSearch) {
92
+                                $emailMatch = true;
93
+                                break;
94
+                            }
95
+                        }
96
+                    }
97
+                    if ($emailMatch || strtolower($contact['FN']) === $lowerSearch || strtolower($cloudId) === $lowerSearch) {
98
+                        if (strtolower($cloudId) === $lowerSearch) {
99
+                            $searchResult->markExactIdMatch($resultType);
100
+                        }
101
+                        $result['exact'][] = [
102
+                            'label' => $contact['FN'] . " ($cloudId)",
103
+                            'uuid' => $contact['UID'],
104
+                            'name' => $contact['FN'],
105
+                            'type' => $cloudIdType,
106
+                            'value' => [
107
+                                'shareType' => IShare::TYPE_REMOTE,
108
+                                'shareWith' => $cloudId,
109
+                                'server' => $serverUrl,
110
+                                'isTrustedServer' => $this->trustedServers?->isTrustedServer($serverUrl) ?? false,
111
+                            ],
112
+                        ];
113
+                    } else {
114
+                        $result['wide'][] = [
115
+                            'label' => $contact['FN'] . " ($cloudId)",
116
+                            'uuid' => $contact['UID'],
117
+                            'name' => $contact['FN'],
118
+                            'type' => $cloudIdType,
119
+                            'value' => [
120
+                                'shareType' => IShare::TYPE_REMOTE,
121
+                                'shareWith' => $cloudId,
122
+                                'server' => $serverUrl,
123
+                                'isTrustedServer' => $this->trustedServers?->isTrustedServer($serverUrl) ?? false,
124
+                            ],
125
+                        ];
126
+                    }
127
+                }
128
+            }
129
+        }
130 130
 
131
-		if (!$this->shareeEnumeration) {
132
-			$result['wide'] = [];
133
-		} else {
134
-			$result['wide'] = array_slice($result['wide'], $offset, $limit);
135
-		}
131
+        if (!$this->shareeEnumeration) {
132
+            $result['wide'] = [];
133
+        } else {
134
+            $result['wide'] = array_slice($result['wide'], $offset, $limit);
135
+        }
136 136
 
137
-		if (!$searchResult->hasExactIdMatch($resultType) && $this->cloudIdManager->isValidCloudId($search) && $offset === 0) {
138
-			try {
139
-				[$remoteUser, $serverUrl] = $this->splitUserRemote($search);
140
-				$localUser = $this->userManager->get($remoteUser);
141
-				if ($localUser === null || $search !== $localUser->getCloudId()) {
142
-					$result['exact'][] = [
143
-						'label' => $remoteUser . " ($serverUrl)",
144
-						'uuid' => $remoteUser,
145
-						'name' => $remoteUser,
146
-						'value' => [
147
-							'shareType' => IShare::TYPE_REMOTE,
148
-							'shareWith' => $search,
149
-							'server' => $serverUrl,
150
-							'isTrustedServer' => $this->trustedServers?->isTrustedServer($serverUrl) ?? false,
151
-						],
152
-					];
153
-				}
154
-			} catch (\InvalidArgumentException $e) {
155
-			}
156
-		}
137
+        if (!$searchResult->hasExactIdMatch($resultType) && $this->cloudIdManager->isValidCloudId($search) && $offset === 0) {
138
+            try {
139
+                [$remoteUser, $serverUrl] = $this->splitUserRemote($search);
140
+                $localUser = $this->userManager->get($remoteUser);
141
+                if ($localUser === null || $search !== $localUser->getCloudId()) {
142
+                    $result['exact'][] = [
143
+                        'label' => $remoteUser . " ($serverUrl)",
144
+                        'uuid' => $remoteUser,
145
+                        'name' => $remoteUser,
146
+                        'value' => [
147
+                            'shareType' => IShare::TYPE_REMOTE,
148
+                            'shareWith' => $search,
149
+                            'server' => $serverUrl,
150
+                            'isTrustedServer' => $this->trustedServers?->isTrustedServer($serverUrl) ?? false,
151
+                        ],
152
+                    ];
153
+                }
154
+            } catch (\InvalidArgumentException $e) {
155
+            }
156
+        }
157 157
 
158
-		$searchResult->addResultSet($resultType, $result['wide'], $result['exact']);
158
+        $searchResult->addResultSet($resultType, $result['wide'], $result['exact']);
159 159
 
160
-		return true;
161
-	}
160
+        return true;
161
+    }
162 162
 
163
-	/**
164
-	 * split user and remote from federated cloud id
165
-	 *
166
-	 * @param string $address federated share address
167
-	 * @return array [user, remoteURL]
168
-	 * @throws \InvalidArgumentException
169
-	 */
170
-	public function splitUserRemote(string $address): array {
171
-		try {
172
-			$cloudId = $this->cloudIdManager->resolveCloudId($address);
173
-			return [$cloudId->getUser(), $this->cloudIdManager->removeProtocolFromUrl($cloudId->getRemote(), true)];
174
-		} catch (\InvalidArgumentException $e) {
175
-			throw new \InvalidArgumentException('Invalid Federated Cloud ID', 0, $e);
176
-		}
177
-	}
163
+    /**
164
+     * split user and remote from federated cloud id
165
+     *
166
+     * @param string $address federated share address
167
+     * @return array [user, remoteURL]
168
+     * @throws \InvalidArgumentException
169
+     */
170
+    public function splitUserRemote(string $address): array {
171
+        try {
172
+            $cloudId = $this->cloudIdManager->resolveCloudId($address);
173
+            return [$cloudId->getUser(), $this->cloudIdManager->removeProtocolFromUrl($cloudId->getRemote(), true)];
174
+        } catch (\InvalidArgumentException $e) {
175
+            throw new \InvalidArgumentException('Invalid Federated Cloud ID', 0, $e);
176
+        }
177
+    }
178 178
 }
Please login to merge, or discard this patch.
lib/private/Color.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -24,12 +24,12 @@
 block discarded – undo
24 24
 namespace OC;
25 25
 
26 26
 class Color {
27
-	public $r;
28
-	public $g;
29
-	public $b;
30
-	public function __construct($r, $g, $b) {
31
-		$this->r = $r;
32
-		$this->g = $g;
33
-		$this->b = $b;
34
-	}
27
+    public $r;
28
+    public $g;
29
+    public $b;
30
+    public function __construct($r, $g, $b) {
31
+        $this->r = $r;
32
+        $this->g = $g;
33
+        $this->b = $b;
34
+    }
35 35
 }
Please login to merge, or discard this patch.