Passed
Push — master ( f5d7fd...3b403d )
by Julius
02:46
created

BoardService::deleteForce()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
/**
3
 * @copyright Copyright (c) 2016 Julius Härtl <[email protected]>
4
 *
5
 * @author Julius Härtl <[email protected]>
6
 *
7
 * @license GNU AGPL version 3 or any later version
8
 *
9
 *  This program is free software: you can redistribute it and/or modify
10
 *  it under the terms of the GNU Affero General Public License as
11
 *  published by the Free Software Foundation, either version 3 of the
12
 *  License, or (at your option) any later version.
13
 *
14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *  GNU Affero General Public License for more details.
18
 *
19
 *  You should have received a copy of the GNU Affero General Public License
20
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 *
22
 */
23
24
namespace OCA\Deck\Service;
25
26
use OCA\Deck\Activity\ActivityManager;
27
use OCA\Deck\Activity\ChangeSet;
28
use OCA\Deck\Db\Acl;
29
use OCA\Deck\Db\AclMapper;
30
use OCA\Deck\Db\AssignedUsersMapper;
31
use OCA\Deck\Db\ChangeHelper;
32
use OCA\Deck\Db\IPermissionMapper;
33
use OCA\Deck\Db\Label;
34
use OCA\Deck\NoPermissionException;
35
use OCA\Deck\Notification\NotificationHelper;
36
use OCP\AppFramework\Db\DoesNotExistException;
37
use OCP\IGroupManager;
38
use OCP\IL10N;
39
use OCA\Deck\Db\Board;
40
use OCA\Deck\Db\BoardMapper;
41
use OCA\Deck\Db\LabelMapper;
42
use OCP\IUserManager;
43
use OCA\Deck\BadRequestException;
44
45
46
class BoardService {
47
48
	private $boardMapper;
49
	private $labelMapper;
50
	private $aclMapper;
51
	private $l10n;
52
	private $permissionService;
53
	private $notificationHelper;
54
	private $assignedUsersMapper;
55
	private $userManager;
56
	private $groupManager;
57
	private $userId;
58
	private $activityManager;
59
	private $changeHelper;
60
61 View Code Duplication
	public function __construct(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
62
		BoardMapper $boardMapper,
63
		IL10N $l10n,
64
		LabelMapper $labelMapper,
65
		AclMapper $aclMapper,
66
		PermissionService $permissionService,
67
		NotificationHelper $notificationHelper,
68
		AssignedUsersMapper $assignedUsersMapper,
69
		IUserManager $userManager,
70
		IGroupManager $groupManager,
71
		ActivityManager $activityManager,
72
		ChangeHelper $changeHelper,
73
		$userId
74
	) {
75
		$this->boardMapper = $boardMapper;
76
		$this->labelMapper = $labelMapper;
77
		$this->aclMapper = $aclMapper;
78
		$this->l10n = $l10n;
79
		$this->permissionService = $permissionService;
80
		$this->notificationHelper = $notificationHelper;
81
		$this->assignedUsersMapper = $assignedUsersMapper;
82
		$this->userManager = $userManager;
83
		$this->groupManager = $groupManager;
84
		$this->activityManager = $activityManager;
85
		$this->changeHelper = $changeHelper;
86
		$this->userId = $userId;
87
	}
88
89
	/**
90
	 * @return array
91
	 */
92
	public function findAll($since = -1) {
93
		$userInfo = $this->getBoardPrerequisites();
94
		$userBoards = $this->boardMapper->findAllByUser($userInfo['user'], null, null, $since);
95
		$groupBoards = $this->boardMapper->findAllByGroups($userInfo['user'], $userInfo['groups'],null, null,  $since);
0 ignored issues
show
Unused Code introduced by
The call to BoardMapper::findAllByGroups() has too many arguments starting with $since.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
96
		$complete = array_merge($userBoards, $groupBoards);
97
		$result = [];
98
		/** @var Board $item */
99
		foreach ($complete as &$item) {
100
			if (!array_key_exists($item->getId(), $result)) {
101
				$this->boardMapper->mapOwner($item);
102
				if ($item->getAcl() !== null) {
103
					foreach ($item->getAcl() as &$acl) {
0 ignored issues
show
Bug introduced by
The expression $item->getAcl() cannot be used as a reference.

Let?s assume that you have the following foreach statement:

foreach ($array as &$itemValue) { }

$itemValue is assigned by reference. This is possible because the expression (in the example $array) can be used as a reference target.

However, if we were to replace $array with something different like the result of a function call as in

foreach (getArray() as &$itemValue) { }

then assigning by reference is not possible anymore as there is no target that could be modified.

Available Fixes

1. Do not assign by reference
foreach (getArray() as $itemValue) { }
2. Assign to a local variable first
$array = getArray();
foreach ($array as &$itemValue) {}
3. Return a reference
function &getArray() { $array = array(); return $array; }

foreach (getArray() as &$itemValue) { }
Loading history...
104
						$this->boardMapper->mapAcl($acl);
105
					}
106
				}
107
				$permissions = $this->permissionService->matchPermissions($item);
108
				$item->setPermissions([
109
					'PERMISSION_READ' => $permissions[Acl::PERMISSION_READ],
110
					'PERMISSION_EDIT' => $permissions[Acl::PERMISSION_EDIT],
111
					'PERMISSION_MANAGE' => $permissions[Acl::PERMISSION_MANAGE],
112
					'PERMISSION_SHARE' => $permissions[Acl::PERMISSION_SHARE]
113
				]);
114
				$result[$item->getId()] = $item;
115
			}
116
		}
117
		return array_values($result);
118
	}
119
120
	/**
121
	 * @param $boardId
122
	 * @return Board
123
	 * @throws DoesNotExistException
124
	 * @throws \OCA\Deck\NoPermissionException
125
	 * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
126
	 * @throws BadRequestException
127
	 */
128
	public function find($boardId) {
129
130
		if ( is_numeric($boardId) === false ) {
131
			throw new BadRequestException('board id must be a number');
132
		}
133
134
		$this->permissionService->checkPermission($this->boardMapper, $boardId, Acl::PERMISSION_READ);
135
		/** @var Board $board */
136
		$board = $this->boardMapper->find($boardId, true, true);
137
		$this->boardMapper->mapOwner($board);
138
		foreach ($board->getAcl() as &$acl) {
0 ignored issues
show
Bug introduced by
The expression $board->getAcl() cannot be used as a reference.

Let?s assume that you have the following foreach statement:

foreach ($array as &$itemValue) { }

$itemValue is assigned by reference. This is possible because the expression (in the example $array) can be used as a reference target.

However, if we were to replace $array with something different like the result of a function call as in

foreach (getArray() as &$itemValue) { }

then assigning by reference is not possible anymore as there is no target that could be modified.

Available Fixes

1. Do not assign by reference
foreach (getArray() as $itemValue) { }
2. Assign to a local variable first
$array = getArray();
foreach ($array as &$itemValue) {}
3. Return a reference
function &getArray() { $array = array(); return $array; }

foreach (getArray() as &$itemValue) { }
Loading history...
139
			if ($acl !== null) {
140
				$this->boardMapper->mapAcl($acl);
141
			}
142
		}
143
		$permissions = $this->permissionService->matchPermissions($board);
144
		$board->setPermissions([
145
			'PERMISSION_READ' => $permissions[Acl::PERMISSION_READ],
146
			'PERMISSION_EDIT' => $permissions[Acl::PERMISSION_EDIT],
147
			'PERMISSION_MANAGE' => $permissions[Acl::PERMISSION_MANAGE],
148
			'PERMISSION_SHARE' => $permissions[Acl::PERMISSION_SHARE]
149
		]);
150
		$boardUsers = $this->permissionService->findUsers($boardId);
151
		$board->setUsers(array_values($boardUsers));
152
		return $board;
153
	}
154
155
	/**
156
	 * @return array
157
	 */
158
	private function getBoardPrerequisites() {
159
		$groups = $this->groupManager->getUserGroupIds(
160
			$this->userManager->get($this->userId)
0 ignored issues
show
Bug introduced by
It seems like $this->userManager->get($this->userId) can be null; however, getUserGroupIds() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
161
		);
162
		return [
163
			'user' => $this->userId,
164
			'groups' => $groups
165
		];
166
	}
167
168
	/**
169
	 * @param $mapper
170
	 * @param $id
171
	 * @return bool
172
	 * @throws DoesNotExistException
173
	 * @throws \OCA\Deck\NoPermissionException
174
	 * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
175
	 * @throws BadRequestException
176
	 */
177
	public function isArchived($mapper, $id) {
178
179
		if (is_numeric($id) === false)  {
180
			throw new BadRequestException('id must be a number');
181
		}
182
183
		try {
184
			$boardId = $id;
185
			if ($mapper instanceof IPermissionMapper) {
186
				$boardId = $mapper->findBoardId($id);
187
			}
188
			if ($boardId === null) {
189
				return false;
190
			}
191
		} catch (DoesNotExistException $exception) {
192
			return false;
193
		}
194
		$board = $this->find($boardId);
195
		return $board->getArchived();
196
	}
197
198
	/**
199
	 * @param $mapper
200
	 * @param $id
201
	 * @return bool
202
	 * @throws DoesNotExistException
203
	 * @throws \OCA\Deck\NoPermissionException
204
	 * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
205
	 * @throws BadRequestException
206
	 */
207
	public function isDeleted($mapper, $id) {
208
209
		if ($mapper === false || $mapper === null) {
210
			throw new BadRequestException('mapper must be provided');
211
		}
212
213
		if (is_numeric($id) === false)  {
214
			throw new BadRequestException('id must be a number');
215
		}
216
217
		try {
218
			$boardId = $id;
219
			if ($mapper instanceof IPermissionMapper) {
220
				$boardId = $mapper->findBoardId($id);
221
			}
222
			if ($boardId === null) {
223
				return false;
224
			}
225
		} catch (DoesNotExistException $exception) {
226
			return false;
227
		}
228
		$board = $this->find($boardId);
229
		return $board->getDeletedAt() > 0;
230
	}
231
232
233
	/**
234
	 * @param $title
235
	 * @param $userId
236
	 * @param $color
237
	 * @return \OCP\AppFramework\Db\Entity
238
	 * @throws BadRequestException
239
	 */
240
	public function create($title, $userId, $color) {
241
242
		if ($title === false || $title === null) {
243
			throw new BadRequestException('title must be provided');
244
		}
245
246
		if ($userId === false || $userId === null) {
247
			throw new BadRequestException('userId must be provided');
248
		}
249
250
		if ($color === false || $color === null) {
251
			throw new BadRequestException('color must be provided');
252
		}
253
254
		if (!$this->permissionService->canCreate()) {
255
			throw new NoPermissionException('Creating boards has been disabled for your account.');
256
		}
257
258
		$board = new Board();
259
		$board->setTitle($title);
260
		$board->setOwner($userId);
261
		$board->setColor($color);
262
		$new_board = $this->boardMapper->insert($board);
0 ignored issues
show
Deprecated Code introduced by
The method OCP\AppFramework\Db\Mapper::insert() has been deprecated with message: 14.0.0 Move over to QBMapper

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
263
264
		// create new labels
265
		$default_labels = [
266
			'31CC7C' => $this->l10n->t('Finished'),
267
			'317CCC' => $this->l10n->t('To review'),
268
			'FF7A66' => $this->l10n->t('Action needed'),
269
			'F1DB50' => $this->l10n->t('Later')
270
		];
271
		$labels = [];
272
		foreach ($default_labels as $labelColor => $labelTitle) {
273
			$label = new Label();
274
			$label->setColor($labelColor);
275
			$label->setTitle($labelTitle);
276
			$label->setBoardId($new_board->getId());
277
			$labels[] = $this->labelMapper->insert($label);
0 ignored issues
show
Deprecated Code introduced by
The method OCP\AppFramework\Db\Mapper::insert() has been deprecated with message: 14.0.0 Move over to QBMapper

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
278
		}
279
		$new_board->setLabels($labels);
280
		$this->boardMapper->mapOwner($new_board);
281
		$permissions = $this->permissionService->matchPermissions($new_board);
282
		$new_board->setPermissions([
283
			'PERMISSION_READ' => $permissions[Acl::PERMISSION_READ],
284
			'PERMISSION_EDIT' => $permissions[Acl::PERMISSION_EDIT],
285
			'PERMISSION_MANAGE' => $permissions[Acl::PERMISSION_MANAGE],
286
			'PERMISSION_SHARE' => $permissions[Acl::PERMISSION_SHARE]
287
		]);
288
		$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_BOARD, $new_board, ActivityManager::SUBJECT_BOARD_CREATE);
289
		$this->changeHelper->boardChanged($new_board->getId());
290
		return $new_board;
291
292
	}
293
294
	/**
295
	 * @param $id
296
	 * @return Board
297
	 * @throws DoesNotExistException
298
	 * @throws \OCA\Deck\NoPermissionException
299
	 * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
300
	 * @throws BadRequestException
301
	 */
302 View Code Duplication
	public function delete($id) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
303
304
		if (is_numeric($id) === false) {
305
			throw new BadRequestException('board id must be a number');
306
		}
307
308
		$this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_READ);
309
		$board = $this->find($id);
310
		$board->setDeletedAt(time());
311
		$board = $this->boardMapper->update($board);
0 ignored issues
show
Deprecated Code introduced by
The method OCP\AppFramework\Db\Mapper::update() has been deprecated with message: 14.0.0 Move over to QBMapper

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
312
		$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_BOARD, $board, ActivityManager::SUBJECT_BOARD_DELETE);
313
		$this->changeHelper->boardChanged($board->getId());
314
		return $board;
315
	}
316
317
	/**
318
	 * @param $id
319
	 * @return \OCP\AppFramework\Db\Entity
320
	 * @throws DoesNotExistException
321
	 * @throws \OCA\Deck\NoPermissionException
322
	 * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
323
	 */
324 View Code Duplication
	public function deleteUndo($id) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
325
326
		if (is_numeric($id) === false) {
327
			throw new BadRequestException('board id must be a number');
328
		}
329
330
		$this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_READ);
331
		$board = $this->find($id);
332
		$board->setDeletedAt(0);
333
		$board = $this->boardMapper->update($board);
0 ignored issues
show
Deprecated Code introduced by
The method OCP\AppFramework\Db\Mapper::update() has been deprecated with message: 14.0.0 Move over to QBMapper

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
334
		$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_BOARD, $board, ActivityManager::SUBJECT_BOARD_RESTORE);
335
		$this->changeHelper->boardChanged($board->getId());
336
		return $board;
337
	}
338
339
	/**
340
	 * @param $id
341
	 * @return \OCP\AppFramework\Db\Entity
342
	 * @throws DoesNotExistException
343
	 * @throws \OCA\Deck\NoPermissionException
344
	 * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
345
	 * @throws BadRequestException
346
	 */
347
	public function deleteForce($id) {
348
		if (is_numeric($id) === false)  {
349
			throw new BadRequestException('id must be a number');
350
		}
351
352
		$this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_READ);
353
		$board = $this->find($id);
354
		return $this->boardMapper->delete($board);
355
	}
356
357
	/**
358
	 * @param $id
359
	 * @param $title
360
	 * @param $color
361
	 * @param $archived
362
	 * @return \OCP\AppFramework\Db\Entity
363
	 * @throws DoesNotExistException
364
	 * @throws \OCA\Deck\NoPermissionException
365
	 * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
366
	 * @throws BadRequestException
367
	 */
368
	public function update($id, $title, $color, $archived) {
369
370
		if (is_numeric($id) === false) {
371
			throw new BadRequestException('board id must be a number');
372
		}
373
374
		if ($title === false || $title === null) {
375
			throw new BadRequestException('color must be provided');
376
		}
377
378
		if ($color === false || $color === null) {
379
			throw new BadRequestException('color must be provided');
380
		}
381
382
		if ( is_bool($archived) === false ) {
383
			throw new BadRequestException('archived must be a boolean');
384
		}
385
386
		$this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_MANAGE);
387
		$board = $this->find($id);
388
		$changes = new ChangeSet($board);
389
		$board->setTitle($title);
390
		$board->setColor($color);
391
		$board->setArchived($archived);
392
		$changes->setAfter($board);
393
		$this->boardMapper->update($board); // operate on clone so we can check for updated fields
0 ignored issues
show
Deprecated Code introduced by
The method OCP\AppFramework\Db\Mapper::update() has been deprecated with message: 14.0.0 Move over to QBMapper

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
394
		$this->boardMapper->mapOwner($board);
395
		$this->activityManager->triggerUpdateEvents(ActivityManager::DECK_OBJECT_BOARD, $changes, ActivityManager::SUBJECT_BOARD_UPDATE);
396
		$this->changeHelper->boardChanged($board->getId());
397
		return $board;
398
	}
399
400
401
	/**
402
	 * @param $boardId
403
	 * @param $type
404
	 * @param $participant
405
	 * @param $edit
406
	 * @param $share
407
	 * @param $manage
408
	 * @return \OCP\AppFramework\Db\Entity
409
	 * @throws BadRequestException
410
	 * @throws \OCA\Deck\NoPermissionException
411
	 */
412
	public function addAcl($boardId, $type, $participant, $edit, $share, $manage) {
413
414
		if (is_numeric($boardId) === false) {
415
			throw new BadRequestException('board id must be a number');
416
		}
417
418
		if ($type === false || $type === null) {
419
			throw new BadRequestException('type must be provided');
420
		}
421
422
		if ($participant === false || $participant === null) {
423
			throw new BadRequestException('participant must be provided');
424
		}
425
426
		if ($edit === null) {
427
			throw new BadRequestException('edit must be provided');
428
		}
429
430
		if ($share === null) {
431
			throw new BadRequestException('share must be provided');
432
		}
433
434
		if ($manage === null) {
435
			throw new BadRequestException('manage must be provided');
436
		}
437
438
		$this->permissionService->checkPermission($this->boardMapper, $boardId, Acl::PERMISSION_SHARE);
439
		$acl = new Acl();
440
		$acl->setBoardId($boardId);
441
		$acl->setType($type);
442
		$acl->setParticipant($participant);
443
		$acl->setPermissionEdit($edit);
444
		$acl->setPermissionShare($share);
445
		$acl->setPermissionManage($manage);
446
447
		/* Notify users about the shared board */
448
		$this->notificationHelper->sendBoardShared($boardId, $acl);
449
450
		$newAcl = $this->aclMapper->insert($acl);
0 ignored issues
show
Deprecated Code introduced by
The method OCP\AppFramework\Db\Mapper::insert() has been deprecated with message: 14.0.0 Move over to QBMapper

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
451
		$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_BOARD, $newAcl, ActivityManager::SUBJECT_BOARD_SHARE);
452
		$this->boardMapper->mapAcl($newAcl);
453
		$this->changeHelper->boardChanged($boardId);
454
		return $newAcl;
455
	}
456
457
	/**
458
	 * @param $id
459
	 * @param $edit
460
	 * @param $share
461
	 * @param $manage
462
	 * @return \OCP\AppFramework\Db\Entity
463
	 * @throws DoesNotExistException
464
	 * @throws \OCA\Deck\NoPermissionException
465
	 * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
466
	 * @throws BadRequestException
467
	 */
468
	public function updateAcl($id, $edit, $share, $manage) {
469
470
		if (is_numeric($id) === false) {
471
			throw new BadRequestException('id must be a number');
472
		}
473
474
		if ($edit === null) {
475
			throw new BadRequestException('edit must be provided');
476
		}
477
478
		if ($share === null) {
479
			throw new BadRequestException('share must be provided');
480
		}
481
482
		if ($manage === null) {
483
			throw new BadRequestException('manage must be provided');
484
		}
485
486
		$this->permissionService->checkPermission($this->aclMapper, $id, Acl::PERMISSION_SHARE);
487
		/** @var Acl $acl */
488
		$acl = $this->aclMapper->find($id);
489
		$acl->setPermissionEdit($edit);
490
		$acl->setPermissionShare($share);
491
		$acl->setPermissionManage($manage);
492
		$this->boardMapper->mapAcl($acl);
493
		$board = $this->aclMapper->update($acl);
0 ignored issues
show
Deprecated Code introduced by
The method OCP\AppFramework\Db\Mapper::update() has been deprecated with message: 14.0.0 Move over to QBMapper

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
494
		$this->changeHelper->boardChanged($acl->getBoardId());
495
		return $board;
496
	}
497
498
	/**
499
	 * @param $id
500
	 * @return \OCP\AppFramework\Db\Entity
501
	 * @throws DoesNotExistException
502
	 * @throws \OCA\Deck\NoPermissionException
503
	 * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
504
	 * @throws BadRequestException
505
	 */
506
	public function deleteAcl($id) {
507
508
		if (is_numeric($id) === false) {
509
			throw new BadRequestException('id must be a number');
510
		}
511
512
		$this->permissionService->checkPermission($this->aclMapper, $id, Acl::PERMISSION_SHARE);
513
		/** @var Acl $acl */
514
		$acl = $this->aclMapper->find($id);
515
		$this->boardMapper->mapAcl($acl);
516
		if ($acl->getType() === Acl::PERMISSION_TYPE_USER) {
517
			$assignements = $this->assignedUsersMapper->findByUserId($acl->getParticipant());
518
			foreach ($assignements as $assignement) {
519
				$this->assignedUsersMapper->delete($assignement);
0 ignored issues
show
Deprecated Code introduced by
The method OCP\AppFramework\Db\Mapper::delete() has been deprecated with message: 14.0.0 Move over to QBMapper

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
520
			}
521
		}
522
		$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_BOARD, $acl, ActivityManager::SUBJECT_BOARD_UNSHARE);
523
		$this->changeHelper->boardChanged($acl->getBoardId());
524
		return $this->aclMapper->delete($acl);
0 ignored issues
show
Deprecated Code introduced by
The method OCP\AppFramework\Db\Mapper::delete() has been deprecated with message: 14.0.0 Move over to QBMapper

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
525
	}
526
527
}
528