Passed
Push — master ( a9798a...74f31b )
by John
14:36 queued 12s
created
apps/encryption/lib/HookManager.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -26,34 +26,34 @@
 block discarded – undo
26 26
 use OCA\Encryption\Hooks\Contracts\IHook;
27 27
 
28 28
 class HookManager {
29
-	/** @var IHook[] */
30
-	private $hookInstances = [];
29
+    /** @var IHook[] */
30
+    private $hookInstances = [];
31 31
 
32
-	/**
33
-	 * @param array|IHook $instances
34
-	 *        - This accepts either a single instance of IHook or an array of instances of IHook
35
-	 * @return bool
36
-	 */
37
-	public function registerHook($instances) {
38
-		if (is_array($instances)) {
39
-			foreach ($instances as $instance) {
40
-				if (!$instance instanceof IHook) {
41
-					return false;
42
-				}
43
-				$this->hookInstances[] = $instance;
44
-			}
45
-		} elseif ($instances instanceof IHook) {
46
-			$this->hookInstances[] = $instances;
47
-		}
48
-		return true;
49
-	}
32
+    /**
33
+     * @param array|IHook $instances
34
+     *        - This accepts either a single instance of IHook or an array of instances of IHook
35
+     * @return bool
36
+     */
37
+    public function registerHook($instances) {
38
+        if (is_array($instances)) {
39
+            foreach ($instances as $instance) {
40
+                if (!$instance instanceof IHook) {
41
+                    return false;
42
+                }
43
+                $this->hookInstances[] = $instance;
44
+            }
45
+        } elseif ($instances instanceof IHook) {
46
+            $this->hookInstances[] = $instances;
47
+        }
48
+        return true;
49
+    }
50 50
 
51
-	public function fireHooks() {
52
-		foreach ($this->hookInstances as $instance) {
53
-			/**
54
-			 * Fire off the add hooks method of each instance stored in cache
55
-			 */
56
-			$instance->addHooks();
57
-		}
58
-	}
51
+    public function fireHooks() {
52
+        foreach ($this->hookInstances as $instance) {
53
+            /**
54
+             * Fire off the add hooks method of each instance stored in cache
55
+             */
56
+            $instance->addHooks();
57
+        }
58
+    }
59 59
 }
Please login to merge, or discard this patch.
lib/private/Search.php 1 patch
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -36,85 +36,85 @@
 block discarded – undo
36 36
  * Provide an interface to all search providers
37 37
  */
38 38
 class Search implements ISearch {
39
-	/** @var Provider[] */
40
-	private $providers = [];
41
-	private $registeredProviders = [];
39
+    /** @var Provider[] */
40
+    private $providers = [];
41
+    private $registeredProviders = [];
42 42
 
43
-	/**
44
-	 * Search all providers for $query
45
-	 * @param string $query
46
-	 * @param string[] $inApps optionally limit results to the given apps
47
-	 * @param int $page pages start at page 1
48
-	 * @param int $size, 0 = all
49
-	 * @return array An array of OC\Search\Result's
50
-	 */
51
-	public function searchPaged($query, array $inApps = [], $page = 1, $size = 30) {
52
-		$this->initProviders();
53
-		$results = [];
54
-		foreach ($this->providers as $provider) {
55
-			if (! $provider->providesResultsFor($inApps)) {
56
-				continue;
57
-			}
58
-			if ($provider instanceof PagedProvider) {
59
-				$results = array_merge($results, $provider->searchPaged($query, $page, $size));
60
-			} elseif ($provider instanceof Provider) {
61
-				$providerResults = $provider->search($query);
62
-				if ($size > 0) {
63
-					$slicedResults = array_slice($providerResults, ($page - 1) * $size, $size);
64
-					$results = array_merge($results, $slicedResults);
65
-				} else {
66
-					$results = array_merge($results, $providerResults);
67
-				}
68
-			} else {
69
-				\OC::$server->getLogger()->warning('Ignoring Unknown search provider', ['provider' => $provider]);
70
-			}
71
-		}
72
-		return $results;
73
-	}
43
+    /**
44
+     * Search all providers for $query
45
+     * @param string $query
46
+     * @param string[] $inApps optionally limit results to the given apps
47
+     * @param int $page pages start at page 1
48
+     * @param int $size, 0 = all
49
+     * @return array An array of OC\Search\Result's
50
+     */
51
+    public function searchPaged($query, array $inApps = [], $page = 1, $size = 30) {
52
+        $this->initProviders();
53
+        $results = [];
54
+        foreach ($this->providers as $provider) {
55
+            if (! $provider->providesResultsFor($inApps)) {
56
+                continue;
57
+            }
58
+            if ($provider instanceof PagedProvider) {
59
+                $results = array_merge($results, $provider->searchPaged($query, $page, $size));
60
+            } elseif ($provider instanceof Provider) {
61
+                $providerResults = $provider->search($query);
62
+                if ($size > 0) {
63
+                    $slicedResults = array_slice($providerResults, ($page - 1) * $size, $size);
64
+                    $results = array_merge($results, $slicedResults);
65
+                } else {
66
+                    $results = array_merge($results, $providerResults);
67
+                }
68
+            } else {
69
+                \OC::$server->getLogger()->warning('Ignoring Unknown search provider', ['provider' => $provider]);
70
+            }
71
+        }
72
+        return $results;
73
+    }
74 74
 
75
-	/**
76
-	 * Remove all registered search providers
77
-	 */
78
-	public function clearProviders() {
79
-		$this->providers = [];
80
-		$this->registeredProviders = [];
81
-	}
75
+    /**
76
+     * Remove all registered search providers
77
+     */
78
+    public function clearProviders() {
79
+        $this->providers = [];
80
+        $this->registeredProviders = [];
81
+    }
82 82
 
83
-	/**
84
-	 * Remove one existing search provider
85
-	 * @param string $provider class name of a OC\Search\Provider
86
-	 */
87
-	public function removeProvider($provider) {
88
-		$this->registeredProviders = array_filter(
89
-			$this->registeredProviders,
90
-			function ($element) use ($provider) {
91
-				return ($element['class'] != $provider);
92
-			}
93
-		);
94
-		// force regeneration of providers on next search
95
-		$this->providers = [];
96
-	}
83
+    /**
84
+     * Remove one existing search provider
85
+     * @param string $provider class name of a OC\Search\Provider
86
+     */
87
+    public function removeProvider($provider) {
88
+        $this->registeredProviders = array_filter(
89
+            $this->registeredProviders,
90
+            function ($element) use ($provider) {
91
+                return ($element['class'] != $provider);
92
+            }
93
+        );
94
+        // force regeneration of providers on next search
95
+        $this->providers = [];
96
+    }
97 97
 
98
-	/**
99
-	 * Register a new search provider to search with
100
-	 * @param string $class class name of a OC\Search\Provider
101
-	 * @param array $options optional
102
-	 */
103
-	public function registerProvider($class, array $options = []) {
104
-		$this->registeredProviders[] = ['class' => $class, 'options' => $options];
105
-	}
98
+    /**
99
+     * Register a new search provider to search with
100
+     * @param string $class class name of a OC\Search\Provider
101
+     * @param array $options optional
102
+     */
103
+    public function registerProvider($class, array $options = []) {
104
+        $this->registeredProviders[] = ['class' => $class, 'options' => $options];
105
+    }
106 106
 
107
-	/**
108
-	 * Create instances of all the registered search providers
109
-	 */
110
-	private function initProviders() {
111
-		if (! empty($this->providers)) {
112
-			return;
113
-		}
114
-		foreach ($this->registeredProviders as $provider) {
115
-			$class = $provider['class'];
116
-			$options = $provider['options'];
117
-			$this->providers[] = new $class($options);
118
-		}
119
-	}
107
+    /**
108
+     * Create instances of all the registered search providers
109
+     */
110
+    private function initProviders() {
111
+        if (! empty($this->providers)) {
112
+            return;
113
+        }
114
+        foreach ($this->registeredProviders as $provider) {
115
+            $class = $provider['class'];
116
+            $options = $provider['options'];
117
+            $this->providers[] = new $class($options);
118
+        }
119
+    }
120 120
 }
Please login to merge, or discard this patch.
core/templates/404.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -4,11 +4,11 @@
 block discarded – undo
4 4
 /** @var \OCP\Defaults $theme */
5 5
 // @codeCoverageIgnoreStart
6 6
 if (!isset($_)) {//standalone  page is not supported anymore - redirect to /
7
-	require_once '../../lib/base.php';
7
+    require_once '../../lib/base.php';
8 8
 
9
-	$urlGenerator = \OC::$server->getURLGenerator();
10
-	header('Location: ' . $urlGenerator->getAbsoluteURL('/'));
11
-	exit;
9
+    $urlGenerator = \OC::$server->getURLGenerator();
10
+    header('Location: ' . $urlGenerator->getAbsoluteURL('/'));
11
+    exit;
12 12
 }
13 13
 // @codeCoverageIgnoreEnd
14 14
 ?>
Please login to merge, or discard this patch.
apps/settings/lib/Search/AppSearch.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -33,76 +33,76 @@
 block discarded – undo
33 33
 
34 34
 class AppSearch implements IProvider {
35 35
 
36
-	/** @var INavigationManager */
37
-	protected $navigationManager;
38
-
39
-	/** @var IL10N */
40
-	protected $l;
41
-
42
-	public function __construct(INavigationManager $navigationManager,
43
-								IL10N $l) {
44
-		$this->navigationManager = $navigationManager;
45
-		$this->l = $l;
46
-	}
47
-
48
-	/**
49
-	 * @inheritDoc
50
-	 */
51
-	public function getId(): string {
52
-		return 'settings_apps';
53
-	}
54
-
55
-	/**
56
-	 * @inheritDoc
57
-	 */
58
-	public function getName(): string {
59
-		return $this->l->t('Apps');
60
-	}
61
-
62
-	/**
63
-	 * @inheritDoc
64
-	 */
65
-	public function getOrder(string $route, array $routeParameters): int {
66
-		return -50;
67
-	}
68
-
69
-	/**
70
-	 * @inheritDoc
71
-	 */
72
-	public function search(IUser $user, ISearchQuery $query): SearchResult {
73
-		$entries = $this->navigationManager->getAll('all');
74
-
75
-		$result = [];
76
-		foreach ($entries as $entry) {
77
-			if (
78
-				stripos($entry['name'], $query->getTerm()) === false &&
79
-				stripos($entry['id'], $query->getTerm()) === false
80
-			) {
81
-				continue;
82
-			}
83
-
84
-			if (strpos($query->getRoute(), $entry['id'] . '.') === 0) {
85
-				// Skip the current app, unlikely this is intended
86
-				continue;
87
-			}
88
-
89
-			if ($entry['href'] === '') {
90
-				// Nothing we can open, so ignore
91
-				continue;
92
-			}
93
-
94
-			$result[] = new SearchResultEntry(
95
-				'',
96
-				$entry['name'],
97
-				'',
98
-				$entry['href'],
99
-				'icon-confirm'
100
-			);
101
-		}
102
-
103
-		return SearchResult::complete(
104
-			$this->l->t('Apps'),
105
-			$result
106
-		);
107
-	}
36
+    /** @var INavigationManager */
37
+    protected $navigationManager;
38
+
39
+    /** @var IL10N */
40
+    protected $l;
41
+
42
+    public function __construct(INavigationManager $navigationManager,
43
+                                IL10N $l) {
44
+        $this->navigationManager = $navigationManager;
45
+        $this->l = $l;
46
+    }
47
+
48
+    /**
49
+     * @inheritDoc
50
+     */
51
+    public function getId(): string {
52
+        return 'settings_apps';
53
+    }
54
+
55
+    /**
56
+     * @inheritDoc
57
+     */
58
+    public function getName(): string {
59
+        return $this->l->t('Apps');
60
+    }
61
+
62
+    /**
63
+     * @inheritDoc
64
+     */
65
+    public function getOrder(string $route, array $routeParameters): int {
66
+        return -50;
67
+    }
68
+
69
+    /**
70
+     * @inheritDoc
71
+     */
72
+    public function search(IUser $user, ISearchQuery $query): SearchResult {
73
+        $entries = $this->navigationManager->getAll('all');
74
+
75
+        $result = [];
76
+        foreach ($entries as $entry) {
77
+            if (
78
+                stripos($entry['name'], $query->getTerm()) === false &&
79
+                stripos($entry['id'], $query->getTerm()) === false
80
+            ) {
81
+                continue;
82
+            }
83
+
84
+            if (strpos($query->getRoute(), $entry['id'] . '.') === 0) {
85
+                // Skip the current app, unlikely this is intended
86
+                continue;
87
+            }
88
+
89
+            if ($entry['href'] === '') {
90
+                // Nothing we can open, so ignore
91
+                continue;
92
+            }
93
+
94
+            $result[] = new SearchResultEntry(
95
+                '',
96
+                $entry['name'],
97
+                '',
98
+                $entry['href'],
99
+                'icon-confirm'
100
+            );
101
+        }
102
+
103
+        return SearchResult::complete(
104
+            $this->l->t('Apps'),
105
+            $result
106
+        );
107
+    }
108 108
 }
Please login to merge, or discard this patch.
lib/public/Files/Config/IRootMountProvider.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -31,11 +31,11 @@
 block discarded – undo
31 31
  * @since 20.0.0
32 32
  */
33 33
 interface IRootMountProvider {
34
-	/**
35
-	 * Get all root mountpoints of this provider
36
-	 *
37
-	 * @return \OCP\Files\Mount\IMountPoint[]
38
-	 * @since 20.0.0
39
-	 */
40
-	public function getRootMounts(IStorageFactory $loader): array;
34
+    /**
35
+     * Get all root mountpoints of this provider
36
+     *
37
+     * @return \OCP\Files\Mount\IMountPoint[]
38
+     * @since 20.0.0
39
+     */
40
+    public function getRootMounts(IStorageFactory $loader): array;
41 41
 }
Please login to merge, or discard this patch.
apps/dav/lib/DAV/Sharing/Plugin.php 1 patch
Indentation   +171 added lines, -171 removed lines patch added patch discarded remove patch
@@ -38,175 +38,175 @@
 block discarded – undo
38 38
 use Sabre\HTTP\ResponseInterface;
39 39
 
40 40
 class Plugin extends ServerPlugin {
41
-	public const NS_OWNCLOUD = 'http://owncloud.org/ns';
42
-	public const NS_NEXTCLOUD = 'http://nextcloud.com/ns';
43
-
44
-	/** @var Auth */
45
-	private $auth;
46
-
47
-	/** @var IRequest */
48
-	private $request;
49
-
50
-	/** @var IConfig */
51
-	private $config;
52
-
53
-	/**
54
-	 * Plugin constructor.
55
-	 *
56
-	 * @param Auth $authBackEnd
57
-	 * @param IRequest $request
58
-	 * @param IConfig $config
59
-	 */
60
-	public function __construct(Auth $authBackEnd, IRequest $request, IConfig $config) {
61
-		$this->auth = $authBackEnd;
62
-		$this->request = $request;
63
-		$this->config = $config;
64
-	}
65
-
66
-	/**
67
-	 * Reference to SabreDAV server object.
68
-	 *
69
-	 * @var \Sabre\DAV\Server
70
-	 */
71
-	protected $server;
72
-
73
-	/**
74
-	 * This method should return a list of server-features.
75
-	 *
76
-	 * This is for example 'versioning' and is added to the DAV: header
77
-	 * in an OPTIONS response.
78
-	 *
79
-	 * @return string[]
80
-	 */
81
-	public function getFeatures() {
82
-		return ['oc-resource-sharing'];
83
-	}
84
-
85
-	/**
86
-	 * Returns a plugin name.
87
-	 *
88
-	 * Using this name other plugins will be able to access other plugins
89
-	 * using Sabre\DAV\Server::getPlugin
90
-	 *
91
-	 * @return string
92
-	 */
93
-	public function getPluginName() {
94
-		return 'oc-resource-sharing';
95
-	}
96
-
97
-	/**
98
-	 * This initializes the plugin.
99
-	 *
100
-	 * This function is called by Sabre\DAV\Server, after
101
-	 * addPlugin is called.
102
-	 *
103
-	 * This method should set up the required event subscriptions.
104
-	 *
105
-	 * @param Server $server
106
-	 * @return void
107
-	 */
108
-	public function initialize(Server $server) {
109
-		$this->server = $server;
110
-		$this->server->xml->elementMap['{' . Plugin::NS_OWNCLOUD . '}share'] = ShareRequest::class;
111
-		$this->server->xml->elementMap['{' . Plugin::NS_OWNCLOUD . '}invite'] = Invite::class;
112
-
113
-		$this->server->on('method:POST', [$this, 'httpPost']);
114
-		$this->server->on('propFind',    [$this, 'propFind']);
115
-	}
116
-
117
-	/**
118
-	 * We intercept this to handle POST requests on a dav resource.
119
-	 *
120
-	 * @param RequestInterface $request
121
-	 * @param ResponseInterface $response
122
-	 * @return null|false
123
-	 */
124
-	public function httpPost(RequestInterface $request, ResponseInterface $response) {
125
-		$path = $request->getPath();
126
-
127
-		// Only handling xml
128
-		$contentType = $request->getHeader('Content-Type');
129
-		if (strpos($contentType, 'application/xml') === false && strpos($contentType, 'text/xml') === false) {
130
-			return;
131
-		}
132
-
133
-		// Making sure the node exists
134
-		try {
135
-			$node = $this->server->tree->getNodeForPath($path);
136
-		} catch (NotFound $e) {
137
-			return;
138
-		}
139
-
140
-		$requestBody = $request->getBodyAsString();
141
-
142
-		// If this request handler could not deal with this POST request, it
143
-		// will return 'null' and other plugins get a chance to handle the
144
-		// request.
145
-		//
146
-		// However, we already requested the full body. This is a problem,
147
-		// because a body can only be read once. This is why we preemptively
148
-		// re-populated the request body with the existing data.
149
-		$request->setBody($requestBody);
150
-
151
-		$message = $this->server->xml->parse($requestBody, $request->getUrl(), $documentType);
152
-
153
-		switch ($documentType) {
154
-
155
-			// Dealing with the 'share' document, which modified invitees on a
156
-			// calendar.
157
-			case '{' . self::NS_OWNCLOUD . '}share':
158
-
159
-				// We can only deal with IShareableCalendar objects
160
-				if (!$node instanceof IShareable) {
161
-					return;
162
-				}
163
-
164
-				$this->server->transactionType = 'post-oc-resource-share';
165
-
166
-				// Getting ACL info
167
-				$acl = $this->server->getPlugin('acl');
168
-
169
-				// If there's no ACL support, we allow everything
170
-				if ($acl) {
171
-					/** @var \Sabre\DAVACL\Plugin $acl */
172
-					$acl->checkPrivileges($path, '{DAV:}write');
173
-
174
-					$limitSharingToOwner = $this->config->getAppValue('dav', 'limitAddressBookAndCalendarSharingToOwner', 'no') === 'yes';
175
-					$isOwner = $acl->getCurrentUserPrincipal() === $node->getOwner();
176
-					if ($limitSharingToOwner && !$isOwner) {
177
-						return;
178
-					}
179
-				}
180
-
181
-				$node->updateShares($message->set, $message->remove);
182
-
183
-				$response->setStatus(200);
184
-				// Adding this because sending a response body may cause issues,
185
-				// and I wanted some type of indicator the response was handled.
186
-				$response->setHeader('X-Sabre-Status', 'everything-went-well');
187
-
188
-				// Breaking the event chain
189
-				return false;
190
-		}
191
-	}
192
-
193
-	/**
194
-	 * This event is triggered when properties are requested for a certain
195
-	 * node.
196
-	 *
197
-	 * This allows us to inject any properties early.
198
-	 *
199
-	 * @param PropFind $propFind
200
-	 * @param INode $node
201
-	 * @return void
202
-	 */
203
-	public function propFind(PropFind $propFind, INode $node) {
204
-		if ($node instanceof IShareable) {
205
-			$propFind->handle('{' . Plugin::NS_OWNCLOUD . '}invite', function () use ($node) {
206
-				return new Invite(
207
-					$node->getShares()
208
-				);
209
-			});
210
-		}
211
-	}
41
+    public const NS_OWNCLOUD = 'http://owncloud.org/ns';
42
+    public const NS_NEXTCLOUD = 'http://nextcloud.com/ns';
43
+
44
+    /** @var Auth */
45
+    private $auth;
46
+
47
+    /** @var IRequest */
48
+    private $request;
49
+
50
+    /** @var IConfig */
51
+    private $config;
52
+
53
+    /**
54
+     * Plugin constructor.
55
+     *
56
+     * @param Auth $authBackEnd
57
+     * @param IRequest $request
58
+     * @param IConfig $config
59
+     */
60
+    public function __construct(Auth $authBackEnd, IRequest $request, IConfig $config) {
61
+        $this->auth = $authBackEnd;
62
+        $this->request = $request;
63
+        $this->config = $config;
64
+    }
65
+
66
+    /**
67
+     * Reference to SabreDAV server object.
68
+     *
69
+     * @var \Sabre\DAV\Server
70
+     */
71
+    protected $server;
72
+
73
+    /**
74
+     * This method should return a list of server-features.
75
+     *
76
+     * This is for example 'versioning' and is added to the DAV: header
77
+     * in an OPTIONS response.
78
+     *
79
+     * @return string[]
80
+     */
81
+    public function getFeatures() {
82
+        return ['oc-resource-sharing'];
83
+    }
84
+
85
+    /**
86
+     * Returns a plugin name.
87
+     *
88
+     * Using this name other plugins will be able to access other plugins
89
+     * using Sabre\DAV\Server::getPlugin
90
+     *
91
+     * @return string
92
+     */
93
+    public function getPluginName() {
94
+        return 'oc-resource-sharing';
95
+    }
96
+
97
+    /**
98
+     * This initializes the plugin.
99
+     *
100
+     * This function is called by Sabre\DAV\Server, after
101
+     * addPlugin is called.
102
+     *
103
+     * This method should set up the required event subscriptions.
104
+     *
105
+     * @param Server $server
106
+     * @return void
107
+     */
108
+    public function initialize(Server $server) {
109
+        $this->server = $server;
110
+        $this->server->xml->elementMap['{' . Plugin::NS_OWNCLOUD . '}share'] = ShareRequest::class;
111
+        $this->server->xml->elementMap['{' . Plugin::NS_OWNCLOUD . '}invite'] = Invite::class;
112
+
113
+        $this->server->on('method:POST', [$this, 'httpPost']);
114
+        $this->server->on('propFind',    [$this, 'propFind']);
115
+    }
116
+
117
+    /**
118
+     * We intercept this to handle POST requests on a dav resource.
119
+     *
120
+     * @param RequestInterface $request
121
+     * @param ResponseInterface $response
122
+     * @return null|false
123
+     */
124
+    public function httpPost(RequestInterface $request, ResponseInterface $response) {
125
+        $path = $request->getPath();
126
+
127
+        // Only handling xml
128
+        $contentType = $request->getHeader('Content-Type');
129
+        if (strpos($contentType, 'application/xml') === false && strpos($contentType, 'text/xml') === false) {
130
+            return;
131
+        }
132
+
133
+        // Making sure the node exists
134
+        try {
135
+            $node = $this->server->tree->getNodeForPath($path);
136
+        } catch (NotFound $e) {
137
+            return;
138
+        }
139
+
140
+        $requestBody = $request->getBodyAsString();
141
+
142
+        // If this request handler could not deal with this POST request, it
143
+        // will return 'null' and other plugins get a chance to handle the
144
+        // request.
145
+        //
146
+        // However, we already requested the full body. This is a problem,
147
+        // because a body can only be read once. This is why we preemptively
148
+        // re-populated the request body with the existing data.
149
+        $request->setBody($requestBody);
150
+
151
+        $message = $this->server->xml->parse($requestBody, $request->getUrl(), $documentType);
152
+
153
+        switch ($documentType) {
154
+
155
+            // Dealing with the 'share' document, which modified invitees on a
156
+            // calendar.
157
+            case '{' . self::NS_OWNCLOUD . '}share':
158
+
159
+                // We can only deal with IShareableCalendar objects
160
+                if (!$node instanceof IShareable) {
161
+                    return;
162
+                }
163
+
164
+                $this->server->transactionType = 'post-oc-resource-share';
165
+
166
+                // Getting ACL info
167
+                $acl = $this->server->getPlugin('acl');
168
+
169
+                // If there's no ACL support, we allow everything
170
+                if ($acl) {
171
+                    /** @var \Sabre\DAVACL\Plugin $acl */
172
+                    $acl->checkPrivileges($path, '{DAV:}write');
173
+
174
+                    $limitSharingToOwner = $this->config->getAppValue('dav', 'limitAddressBookAndCalendarSharingToOwner', 'no') === 'yes';
175
+                    $isOwner = $acl->getCurrentUserPrincipal() === $node->getOwner();
176
+                    if ($limitSharingToOwner && !$isOwner) {
177
+                        return;
178
+                    }
179
+                }
180
+
181
+                $node->updateShares($message->set, $message->remove);
182
+
183
+                $response->setStatus(200);
184
+                // Adding this because sending a response body may cause issues,
185
+                // and I wanted some type of indicator the response was handled.
186
+                $response->setHeader('X-Sabre-Status', 'everything-went-well');
187
+
188
+                // Breaking the event chain
189
+                return false;
190
+        }
191
+    }
192
+
193
+    /**
194
+     * This event is triggered when properties are requested for a certain
195
+     * node.
196
+     *
197
+     * This allows us to inject any properties early.
198
+     *
199
+     * @param PropFind $propFind
200
+     * @param INode $node
201
+     * @return void
202
+     */
203
+    public function propFind(PropFind $propFind, INode $node) {
204
+        if ($node instanceof IShareable) {
205
+            $propFind->handle('{' . Plugin::NS_OWNCLOUD . '}invite', function () use ($node) {
206
+                return new Invite(
207
+                    $node->getShares()
208
+                );
209
+            });
210
+        }
211
+    }
212 212
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Migration/DummyUserSession.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -29,45 +29,45 @@
 block discarded – undo
29 29
 
30 30
 class DummyUserSession implements IUserSession {
31 31
 
32
-	/**
33
-	 * @var IUser
34
-	 */
35
-	private $user;
32
+    /**
33
+     * @var IUser
34
+     */
35
+    private $user;
36 36
 
37
-	public function login($uid, $password) {
38
-	}
37
+    public function login($uid, $password) {
38
+    }
39 39
 
40
-	public function logout() {
41
-	}
40
+    public function logout() {
41
+    }
42 42
 
43
-	public function setUser($user) {
44
-		$this->user = $user;
45
-	}
43
+    public function setUser($user) {
44
+        $this->user = $user;
45
+    }
46 46
 
47
-	public function getUser() {
48
-		return $this->user;
49
-	}
47
+    public function getUser() {
48
+        return $this->user;
49
+    }
50 50
 
51
-	public function isLoggedIn() {
52
-		return !is_null($this->user);
53
-	}
51
+    public function isLoggedIn() {
52
+        return !is_null($this->user);
53
+    }
54 54
 
55
-	/**
56
-	 * get getImpersonatingUserID
57
-	 *
58
-	 * @return string|null
59
-	 * @since 17.0.0
60
-	 */
61
-	public function getImpersonatingUserID() : ?string {
62
-		return null;
63
-	}
55
+    /**
56
+     * get getImpersonatingUserID
57
+     *
58
+     * @return string|null
59
+     * @since 17.0.0
60
+     */
61
+    public function getImpersonatingUserID() : ?string {
62
+        return null;
63
+    }
64 64
 
65
-	/**
66
-	 * set setImpersonatingUserID
67
-	 *
68
-	 * @since 17.0.0
69
-	 */
70
-	public function setImpersonatingUserID(bool $useCurrentUser = true): void {
71
-		//no OP
72
-	}
65
+    /**
66
+     * set setImpersonatingUserID
67
+     *
68
+     * @since 17.0.0
69
+     */
70
+    public function setImpersonatingUserID(bool $useCurrentUser = true): void {
71
+        //no OP
72
+    }
73 73
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Lib/Auth/Password/UserProvided.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -38,51 +38,51 @@
 block discarded – undo
38 38
  * User provided Username and Password
39 39
  */
40 40
 class UserProvided extends AuthMechanism implements IUserProvided {
41
-	public const CREDENTIALS_IDENTIFIER_PREFIX = 'password::userprovided/';
41
+    public const CREDENTIALS_IDENTIFIER_PREFIX = 'password::userprovided/';
42 42
 
43
-	/** @var ICredentialsManager */
44
-	protected $credentialsManager;
43
+    /** @var ICredentialsManager */
44
+    protected $credentialsManager;
45 45
 
46
-	public function __construct(IL10N $l, ICredentialsManager $credentialsManager) {
47
-		$this->credentialsManager = $credentialsManager;
46
+    public function __construct(IL10N $l, ICredentialsManager $credentialsManager) {
47
+        $this->credentialsManager = $credentialsManager;
48 48
 
49
-		$this
50
-			->setIdentifier('password::userprovided')
51
-			->setVisibility(BackendService::VISIBILITY_ADMIN)
52
-			->setScheme(self::SCHEME_PASSWORD)
53
-			->setText($l->t('User entered, store in database'))
54
-			->addParameters([
55
-				(new DefinitionParameter('user', $l->t('Username')))
56
-					->setFlag(DefinitionParameter::FLAG_USER_PROVIDED),
57
-				(new DefinitionParameter('password', $l->t('Password')))
58
-					->setType(DefinitionParameter::VALUE_PASSWORD)
59
-					->setFlag(DefinitionParameter::FLAG_USER_PROVIDED),
60
-			]);
61
-	}
49
+        $this
50
+            ->setIdentifier('password::userprovided')
51
+            ->setVisibility(BackendService::VISIBILITY_ADMIN)
52
+            ->setScheme(self::SCHEME_PASSWORD)
53
+            ->setText($l->t('User entered, store in database'))
54
+            ->addParameters([
55
+                (new DefinitionParameter('user', $l->t('Username')))
56
+                    ->setFlag(DefinitionParameter::FLAG_USER_PROVIDED),
57
+                (new DefinitionParameter('password', $l->t('Password')))
58
+                    ->setType(DefinitionParameter::VALUE_PASSWORD)
59
+                    ->setFlag(DefinitionParameter::FLAG_USER_PROVIDED),
60
+            ]);
61
+    }
62 62
 
63
-	private function getCredentialsIdentifier($storageId) {
64
-		return self::CREDENTIALS_IDENTIFIER_PREFIX . $storageId;
65
-	}
63
+    private function getCredentialsIdentifier($storageId) {
64
+        return self::CREDENTIALS_IDENTIFIER_PREFIX . $storageId;
65
+    }
66 66
 
67
-	public function saveBackendOptions(IUser $user, $mountId, array $options) {
68
-		$this->credentialsManager->store($user->getUID(), $this->getCredentialsIdentifier($mountId), [
69
-			'user' => $options['user'], // explicitly copy the fields we want instead of just passing the entire $options array
70
-			'password' => $options['password'] // this way we prevent users from being able to modify any other field
71
-		]);
72
-	}
67
+    public function saveBackendOptions(IUser $user, $mountId, array $options) {
68
+        $this->credentialsManager->store($user->getUID(), $this->getCredentialsIdentifier($mountId), [
69
+            'user' => $options['user'], // explicitly copy the fields we want instead of just passing the entire $options array
70
+            'password' => $options['password'] // this way we prevent users from being able to modify any other field
71
+        ]);
72
+    }
73 73
 
74
-	public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) {
75
-		if (!isset($user)) {
76
-			throw new InsufficientDataForMeaningfulAnswerException('No credentials saved');
77
-		}
78
-		$uid = $user->getUID();
79
-		$credentials = $this->credentialsManager->retrieve($uid, $this->getCredentialsIdentifier($storage->getId()));
74
+    public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) {
75
+        if (!isset($user)) {
76
+            throw new InsufficientDataForMeaningfulAnswerException('No credentials saved');
77
+        }
78
+        $uid = $user->getUID();
79
+        $credentials = $this->credentialsManager->retrieve($uid, $this->getCredentialsIdentifier($storage->getId()));
80 80
 
81
-		if (!isset($credentials)) {
82
-			throw new InsufficientDataForMeaningfulAnswerException('No credentials saved');
83
-		}
81
+        if (!isset($credentials)) {
82
+            throw new InsufficientDataForMeaningfulAnswerException('No credentials saved');
83
+        }
84 84
 
85
-		$storage->setBackendOption('user', $credentials['user']);
86
-		$storage->setBackendOption('password', $credentials['password']);
87
-	}
85
+        $storage->setBackendOption('user', $credentials['user']);
86
+        $storage->setBackendOption('password', $credentials['password']);
87
+    }
88 88
 }
Please login to merge, or discard this patch.
lib/public/IUserSession.php 1 patch
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -43,61 +43,61 @@
 block discarded – undo
43 43
  * @since 6.0.0
44 44
  */
45 45
 interface IUserSession {
46
-	/**
47
-	 * Do a user login
48
-	 *
49
-	 * @param string $uid the username
50
-	 * @param string $password the password
51
-	 * @return bool true if successful
52
-	 * @since 6.0.0
53
-	 */
54
-	public function login($uid, $password);
46
+    /**
47
+     * Do a user login
48
+     *
49
+     * @param string $uid the username
50
+     * @param string $password the password
51
+     * @return bool true if successful
52
+     * @since 6.0.0
53
+     */
54
+    public function login($uid, $password);
55 55
 
56
-	/**
57
-	 * Logs the user out including all the session data
58
-	 * Logout, destroys session
59
-	 *
60
-	 * @return void
61
-	 * @since 6.0.0
62
-	 */
63
-	public function logout();
56
+    /**
57
+     * Logs the user out including all the session data
58
+     * Logout, destroys session
59
+     *
60
+     * @return void
61
+     * @since 6.0.0
62
+     */
63
+    public function logout();
64 64
 
65
-	/**
66
-	 * set the currently active user
67
-	 *
68
-	 * @param \OCP\IUser|null $user
69
-	 * @since 8.0.0
70
-	 */
71
-	public function setUser($user);
65
+    /**
66
+     * set the currently active user
67
+     *
68
+     * @param \OCP\IUser|null $user
69
+     * @since 8.0.0
70
+     */
71
+    public function setUser($user);
72 72
 
73
-	/**
74
-	 * get the current active user
75
-	 *
76
-	 * @return \OCP\IUser|null Current user, otherwise null
77
-	 * @since 8.0.0
78
-	 */
79
-	public function getUser();
73
+    /**
74
+     * get the current active user
75
+     *
76
+     * @return \OCP\IUser|null Current user, otherwise null
77
+     * @since 8.0.0
78
+     */
79
+    public function getUser();
80 80
 
81
-	/**
82
-	 * Checks whether the user is logged in
83
-	 *
84
-	 * @return bool if logged in
85
-	 * @since 8.0.0
86
-	 */
87
-	public function isLoggedIn();
81
+    /**
82
+     * Checks whether the user is logged in
83
+     *
84
+     * @return bool if logged in
85
+     * @since 8.0.0
86
+     */
87
+    public function isLoggedIn();
88 88
 
89
-	/**
90
-	 * get getImpersonatingUserID
91
-	 *
92
-	 * @return string|null
93
-	 * @since 18.0.0
94
-	 */
95
-	public function getImpersonatingUserID(): ?string;
89
+    /**
90
+     * get getImpersonatingUserID
91
+     *
92
+     * @return string|null
93
+     * @since 18.0.0
94
+     */
95
+    public function getImpersonatingUserID(): ?string;
96 96
 
97
-	/**
98
-	 * set setImpersonatingUserID
99
-	 *
100
-	 * @since 18.0.0
101
-	 */
102
-	public function setImpersonatingUserID(bool $useCurrentUser = true): void;
97
+    /**
98
+     * set setImpersonatingUserID
99
+     *
100
+     * @since 18.0.0
101
+     */
102
+    public function setImpersonatingUserID(bool $useCurrentUser = true): void;
103 103
 }
Please login to merge, or discard this patch.