Fix indentation
This commit is contained in:
@@ -43,13 +43,7 @@ class BoardService {
|
||||
private $l10n;
|
||||
private $permissionService;
|
||||
|
||||
public function __construct(
|
||||
BoardMapper $boardMapper,
|
||||
IL10N $l10n,
|
||||
LabelMapper $labelMapper,
|
||||
AclMapper $aclMapper,
|
||||
PermissionService $permissionService
|
||||
) {
|
||||
public function __construct(BoardMapper $boardMapper, IL10N $l10n, LabelMapper $labelMapper, AclMapper $aclMapper, PermissionService $permissionService) {
|
||||
$this->boardMapper = $boardMapper;
|
||||
$this->labelMapper = $labelMapper;
|
||||
$this->aclMapper = $aclMapper;
|
||||
@@ -78,10 +72,11 @@ class BoardService {
|
||||
|
||||
// create new labels
|
||||
$default_labels = [
|
||||
'31CC7C' => $this->l10n->t('Finished'),
|
||||
'317CCC' => $this->l10n->t('To review'),
|
||||
'31CC7C' => $this->l10n->t('Finished'),
|
||||
'317CCC' => $this->l10n->t('To review'),
|
||||
'FF7A66' => $this->l10n->t('Action needed'),
|
||||
'F1DB50' => $this->l10n->t('Later')];
|
||||
'F1DB50' => $this->l10n->t('Later')
|
||||
];
|
||||
$labels = [];
|
||||
foreach ($default_labels as $color => $title) {
|
||||
$label = new Label();
|
||||
|
||||
@@ -5,20 +5,20 @@
|
||||
* @author Julius Härtl <jus@bitgrid.net>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Deck\Service;
|
||||
@@ -30,15 +30,11 @@ use OCA\Deck\CardArchivedException;
|
||||
use OCA\Deck\Db\StackMapper;
|
||||
|
||||
|
||||
class CardService {
|
||||
class CardService {
|
||||
|
||||
private $cardMapper;
|
||||
|
||||
public function __construct(
|
||||
CardMapper $cardMapper,
|
||||
StackMapper $stackMapper,
|
||||
PermissionService $permissionService
|
||||
) {
|
||||
public function __construct(CardMapper $cardMapper, StackMapper $stackMapper, PermissionService $permissionService) {
|
||||
$this->cardMapper = $cardMapper;
|
||||
$this->stackMapper = $stackMapper;
|
||||
$this->permissionService = $permissionService;
|
||||
@@ -48,6 +44,7 @@ class CardService {
|
||||
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_READ);
|
||||
return $this->cardMapper->find($cardId);
|
||||
}
|
||||
|
||||
public function create($title, $stackId, $type, $order, $owner) {
|
||||
$this->permissionService->checkPermission($this->stackMapper, $stackId, Acl::PERMISSION_EDIT);
|
||||
$card = new Card();
|
||||
@@ -68,7 +65,7 @@ class CardService {
|
||||
public function update($id, $title, $stackId, $type, $order, $description, $owner) {
|
||||
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
|
||||
$card = $this->cardMapper->find($id);
|
||||
if($card->getArchived()) {
|
||||
if ($card->getArchived()) {
|
||||
throw new CardArchivedException();
|
||||
}
|
||||
$card->setTitle($title);
|
||||
@@ -83,30 +80,31 @@ class CardService {
|
||||
public function rename($id, $title) {
|
||||
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
|
||||
$card = $this->cardMapper->find($id);
|
||||
if($card->getArchived()) {
|
||||
if ($card->getArchived()) {
|
||||
throw new CardArchivedException();
|
||||
}
|
||||
$card->setTitle($title);
|
||||
return $this->cardMapper->update($card);
|
||||
}
|
||||
|
||||
public function reorder($id, $stackId, $order) {
|
||||
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
|
||||
$cards = $this->cardMapper->findAll($stackId);
|
||||
$result = [];
|
||||
$i = 0;
|
||||
foreach ($cards as $card) {
|
||||
if($card->getArchived()) {
|
||||
if ($card->getArchived()) {
|
||||
throw new CardArchivedException();
|
||||
}
|
||||
if($card->id === $id) {
|
||||
if ($card->id === $id) {
|
||||
$card->setOrder($order);
|
||||
$card->setLastModified(time());
|
||||
}
|
||||
$card->setLastModified(time());
|
||||
}
|
||||
|
||||
if($i === $order)
|
||||
if ($i === $order)
|
||||
$i++;
|
||||
|
||||
if($card->id !== $id) {
|
||||
if ($card->id !== $id) {
|
||||
$card->setOrder($i++);
|
||||
}
|
||||
$this->cardMapper->update($card);
|
||||
@@ -122,7 +120,7 @@ class CardService {
|
||||
$card->setArchived(true);
|
||||
return $this->cardMapper->update($card);
|
||||
}
|
||||
|
||||
|
||||
public function unarchive($id) {
|
||||
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
|
||||
$card = $this->cardMapper->find($id);
|
||||
@@ -133,7 +131,7 @@ class CardService {
|
||||
public function assignLabel($cardId, $labelId) {
|
||||
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT);
|
||||
$card = $this->cardMapper->find($cardId);
|
||||
if($card->getArchived()) {
|
||||
if ($card->getArchived()) {
|
||||
throw new CardArchivedException();
|
||||
}
|
||||
$this->cardMapper->assignLabel($cardId, $labelId);
|
||||
@@ -142,7 +140,7 @@ class CardService {
|
||||
public function removeLabel($cardId, $labelId) {
|
||||
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT);
|
||||
$card = $this->cardMapper->find($cardId);
|
||||
if($card->getArchived()) {
|
||||
if ($card->getArchived()) {
|
||||
throw new CardArchivedException();
|
||||
}
|
||||
$this->cardMapper->removeLabel($cardId, $labelId);
|
||||
|
||||
@@ -32,10 +32,7 @@ class LabelService {
|
||||
|
||||
private $labelMapper;
|
||||
|
||||
public function __construct(
|
||||
LabelMapper $labelMapper,
|
||||
PermissionService $permissionService
|
||||
) {
|
||||
public function __construct(LabelMapper $labelMapper, PermissionService $permissionService) {
|
||||
$this->labelMapper = $labelMapper;
|
||||
$this->permissionService = $permissionService;
|
||||
}
|
||||
|
||||
@@ -43,12 +43,7 @@ class PermissionService {
|
||||
private $logger;
|
||||
private $userId;
|
||||
|
||||
public function __construct(ILogger $logger,
|
||||
AclMapper $aclMapper,
|
||||
BoardMapper $boardMapper,
|
||||
IGroupManager $groupManager,
|
||||
$userId
|
||||
) {
|
||||
public function __construct(ILogger $logger, AclMapper $aclMapper, BoardMapper $boardMapper, IGroupManager $groupManager, $userId) {
|
||||
$this->aclMapper = $aclMapper;
|
||||
$this->boardMapper = $boardMapper;
|
||||
$this->logger = $logger;
|
||||
@@ -82,14 +77,14 @@ class PermissionService {
|
||||
* @return bool
|
||||
* @throws NoPermissionException
|
||||
*/
|
||||
public function checkPermission($mapper, $id, $permission) {
|
||||
try {
|
||||
if($mapper instanceof IPermissionMapper) {
|
||||
public function checkPermission($mapper, $id, $permission) {
|
||||
try {
|
||||
if ($mapper instanceof IPermissionMapper) {
|
||||
$boardId = $mapper->findBoardId($id);
|
||||
} else {
|
||||
$boardId = $id;
|
||||
$boardId = $id;
|
||||
}
|
||||
if($boardId === null) {
|
||||
if ($boardId === null) {
|
||||
// Throw NoPermission to not leak information about existing entries
|
||||
throw new NoPermissionException('Permission denied');
|
||||
}
|
||||
@@ -104,8 +99,8 @@ class PermissionService {
|
||||
}
|
||||
|
||||
} catch (DoesNotExistException $exception) {
|
||||
// Throw NoPermission to not leak information about existing entries
|
||||
throw new NoPermissionException('Permission denied');
|
||||
// Throw NoPermission to not leak information about existing entries
|
||||
throw new NoPermissionException('Permission denied');
|
||||
}
|
||||
|
||||
throw new NoPermissionException('Permission denied.');
|
||||
|
||||
Reference in New Issue
Block a user