Passed
Push — master ( 078203...c81798 )
by Joas
14:40 queued 14s
created
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/private/SystemTag/SystemTagManager.php 1 patch
Indentation   +385 added lines, -385 removed lines patch added patch discarded remove patch
@@ -45,389 +45,389 @@
 block discarded – undo
45 45
  * Manager class for system tags
46 46
  */
47 47
 class SystemTagManager implements ISystemTagManager {
48
-	public const TAG_TABLE = 'systemtag';
49
-	public const TAG_GROUP_TABLE = 'systemtag_group';
50
-
51
-	/** @var IDBConnection */
52
-	protected $connection;
53
-
54
-	/** @var EventDispatcherInterface */
55
-	protected $dispatcher;
56
-
57
-	/** @var IGroupManager */
58
-	protected $groupManager;
59
-
60
-	/**
61
-	 * Prepared query for selecting tags directly
62
-	 *
63
-	 * @var \OCP\DB\QueryBuilder\IQueryBuilder
64
-	 */
65
-	private $selectTagQuery;
66
-
67
-	/**
68
-	 * Constructor.
69
-	 *
70
-	 * @param IDBConnection $connection database connection
71
-	 * @param IGroupManager $groupManager
72
-	 * @param EventDispatcherInterface $dispatcher
73
-	 */
74
-	public function __construct(
75
-		IDBConnection $connection,
76
-		IGroupManager $groupManager,
77
-		EventDispatcherInterface $dispatcher
78
-	) {
79
-		$this->connection = $connection;
80
-		$this->groupManager = $groupManager;
81
-		$this->dispatcher = $dispatcher;
82
-
83
-		$query = $this->connection->getQueryBuilder();
84
-		$this->selectTagQuery = $query->select('*')
85
-			->from(self::TAG_TABLE)
86
-			->where($query->expr()->eq('name', $query->createParameter('name')))
87
-			->andWhere($query->expr()->eq('visibility', $query->createParameter('visibility')))
88
-			->andWhere($query->expr()->eq('editable', $query->createParameter('editable')));
89
-	}
90
-
91
-	/**
92
-	 * {@inheritdoc}
93
-	 */
94
-	public function getTagsByIds($tagIds): array {
95
-		if (!\is_array($tagIds)) {
96
-			$tagIds = [$tagIds];
97
-		}
98
-
99
-		$tags = [];
100
-
101
-		// note: not all databases will fail if it's a string or starts with a number
102
-		foreach ($tagIds as $tagId) {
103
-			if (!is_numeric($tagId)) {
104
-				throw new \InvalidArgumentException('Tag id must be integer');
105
-			}
106
-		}
107
-
108
-		$query = $this->connection->getQueryBuilder();
109
-		$query->select('*')
110
-			->from(self::TAG_TABLE)
111
-			->where($query->expr()->in('id', $query->createParameter('tagids')))
112
-			->addOrderBy('name', 'ASC')
113
-			->addOrderBy('visibility', 'ASC')
114
-			->addOrderBy('editable', 'ASC')
115
-			->setParameter('tagids', $tagIds, IQueryBuilder::PARAM_INT_ARRAY);
116
-
117
-		$result = $query->execute();
118
-		while ($row = $result->fetch()) {
119
-			$tags[$row['id']] = $this->createSystemTagFromRow($row);
120
-		}
121
-
122
-		$result->closeCursor();
123
-
124
-		if (\count($tags) !== \count($tagIds)) {
125
-			throw new TagNotFoundException(
126
-				'Tag id(s) not found', 0, null, array_diff($tagIds, array_keys($tags))
127
-			);
128
-		}
129
-
130
-		return $tags;
131
-	}
132
-
133
-	/**
134
-	 * {@inheritdoc}
135
-	 */
136
-	public function getAllTags($visibilityFilter = null, $nameSearchPattern = null): array {
137
-		$tags = [];
138
-
139
-		$query = $this->connection->getQueryBuilder();
140
-		$query->select('*')
141
-			->from(self::TAG_TABLE);
142
-
143
-		if (!\is_null($visibilityFilter)) {
144
-			$query->andWhere($query->expr()->eq('visibility', $query->createNamedParameter((int)$visibilityFilter)));
145
-		}
146
-
147
-		if (!empty($nameSearchPattern)) {
148
-			$query->andWhere(
149
-				$query->expr()->like(
150
-					'name',
151
-					$query->createNamedParameter('%' . $this->connection->escapeLikeParameter($nameSearchPattern). '%')
152
-				)
153
-			);
154
-		}
155
-
156
-		$query
157
-			->addOrderBy('name', 'ASC')
158
-			->addOrderBy('visibility', 'ASC')
159
-			->addOrderBy('editable', 'ASC');
160
-
161
-		$result = $query->execute();
162
-		while ($row = $result->fetch()) {
163
-			$tags[$row['id']] = $this->createSystemTagFromRow($row);
164
-		}
165
-
166
-		$result->closeCursor();
167
-
168
-		return $tags;
169
-	}
170
-
171
-	/**
172
-	 * {@inheritdoc}
173
-	 */
174
-	public function getTag(string $tagName, bool $userVisible, bool $userAssignable): ISystemTag {
175
-		$result = $this->selectTagQuery
176
-			->setParameter('name', $tagName)
177
-			->setParameter('visibility', $userVisible ? 1 : 0)
178
-			->setParameter('editable', $userAssignable ? 1 : 0)
179
-			->execute();
180
-
181
-		$row = $result->fetch();
182
-		$result->closeCursor();
183
-		if (!$row) {
184
-			throw new TagNotFoundException(
185
-				'Tag ("' . $tagName . '", '. $userVisible . ', ' . $userAssignable . ') does not exist'
186
-			);
187
-		}
188
-
189
-		return $this->createSystemTagFromRow($row);
190
-	}
191
-
192
-	/**
193
-	 * {@inheritdoc}
194
-	 */
195
-	public function createTag(string $tagName, bool $userVisible, bool $userAssignable): ISystemTag {
196
-		$query = $this->connection->getQueryBuilder();
197
-		$query->insert(self::TAG_TABLE)
198
-			->values([
199
-				'name' => $query->createNamedParameter($tagName),
200
-				'visibility' => $query->createNamedParameter($userVisible ? 1 : 0),
201
-				'editable' => $query->createNamedParameter($userAssignable ? 1 : 0),
202
-			]);
203
-
204
-		try {
205
-			$query->execute();
206
-		} catch (UniqueConstraintViolationException $e) {
207
-			throw new TagAlreadyExistsException(
208
-				'Tag ("' . $tagName . '", '. $userVisible . ', ' . $userAssignable . ') already exists',
209
-				0,
210
-				$e
211
-			);
212
-		}
213
-
214
-		$tagId = $query->getLastInsertId();
215
-
216
-		$tag = new SystemTag(
217
-			(string)$tagId,
218
-			$tagName,
219
-			$userVisible,
220
-			$userAssignable
221
-		);
222
-
223
-		$this->dispatcher->dispatch(ManagerEvent::EVENT_CREATE, new ManagerEvent(
224
-			ManagerEvent::EVENT_CREATE, $tag
225
-		));
226
-
227
-		return $tag;
228
-	}
229
-
230
-	/**
231
-	 * {@inheritdoc}
232
-	 */
233
-	public function updateTag(string $tagId, string $newName, bool $userVisible, bool $userAssignable) {
234
-		try {
235
-			$tags = $this->getTagsByIds($tagId);
236
-		} catch (TagNotFoundException $e) {
237
-			throw new TagNotFoundException(
238
-				'Tag does not exist', 0, null, [$tagId]
239
-			);
240
-		}
241
-
242
-		$beforeUpdate = array_shift($tags);
243
-		$afterUpdate = new SystemTag(
244
-			$tagId,
245
-			$newName,
246
-			$userVisible,
247
-			$userAssignable
248
-		);
249
-
250
-		$query = $this->connection->getQueryBuilder();
251
-		$query->update(self::TAG_TABLE)
252
-			->set('name', $query->createParameter('name'))
253
-			->set('visibility', $query->createParameter('visibility'))
254
-			->set('editable', $query->createParameter('editable'))
255
-			->where($query->expr()->eq('id', $query->createParameter('tagid')))
256
-			->setParameter('name', $newName)
257
-			->setParameter('visibility', $userVisible ? 1 : 0)
258
-			->setParameter('editable', $userAssignable ? 1 : 0)
259
-			->setParameter('tagid', $tagId);
260
-
261
-		try {
262
-			if ($query->execute() === 0) {
263
-				throw new TagNotFoundException(
264
-					'Tag does not exist', 0, null, [$tagId]
265
-				);
266
-			}
267
-		} catch (UniqueConstraintViolationException $e) {
268
-			throw new TagAlreadyExistsException(
269
-				'Tag ("' . $newName . '", '. $userVisible . ', ' . $userAssignable . ') already exists',
270
-				0,
271
-				$e
272
-			);
273
-		}
274
-
275
-		$this->dispatcher->dispatch(ManagerEvent::EVENT_UPDATE, new ManagerEvent(
276
-			ManagerEvent::EVENT_UPDATE, $afterUpdate, $beforeUpdate
277
-		));
278
-	}
279
-
280
-	/**
281
-	 * {@inheritdoc}
282
-	 */
283
-	public function deleteTags($tagIds) {
284
-		if (!\is_array($tagIds)) {
285
-			$tagIds = [$tagIds];
286
-		}
287
-
288
-		$tagNotFoundException = null;
289
-		$tags = [];
290
-		try {
291
-			$tags = $this->getTagsByIds($tagIds);
292
-		} catch (TagNotFoundException $e) {
293
-			$tagNotFoundException = $e;
294
-
295
-			// Get existing tag objects for the hooks later
296
-			$existingTags = array_diff($tagIds, $tagNotFoundException->getMissingTags());
297
-			if (!empty($existingTags)) {
298
-				try {
299
-					$tags = $this->getTagsByIds($existingTags);
300
-				} catch (TagNotFoundException $e) {
301
-					// Ignore further errors...
302
-				}
303
-			}
304
-		}
305
-
306
-		// delete relationships first
307
-		$query = $this->connection->getQueryBuilder();
308
-		$query->delete(SystemTagObjectMapper::RELATION_TABLE)
309
-			->where($query->expr()->in('systemtagid', $query->createParameter('tagids')))
310
-			->setParameter('tagids', $tagIds, IQueryBuilder::PARAM_INT_ARRAY)
311
-			->execute();
312
-
313
-		$query = $this->connection->getQueryBuilder();
314
-		$query->delete(self::TAG_TABLE)
315
-			->where($query->expr()->in('id', $query->createParameter('tagids')))
316
-			->setParameter('tagids', $tagIds, IQueryBuilder::PARAM_INT_ARRAY)
317
-			->execute();
318
-
319
-		foreach ($tags as $tag) {
320
-			$this->dispatcher->dispatch(ManagerEvent::EVENT_DELETE, new ManagerEvent(
321
-				ManagerEvent::EVENT_DELETE, $tag
322
-			));
323
-		}
324
-
325
-		if ($tagNotFoundException !== null) {
326
-			throw new TagNotFoundException(
327
-				'Tag id(s) not found', 0, $tagNotFoundException, $tagNotFoundException->getMissingTags()
328
-			);
329
-		}
330
-	}
331
-
332
-	/**
333
-	 * {@inheritdoc}
334
-	 */
335
-	public function canUserAssignTag(ISystemTag $tag, IUser $user): bool {
336
-		// early check to avoid unneeded group lookups
337
-		if ($tag->isUserAssignable() && $tag->isUserVisible()) {
338
-			return true;
339
-		}
340
-
341
-		if ($this->groupManager->isAdmin($user->getUID())) {
342
-			return true;
343
-		}
344
-
345
-		if (!$tag->isUserVisible()) {
346
-			return false;
347
-		}
348
-
349
-		$groupIds = $this->groupManager->getUserGroupIds($user);
350
-		if (!empty($groupIds)) {
351
-			$matchingGroups = array_intersect($groupIds, $this->getTagGroups($tag));
352
-			if (!empty($matchingGroups)) {
353
-				return true;
354
-			}
355
-		}
356
-
357
-		return false;
358
-	}
359
-
360
-	/**
361
-	 * {@inheritdoc}
362
-	 */
363
-	public function canUserSeeTag(ISystemTag $tag, IUser $user): bool {
364
-		if ($tag->isUserVisible()) {
365
-			return true;
366
-		}
367
-
368
-		if ($this->groupManager->isAdmin($user->getUID())) {
369
-			return true;
370
-		}
371
-
372
-		return false;
373
-	}
374
-
375
-	private function createSystemTagFromRow($row) {
376
-		return new SystemTag((string)$row['id'], $row['name'], (bool)$row['visibility'], (bool)$row['editable']);
377
-	}
378
-
379
-	/**
380
-	 * {@inheritdoc}
381
-	 */
382
-	public function setTagGroups(ISystemTag $tag, array $groupIds) {
383
-		// delete relationships first
384
-		$this->connection->beginTransaction();
385
-		try {
386
-			$query = $this->connection->getQueryBuilder();
387
-			$query->delete(self::TAG_GROUP_TABLE)
388
-				->where($query->expr()->eq('systemtagid', $query->createNamedParameter($tag->getId())))
389
-				->execute();
390
-
391
-			// add each group id
392
-			$query = $this->connection->getQueryBuilder();
393
-			$query->insert(self::TAG_GROUP_TABLE)
394
-				->values([
395
-					'systemtagid' => $query->createNamedParameter($tag->getId()),
396
-					'gid' => $query->createParameter('gid'),
397
-				]);
398
-			foreach ($groupIds as $groupId) {
399
-				if ($groupId === '') {
400
-					continue;
401
-				}
402
-				$query->setParameter('gid', $groupId);
403
-				$query->execute();
404
-			}
405
-
406
-			$this->connection->commit();
407
-		} catch (\Exception $e) {
408
-			$this->connection->rollBack();
409
-			throw $e;
410
-		}
411
-	}
412
-
413
-	/**
414
-	 * {@inheritdoc}
415
-	 */
416
-	public function getTagGroups(ISystemTag $tag): array {
417
-		$groupIds = [];
418
-		$query = $this->connection->getQueryBuilder();
419
-		$query->select('gid')
420
-			->from(self::TAG_GROUP_TABLE)
421
-			->where($query->expr()->eq('systemtagid', $query->createNamedParameter($tag->getId())))
422
-			->orderBy('gid');
423
-
424
-		$result = $query->execute();
425
-		while ($row = $result->fetch()) {
426
-			$groupIds[] = $row['gid'];
427
-		}
428
-
429
-		$result->closeCursor();
430
-
431
-		return $groupIds;
432
-	}
48
+    public const TAG_TABLE = 'systemtag';
49
+    public const TAG_GROUP_TABLE = 'systemtag_group';
50
+
51
+    /** @var IDBConnection */
52
+    protected $connection;
53
+
54
+    /** @var EventDispatcherInterface */
55
+    protected $dispatcher;
56
+
57
+    /** @var IGroupManager */
58
+    protected $groupManager;
59
+
60
+    /**
61
+     * Prepared query for selecting tags directly
62
+     *
63
+     * @var \OCP\DB\QueryBuilder\IQueryBuilder
64
+     */
65
+    private $selectTagQuery;
66
+
67
+    /**
68
+     * Constructor.
69
+     *
70
+     * @param IDBConnection $connection database connection
71
+     * @param IGroupManager $groupManager
72
+     * @param EventDispatcherInterface $dispatcher
73
+     */
74
+    public function __construct(
75
+        IDBConnection $connection,
76
+        IGroupManager $groupManager,
77
+        EventDispatcherInterface $dispatcher
78
+    ) {
79
+        $this->connection = $connection;
80
+        $this->groupManager = $groupManager;
81
+        $this->dispatcher = $dispatcher;
82
+
83
+        $query = $this->connection->getQueryBuilder();
84
+        $this->selectTagQuery = $query->select('*')
85
+            ->from(self::TAG_TABLE)
86
+            ->where($query->expr()->eq('name', $query->createParameter('name')))
87
+            ->andWhere($query->expr()->eq('visibility', $query->createParameter('visibility')))
88
+            ->andWhere($query->expr()->eq('editable', $query->createParameter('editable')));
89
+    }
90
+
91
+    /**
92
+     * {@inheritdoc}
93
+     */
94
+    public function getTagsByIds($tagIds): array {
95
+        if (!\is_array($tagIds)) {
96
+            $tagIds = [$tagIds];
97
+        }
98
+
99
+        $tags = [];
100
+
101
+        // note: not all databases will fail if it's a string or starts with a number
102
+        foreach ($tagIds as $tagId) {
103
+            if (!is_numeric($tagId)) {
104
+                throw new \InvalidArgumentException('Tag id must be integer');
105
+            }
106
+        }
107
+
108
+        $query = $this->connection->getQueryBuilder();
109
+        $query->select('*')
110
+            ->from(self::TAG_TABLE)
111
+            ->where($query->expr()->in('id', $query->createParameter('tagids')))
112
+            ->addOrderBy('name', 'ASC')
113
+            ->addOrderBy('visibility', 'ASC')
114
+            ->addOrderBy('editable', 'ASC')
115
+            ->setParameter('tagids', $tagIds, IQueryBuilder::PARAM_INT_ARRAY);
116
+
117
+        $result = $query->execute();
118
+        while ($row = $result->fetch()) {
119
+            $tags[$row['id']] = $this->createSystemTagFromRow($row);
120
+        }
121
+
122
+        $result->closeCursor();
123
+
124
+        if (\count($tags) !== \count($tagIds)) {
125
+            throw new TagNotFoundException(
126
+                'Tag id(s) not found', 0, null, array_diff($tagIds, array_keys($tags))
127
+            );
128
+        }
129
+
130
+        return $tags;
131
+    }
132
+
133
+    /**
134
+     * {@inheritdoc}
135
+     */
136
+    public function getAllTags($visibilityFilter = null, $nameSearchPattern = null): array {
137
+        $tags = [];
138
+
139
+        $query = $this->connection->getQueryBuilder();
140
+        $query->select('*')
141
+            ->from(self::TAG_TABLE);
142
+
143
+        if (!\is_null($visibilityFilter)) {
144
+            $query->andWhere($query->expr()->eq('visibility', $query->createNamedParameter((int)$visibilityFilter)));
145
+        }
146
+
147
+        if (!empty($nameSearchPattern)) {
148
+            $query->andWhere(
149
+                $query->expr()->like(
150
+                    'name',
151
+                    $query->createNamedParameter('%' . $this->connection->escapeLikeParameter($nameSearchPattern). '%')
152
+                )
153
+            );
154
+        }
155
+
156
+        $query
157
+            ->addOrderBy('name', 'ASC')
158
+            ->addOrderBy('visibility', 'ASC')
159
+            ->addOrderBy('editable', 'ASC');
160
+
161
+        $result = $query->execute();
162
+        while ($row = $result->fetch()) {
163
+            $tags[$row['id']] = $this->createSystemTagFromRow($row);
164
+        }
165
+
166
+        $result->closeCursor();
167
+
168
+        return $tags;
169
+    }
170
+
171
+    /**
172
+     * {@inheritdoc}
173
+     */
174
+    public function getTag(string $tagName, bool $userVisible, bool $userAssignable): ISystemTag {
175
+        $result = $this->selectTagQuery
176
+            ->setParameter('name', $tagName)
177
+            ->setParameter('visibility', $userVisible ? 1 : 0)
178
+            ->setParameter('editable', $userAssignable ? 1 : 0)
179
+            ->execute();
180
+
181
+        $row = $result->fetch();
182
+        $result->closeCursor();
183
+        if (!$row) {
184
+            throw new TagNotFoundException(
185
+                'Tag ("' . $tagName . '", '. $userVisible . ', ' . $userAssignable . ') does not exist'
186
+            );
187
+        }
188
+
189
+        return $this->createSystemTagFromRow($row);
190
+    }
191
+
192
+    /**
193
+     * {@inheritdoc}
194
+     */
195
+    public function createTag(string $tagName, bool $userVisible, bool $userAssignable): ISystemTag {
196
+        $query = $this->connection->getQueryBuilder();
197
+        $query->insert(self::TAG_TABLE)
198
+            ->values([
199
+                'name' => $query->createNamedParameter($tagName),
200
+                'visibility' => $query->createNamedParameter($userVisible ? 1 : 0),
201
+                'editable' => $query->createNamedParameter($userAssignable ? 1 : 0),
202
+            ]);
203
+
204
+        try {
205
+            $query->execute();
206
+        } catch (UniqueConstraintViolationException $e) {
207
+            throw new TagAlreadyExistsException(
208
+                'Tag ("' . $tagName . '", '. $userVisible . ', ' . $userAssignable . ') already exists',
209
+                0,
210
+                $e
211
+            );
212
+        }
213
+
214
+        $tagId = $query->getLastInsertId();
215
+
216
+        $tag = new SystemTag(
217
+            (string)$tagId,
218
+            $tagName,
219
+            $userVisible,
220
+            $userAssignable
221
+        );
222
+
223
+        $this->dispatcher->dispatch(ManagerEvent::EVENT_CREATE, new ManagerEvent(
224
+            ManagerEvent::EVENT_CREATE, $tag
225
+        ));
226
+
227
+        return $tag;
228
+    }
229
+
230
+    /**
231
+     * {@inheritdoc}
232
+     */
233
+    public function updateTag(string $tagId, string $newName, bool $userVisible, bool $userAssignable) {
234
+        try {
235
+            $tags = $this->getTagsByIds($tagId);
236
+        } catch (TagNotFoundException $e) {
237
+            throw new TagNotFoundException(
238
+                'Tag does not exist', 0, null, [$tagId]
239
+            );
240
+        }
241
+
242
+        $beforeUpdate = array_shift($tags);
243
+        $afterUpdate = new SystemTag(
244
+            $tagId,
245
+            $newName,
246
+            $userVisible,
247
+            $userAssignable
248
+        );
249
+
250
+        $query = $this->connection->getQueryBuilder();
251
+        $query->update(self::TAG_TABLE)
252
+            ->set('name', $query->createParameter('name'))
253
+            ->set('visibility', $query->createParameter('visibility'))
254
+            ->set('editable', $query->createParameter('editable'))
255
+            ->where($query->expr()->eq('id', $query->createParameter('tagid')))
256
+            ->setParameter('name', $newName)
257
+            ->setParameter('visibility', $userVisible ? 1 : 0)
258
+            ->setParameter('editable', $userAssignable ? 1 : 0)
259
+            ->setParameter('tagid', $tagId);
260
+
261
+        try {
262
+            if ($query->execute() === 0) {
263
+                throw new TagNotFoundException(
264
+                    'Tag does not exist', 0, null, [$tagId]
265
+                );
266
+            }
267
+        } catch (UniqueConstraintViolationException $e) {
268
+            throw new TagAlreadyExistsException(
269
+                'Tag ("' . $newName . '", '. $userVisible . ', ' . $userAssignable . ') already exists',
270
+                0,
271
+                $e
272
+            );
273
+        }
274
+
275
+        $this->dispatcher->dispatch(ManagerEvent::EVENT_UPDATE, new ManagerEvent(
276
+            ManagerEvent::EVENT_UPDATE, $afterUpdate, $beforeUpdate
277
+        ));
278
+    }
279
+
280
+    /**
281
+     * {@inheritdoc}
282
+     */
283
+    public function deleteTags($tagIds) {
284
+        if (!\is_array($tagIds)) {
285
+            $tagIds = [$tagIds];
286
+        }
287
+
288
+        $tagNotFoundException = null;
289
+        $tags = [];
290
+        try {
291
+            $tags = $this->getTagsByIds($tagIds);
292
+        } catch (TagNotFoundException $e) {
293
+            $tagNotFoundException = $e;
294
+
295
+            // Get existing tag objects for the hooks later
296
+            $existingTags = array_diff($tagIds, $tagNotFoundException->getMissingTags());
297
+            if (!empty($existingTags)) {
298
+                try {
299
+                    $tags = $this->getTagsByIds($existingTags);
300
+                } catch (TagNotFoundException $e) {
301
+                    // Ignore further errors...
302
+                }
303
+            }
304
+        }
305
+
306
+        // delete relationships first
307
+        $query = $this->connection->getQueryBuilder();
308
+        $query->delete(SystemTagObjectMapper::RELATION_TABLE)
309
+            ->where($query->expr()->in('systemtagid', $query->createParameter('tagids')))
310
+            ->setParameter('tagids', $tagIds, IQueryBuilder::PARAM_INT_ARRAY)
311
+            ->execute();
312
+
313
+        $query = $this->connection->getQueryBuilder();
314
+        $query->delete(self::TAG_TABLE)
315
+            ->where($query->expr()->in('id', $query->createParameter('tagids')))
316
+            ->setParameter('tagids', $tagIds, IQueryBuilder::PARAM_INT_ARRAY)
317
+            ->execute();
318
+
319
+        foreach ($tags as $tag) {
320
+            $this->dispatcher->dispatch(ManagerEvent::EVENT_DELETE, new ManagerEvent(
321
+                ManagerEvent::EVENT_DELETE, $tag
322
+            ));
323
+        }
324
+
325
+        if ($tagNotFoundException !== null) {
326
+            throw new TagNotFoundException(
327
+                'Tag id(s) not found', 0, $tagNotFoundException, $tagNotFoundException->getMissingTags()
328
+            );
329
+        }
330
+    }
331
+
332
+    /**
333
+     * {@inheritdoc}
334
+     */
335
+    public function canUserAssignTag(ISystemTag $tag, IUser $user): bool {
336
+        // early check to avoid unneeded group lookups
337
+        if ($tag->isUserAssignable() && $tag->isUserVisible()) {
338
+            return true;
339
+        }
340
+
341
+        if ($this->groupManager->isAdmin($user->getUID())) {
342
+            return true;
343
+        }
344
+
345
+        if (!$tag->isUserVisible()) {
346
+            return false;
347
+        }
348
+
349
+        $groupIds = $this->groupManager->getUserGroupIds($user);
350
+        if (!empty($groupIds)) {
351
+            $matchingGroups = array_intersect($groupIds, $this->getTagGroups($tag));
352
+            if (!empty($matchingGroups)) {
353
+                return true;
354
+            }
355
+        }
356
+
357
+        return false;
358
+    }
359
+
360
+    /**
361
+     * {@inheritdoc}
362
+     */
363
+    public function canUserSeeTag(ISystemTag $tag, IUser $user): bool {
364
+        if ($tag->isUserVisible()) {
365
+            return true;
366
+        }
367
+
368
+        if ($this->groupManager->isAdmin($user->getUID())) {
369
+            return true;
370
+        }
371
+
372
+        return false;
373
+    }
374
+
375
+    private function createSystemTagFromRow($row) {
376
+        return new SystemTag((string)$row['id'], $row['name'], (bool)$row['visibility'], (bool)$row['editable']);
377
+    }
378
+
379
+    /**
380
+     * {@inheritdoc}
381
+     */
382
+    public function setTagGroups(ISystemTag $tag, array $groupIds) {
383
+        // delete relationships first
384
+        $this->connection->beginTransaction();
385
+        try {
386
+            $query = $this->connection->getQueryBuilder();
387
+            $query->delete(self::TAG_GROUP_TABLE)
388
+                ->where($query->expr()->eq('systemtagid', $query->createNamedParameter($tag->getId())))
389
+                ->execute();
390
+
391
+            // add each group id
392
+            $query = $this->connection->getQueryBuilder();
393
+            $query->insert(self::TAG_GROUP_TABLE)
394
+                ->values([
395
+                    'systemtagid' => $query->createNamedParameter($tag->getId()),
396
+                    'gid' => $query->createParameter('gid'),
397
+                ]);
398
+            foreach ($groupIds as $groupId) {
399
+                if ($groupId === '') {
400
+                    continue;
401
+                }
402
+                $query->setParameter('gid', $groupId);
403
+                $query->execute();
404
+            }
405
+
406
+            $this->connection->commit();
407
+        } catch (\Exception $e) {
408
+            $this->connection->rollBack();
409
+            throw $e;
410
+        }
411
+    }
412
+
413
+    /**
414
+     * {@inheritdoc}
415
+     */
416
+    public function getTagGroups(ISystemTag $tag): array {
417
+        $groupIds = [];
418
+        $query = $this->connection->getQueryBuilder();
419
+        $query->select('gid')
420
+            ->from(self::TAG_GROUP_TABLE)
421
+            ->where($query->expr()->eq('systemtagid', $query->createNamedParameter($tag->getId())))
422
+            ->orderBy('gid');
423
+
424
+        $result = $query->execute();
425
+        while ($row = $result->fetch()) {
426
+            $groupIds[] = $row['gid'];
427
+        }
428
+
429
+        $result->closeCursor();
430
+
431
+        return $groupIds;
432
+    }
433 433
 }
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.
apps/dav/lib/Events/CardCreatedEvent.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -34,67 +34,67 @@
 block discarded – undo
34 34
  */
35 35
 class CardCreatedEvent extends Event {
36 36
 
37
-	/** @var int */
38
-	private $addressBookId;
37
+    /** @var int */
38
+    private $addressBookId;
39 39
 
40
-	/** @var array */
41
-	private $addressBookData;
40
+    /** @var array */
41
+    private $addressBookData;
42 42
 
43
-	/** @var array */
44
-	private $shares;
43
+    /** @var array */
44
+    private $shares;
45 45
 
46
-	/** @var array */
47
-	private $cardData;
46
+    /** @var array */
47
+    private $cardData;
48 48
 
49
-	/**
50
-	 * CardCreatedEvent constructor.
51
-	 *
52
-	 * @param int $addressBookId
53
-	 * @param array $addressBookData
54
-	 * @param array $shares
55
-	 * @param array $cardData
56
-	 * @since 20.0.0
57
-	 */
58
-	public function __construct(int $addressBookId,
59
-								array $addressBookData,
60
-								array $shares,
61
-								array $cardData) {
62
-		parent::__construct();
63
-		$this->addressBookId = $addressBookId;
64
-		$this->addressBookData = $addressBookData;
65
-		$this->shares = $shares;
66
-		$this->cardData = $cardData;
67
-	}
49
+    /**
50
+     * CardCreatedEvent constructor.
51
+     *
52
+     * @param int $addressBookId
53
+     * @param array $addressBookData
54
+     * @param array $shares
55
+     * @param array $cardData
56
+     * @since 20.0.0
57
+     */
58
+    public function __construct(int $addressBookId,
59
+                                array $addressBookData,
60
+                                array $shares,
61
+                                array $cardData) {
62
+        parent::__construct();
63
+        $this->addressBookId = $addressBookId;
64
+        $this->addressBookData = $addressBookData;
65
+        $this->shares = $shares;
66
+        $this->cardData = $cardData;
67
+    }
68 68
 
69
-	/**
70
-	 * @return int
71
-	 * @since 20.0.0
72
-	 */
73
-	public function getAddressBookId(): int {
74
-		return $this->addressBookId;
75
-	}
69
+    /**
70
+     * @return int
71
+     * @since 20.0.0
72
+     */
73
+    public function getAddressBookId(): int {
74
+        return $this->addressBookId;
75
+    }
76 76
 
77
-	/**
78
-	 * @return array
79
-	 * @since 20.0.0
80
-	 */
81
-	public function getAddressBookData(): array {
82
-		return $this->addressBookData;
83
-	}
77
+    /**
78
+     * @return array
79
+     * @since 20.0.0
80
+     */
81
+    public function getAddressBookData(): array {
82
+        return $this->addressBookData;
83
+    }
84 84
 
85
-	/**
86
-	 * @return array
87
-	 * @since 20.0.0
88
-	 */
89
-	public function getShares(): array {
90
-		return $this->shares;
91
-	}
85
+    /**
86
+     * @return array
87
+     * @since 20.0.0
88
+     */
89
+    public function getShares(): array {
90
+        return $this->shares;
91
+    }
92 92
 
93
-	/**
94
-	 * @return array
95
-	 * @since 20.0.0
96
-	 */
97
-	public function getCardData(): array {
98
-		return $this->cardData;
99
-	}
93
+    /**
94
+     * @return array
95
+     * @since 20.0.0
96
+     */
97
+    public function getCardData(): array {
98
+        return $this->cardData;
99
+    }
100 100
 }
Please login to merge, or discard this patch.
apps/dav/lib/Events/CalendarObjectUpdatedEvent.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -34,67 +34,67 @@
 block discarded – undo
34 34
  */
35 35
 class CalendarObjectUpdatedEvent extends Event {
36 36
 
37
-	/** @var int */
38
-	private $calendarId;
37
+    /** @var int */
38
+    private $calendarId;
39 39
 
40
-	/** @var array */
41
-	private $calendarData;
40
+    /** @var array */
41
+    private $calendarData;
42 42
 
43
-	/** @var array */
44
-	private $shares;
43
+    /** @var array */
44
+    private $shares;
45 45
 
46
-	/** @var array */
47
-	private $objectData;
46
+    /** @var array */
47
+    private $objectData;
48 48
 
49
-	/**
50
-	 * CalendarObjectUpdatedEvent constructor.
51
-	 *
52
-	 * @param int $calendarId
53
-	 * @param array $calendarData
54
-	 * @param array $shares
55
-	 * @param array $objectData
56
-	 * @since 20.0.0
57
-	 */
58
-	public function __construct(int $calendarId,
59
-								array $calendarData,
60
-								array $shares,
61
-								array $objectData) {
62
-		parent::__construct();
63
-		$this->calendarId = $calendarId;
64
-		$this->calendarData = $calendarData;
65
-		$this->shares = $shares;
66
-		$this->objectData = $objectData;
67
-	}
49
+    /**
50
+     * CalendarObjectUpdatedEvent constructor.
51
+     *
52
+     * @param int $calendarId
53
+     * @param array $calendarData
54
+     * @param array $shares
55
+     * @param array $objectData
56
+     * @since 20.0.0
57
+     */
58
+    public function __construct(int $calendarId,
59
+                                array $calendarData,
60
+                                array $shares,
61
+                                array $objectData) {
62
+        parent::__construct();
63
+        $this->calendarId = $calendarId;
64
+        $this->calendarData = $calendarData;
65
+        $this->shares = $shares;
66
+        $this->objectData = $objectData;
67
+    }
68 68
 
69
-	/**
70
-	 * @return int
71
-	 * @since 20.0.0
72
-	 */
73
-	public function getCalendarId(): int {
74
-		return $this->calendarId;
75
-	}
69
+    /**
70
+     * @return int
71
+     * @since 20.0.0
72
+     */
73
+    public function getCalendarId(): int {
74
+        return $this->calendarId;
75
+    }
76 76
 
77
-	/**
78
-	 * @return array
79
-	 * @since 20.0.0
80
-	 */
81
-	public function getCalendarData(): array {
82
-		return $this->calendarData;
83
-	}
77
+    /**
78
+     * @return array
79
+     * @since 20.0.0
80
+     */
81
+    public function getCalendarData(): array {
82
+        return $this->calendarData;
83
+    }
84 84
 
85
-	/**
86
-	 * @return array
87
-	 * @since 20.0.0
88
-	 */
89
-	public function getShares(): array {
90
-		return $this->shares;
91
-	}
85
+    /**
86
+     * @return array
87
+     * @since 20.0.0
88
+     */
89
+    public function getShares(): array {
90
+        return $this->shares;
91
+    }
92 92
 
93
-	/**
94
-	 * @return array
95
-	 * @since 20.0.0
96
-	 */
97
-	public function getObjectData(): array {
98
-		return $this->objectData;
99
-	}
93
+    /**
94
+     * @return array
95
+     * @since 20.0.0
96
+     */
97
+    public function getObjectData(): array {
98
+        return $this->objectData;
99
+    }
100 100
 }
Please login to merge, or discard this patch.
apps/dav/lib/Events/AddressBookDeletedEvent.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -34,53 +34,53 @@
 block discarded – undo
34 34
  */
35 35
 class AddressBookDeletedEvent extends Event {
36 36
 
37
-	/** @var int */
38
-	private $addressBookId;
37
+    /** @var int */
38
+    private $addressBookId;
39 39
 
40
-	/** @var array */
41
-	private $addressBookData;
40
+    /** @var array */
41
+    private $addressBookData;
42 42
 
43
-	/** @var array */
44
-	private $shares;
43
+    /** @var array */
44
+    private $shares;
45 45
 
46
-	/**
47
-	 * AddressBookDeletedEvent constructor.
48
-	 *
49
-	 * @param int $addressBookId
50
-	 * @param array $addressBookData
51
-	 * @param array $shares
52
-	 * @since 20.0.0
53
-	 */
54
-	public function __construct(int $addressBookId,
55
-								array $addressBookData,
56
-								array $shares) {
57
-		parent::__construct();
58
-		$this->addressBookId = $addressBookId;
59
-		$this->addressBookData = $addressBookData;
60
-		$this->shares = $shares;
61
-	}
46
+    /**
47
+     * AddressBookDeletedEvent constructor.
48
+     *
49
+     * @param int $addressBookId
50
+     * @param array $addressBookData
51
+     * @param array $shares
52
+     * @since 20.0.0
53
+     */
54
+    public function __construct(int $addressBookId,
55
+                                array $addressBookData,
56
+                                array $shares) {
57
+        parent::__construct();
58
+        $this->addressBookId = $addressBookId;
59
+        $this->addressBookData = $addressBookData;
60
+        $this->shares = $shares;
61
+    }
62 62
 
63
-	/**
64
-	 * @return int
65
-	 * @since 20.0.0
66
-	 */
67
-	public function getAddressBookId():int {
68
-		return $this->addressBookId;
69
-	}
63
+    /**
64
+     * @return int
65
+     * @since 20.0.0
66
+     */
67
+    public function getAddressBookId():int {
68
+        return $this->addressBookId;
69
+    }
70 70
 
71
-	/**
72
-	 * @return array
73
-	 * @since 20.0.0
74
-	 */
75
-	public function getAddressBookData(): array {
76
-		return $this->addressBookData;
77
-	}
71
+    /**
72
+     * @return array
73
+     * @since 20.0.0
74
+     */
75
+    public function getAddressBookData(): array {
76
+        return $this->addressBookData;
77
+    }
78 78
 
79
-	/**
80
-	 * @return array
81
-	 * @since 20.0.0
82
-	 */
83
-	public function getShares(): array {
84
-		return $this->shares;
85
-	}
79
+    /**
80
+     * @return array
81
+     * @since 20.0.0
82
+     */
83
+    public function getShares(): array {
84
+        return $this->shares;
85
+    }
86 86
 }
Please login to merge, or discard this patch.
apps/dav/lib/Events/CalendarObjectDeletedEvent.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -34,67 +34,67 @@
 block discarded – undo
34 34
  */
35 35
 class CalendarObjectDeletedEvent extends Event {
36 36
 
37
-	/** @var int */
38
-	private $calendarId;
37
+    /** @var int */
38
+    private $calendarId;
39 39
 
40
-	/** @var array */
41
-	private $calendarData;
40
+    /** @var array */
41
+    private $calendarData;
42 42
 
43
-	/** @var array */
44
-	private $shares;
43
+    /** @var array */
44
+    private $shares;
45 45
 
46
-	/** @var array */
47
-	private $objectData;
46
+    /** @var array */
47
+    private $objectData;
48 48
 
49
-	/**
50
-	 * CalendarObjectDeletedEvent constructor.
51
-	 *
52
-	 * @param int $calendarId
53
-	 * @param array $calendarData
54
-	 * @param array $shares
55
-	 * @param array $objectData
56
-	 * @since 20.0.0
57
-	 */
58
-	public function __construct(int $calendarId,
59
-								array $calendarData,
60
-								array $shares,
61
-								array $objectData) {
62
-		parent::__construct();
63
-		$this->calendarId = $calendarId;
64
-		$this->calendarData = $calendarData;
65
-		$this->shares = $shares;
66
-		$this->objectData = $objectData;
67
-	}
49
+    /**
50
+     * CalendarObjectDeletedEvent constructor.
51
+     *
52
+     * @param int $calendarId
53
+     * @param array $calendarData
54
+     * @param array $shares
55
+     * @param array $objectData
56
+     * @since 20.0.0
57
+     */
58
+    public function __construct(int $calendarId,
59
+                                array $calendarData,
60
+                                array $shares,
61
+                                array $objectData) {
62
+        parent::__construct();
63
+        $this->calendarId = $calendarId;
64
+        $this->calendarData = $calendarData;
65
+        $this->shares = $shares;
66
+        $this->objectData = $objectData;
67
+    }
68 68
 
69
-	/**
70
-	 * @return int
71
-	 * @since 20.0.0
72
-	 */
73
-	public function getCalendarId(): int {
74
-		return $this->calendarId;
75
-	}
69
+    /**
70
+     * @return int
71
+     * @since 20.0.0
72
+     */
73
+    public function getCalendarId(): int {
74
+        return $this->calendarId;
75
+    }
76 76
 
77
-	/**
78
-	 * @return array
79
-	 * @since 20.0.0
80
-	 */
81
-	public function getCalendarData(): array {
82
-		return $this->calendarData;
83
-	}
77
+    /**
78
+     * @return array
79
+     * @since 20.0.0
80
+     */
81
+    public function getCalendarData(): array {
82
+        return $this->calendarData;
83
+    }
84 84
 
85
-	/**
86
-	 * @return array
87
-	 * @since 20.0.0
88
-	 */
89
-	public function getShares(): array {
90
-		return $this->shares;
91
-	}
85
+    /**
86
+     * @return array
87
+     * @since 20.0.0
88
+     */
89
+    public function getShares(): array {
90
+        return $this->shares;
91
+    }
92 92
 
93
-	/**
94
-	 * @return array
95
-	 * @since 20.0.0
96
-	 */
97
-	public function getObjectData(): array {
98
-		return $this->objectData;
99
-	}
93
+    /**
94
+     * @return array
95
+     * @since 20.0.0
96
+     */
97
+    public function getObjectData(): array {
98
+        return $this->objectData;
99
+    }
100 100
 }
Please login to merge, or discard this patch.