Scrutinizer Auto-Fixes

This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
This commit is contained in:
Scrutinizer Auto-Fixer
2018-05-12 11:10:23 +00:00
parent 08d9d51bea
commit b633d82c5e
17 changed files with 77 additions and 71 deletions

View File

@@ -30,7 +30,6 @@ use OCA\Deck\Notification\Notifier;
use OCP\AppFramework\App; use OCP\AppFramework\App;
use OCA\Deck\Middleware\SharingMiddleware; use OCA\Deck\Middleware\SharingMiddleware;
use OCP\IGroup; use OCP\IGroup;
use OCP\IUser; use OCP\IUser;
use OCP\IUserManager; use OCP\IUserManager;
use OCP\IURLGenerator; use OCP\IURLGenerator;
@@ -114,7 +113,7 @@ class Application extends App {
$self = &$this; $self = &$this;
$notificationManager->registerNotifier(function() use (&$self) { $notificationManager->registerNotifier(function() use (&$self) {
return $self->getContainer()->query(Notifier::class); return $self->getContainer()->query(Notifier::class);
}, function () { }, function() {
return ['id' => 'deck', 'name' => 'Deck']; return ['id' => 'deck', 'name' => 'Deck'];
}); });

View File

@@ -86,7 +86,7 @@ class AssignedUsersMapper extends DeckMapper implements IPermissionMapper {
$userManager = $this->userManager; $userManager = $this->userManager;
$assignment->resolveRelation('participant', function() use (&$userManager, &$assignment) { $assignment->resolveRelation('participant', function() use (&$userManager, &$assignment) {
$user = $userManager->get($assignment->getParticipant()); $user = $userManager->get($assignment->getParticipant());
if($user !== null) { if ($user !== null) {
return new User($user); return new User($user);
} }
return null; return null;

View File

@@ -140,7 +140,7 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
public function findToDelete() { public function findToDelete() {
// add buffer of 5 min // add buffer of 5 min
$timeLimit = time()-(60*5); $timeLimit = time() - (60 * 5);
$sql = 'SELECT id, title, owner, color, archived, deleted_at FROM `*PREFIX*deck_boards` ' . $sql = 'SELECT id, title, owner, color, archived, deleted_at FROM `*PREFIX*deck_boards` ' .
'WHERE `deleted_at` > 0 AND `deleted_at` < ?'; 'WHERE `deleted_at` > 0 AND `deleted_at` < ?';
return $this->findEntities($sql, [$timeLimit]); return $this->findEntities($sql, [$timeLimit]);
@@ -181,17 +181,17 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
$userManager = $this->userManager; $userManager = $this->userManager;
$groupManager = $this->groupManager; $groupManager = $this->groupManager;
$acl->resolveRelation('participant', function($participant) use (&$acl, &$userManager, &$groupManager) { $acl->resolveRelation('participant', function($participant) use (&$acl, &$userManager, &$groupManager) {
if($acl->getType() === Acl::PERMISSION_TYPE_USER) { if ($acl->getType() === Acl::PERMISSION_TYPE_USER) {
$user = $userManager->get($participant); $user = $userManager->get($participant);
if($user !== null) { if ($user !== null) {
return new User($user); return new User($user);
} }
\OC::$server->getLogger()->debug('User ' . $acl->getId() . ' not found when mapping acl ' . $acl->getParticipant()); \OC::$server->getLogger()->debug('User ' . $acl->getId() . ' not found when mapping acl ' . $acl->getParticipant());
return null; return null;
} }
if($acl->getType() === Acl::PERMISSION_TYPE_GROUP) { if ($acl->getType() === Acl::PERMISSION_TYPE_GROUP) {
$group = $groupManager->get($participant); $group = $groupManager->get($participant);
if($group !== null) { if ($group !== null) {
return new Group($group); return new Group($group);
} }
\OC::$server->getLogger()->debug('Group ' . $acl->getId() . ' not found when mapping acl ' . $acl->getParticipant()); \OC::$server->getLogger()->debug('Group ' . $acl->getId() . ' not found when mapping acl ' . $acl->getParticipant());
@@ -208,7 +208,7 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
$userManager = $this->userManager; $userManager = $this->userManager;
$board->resolveRelation('owner', function($owner) use (&$userManager) { $board->resolveRelation('owner', function($owner) use (&$userManager) {
$user = $userManager->get($owner); $user = $userManager->get($owner);
if($user !== null) { if ($user !== null) {
return new User($user); return new User($user);
} }
return null; return null;

View File

@@ -67,7 +67,7 @@ class Card extends RelationalEntity {
} }
public function getDuedate($isoFormat = false) { public function getDuedate($isoFormat = false) {
if($this->duedate === null) { if ($this->duedate === null) {
return null; return null;
} }
$dt = new DateTime($this->duedate); $dt = new DateTime($this->duedate);
@@ -83,16 +83,16 @@ class Card extends RelationalEntity {
$due = strtotime($this->duedate); $due = strtotime($this->duedate);
$today = new DateTime(); $today = new DateTime();
$today->setTime( 0, 0); $today->setTime(0, 0);
$match_date = new DateTime($this->duedate); $match_date = new DateTime($this->duedate);
$match_date->setTime( 0, 0); $match_date->setTime(0, 0);
$diff = $today->diff( $match_date ); $diff = $today->diff($match_date);
$diffDays = (integer)$diff->format('%R%a'); // Extract days count in interval $diffDays = (integer) $diff->format('%R%a'); // Extract days count in interval
if($due !== false) { if ($due !== false) {
if ($diffDays === 1) { if ($diffDays === 1) {
$json['overdue'] = self::DUEDATE_NEXT; $json['overdue'] = self::DUEDATE_NEXT;
} }

View File

@@ -178,7 +178,7 @@ class CardMapper extends DeckMapper implements IPermissionMapper {
$userManager = $this->userManager; $userManager = $this->userManager;
$card->resolveRelation('owner', function($owner) use (&$userManager) { $card->resolveRelation('owner', function($owner) use (&$userManager) {
$user = $userManager->get($owner); $user = $userManager->get($owner);
if($user !== null) { if ($user !== null) {
return new User($user); return new User($user);
} }
return null; return null;

View File

@@ -32,7 +32,7 @@ class RelationalEntity extends Entity implements \JsonSerializable {
/** /**
* Mark a property as relation so it will not get updated using Mapper::update * Mark a property as relation so it will not get updated using Mapper::update
* @param $property string Name of the property * @param string $property string Name of the property
*/ */
public function addRelation($property) { public function addRelation($property) {
if (!in_array($property, $this->_relations, true)) { if (!in_array($property, $this->_relations, true)) {
@@ -42,7 +42,7 @@ class RelationalEntity extends Entity implements \JsonSerializable {
/** /**
* Mark a property as resolvable via resolveRelation() * Mark a property as resolvable via resolveRelation()
* @param $property string Name of the property * @param string $property string Name of the property
*/ */
public function addResolvable($property) { public function addResolvable($property) {
$this->_resolvedProperties[$property] = null; $this->_resolvedProperties[$property] = null;
@@ -77,7 +77,7 @@ class RelationalEntity extends Entity implements \JsonSerializable {
} }
} }
foreach ($this->_resolvedProperties as $property => $value) { foreach ($this->_resolvedProperties as $property => $value) {
if($value !== null) { if ($value !== null) {
$json[$property] = $value; $json[$property] = $value;
} }
} }
@@ -107,29 +107,29 @@ class RelationalEntity extends Entity implements \JsonSerializable {
*/ */
public function resolveRelation($property, $resolver) { public function resolveRelation($property, $resolver) {
$result = null; $result = null;
if($property !== null && $this->$property !== null) { if ($property !== null && $this->$property !== null) {
$result = $resolver($this->$property); $result = $resolver($this->$property);
} }
if($result instanceof RelationalObject || $result === null) { if ($result instanceof RelationalObject || $result === null) {
$this->_resolvedProperties[$property] = $result; $this->_resolvedProperties[$property] = $result;
} else { } else {
throw new \Exception('resolver must return an instance of RelationalObject'); throw new \Exception('resolver must return an instance of RelationalObject');
} }
} }
public function __call($methodName, $args){ public function __call($methodName, $args) {
$attr = lcfirst( substr($methodName, 7) ); $attr = lcfirst(substr($methodName, 7));
if(array_key_exists($attr, $this->_resolvedProperties) && strpos($methodName, 'resolve') === 0) { if (array_key_exists($attr, $this->_resolvedProperties) && strpos($methodName, 'resolve') === 0) {
if($this->_resolvedProperties[$attr] !== null) { if ($this->_resolvedProperties[$attr] !== null) {
return $this->_resolvedProperties[$attr]; return $this->_resolvedProperties[$attr];
} }
return $this->getter($attr); return $this->getter($attr);
} }
$attr = lcfirst( substr($methodName, 3) ); $attr = lcfirst(substr($methodName, 3));
if(array_key_exists($attr, $this->_resolvedProperties) && strpos($methodName, 'set') === 0) { if (array_key_exists($attr, $this->_resolvedProperties) && strpos($methodName, 'set') === 0) {
if(!is_scalar($args[0])) { if (!is_scalar($args[0])) {
$args[0] = $args[0]['primaryKey']; $args[0] = $args[0]['primaryKey'];
} }
parent::setter($attr, $args); parent::setter($attr, $args);

View File

@@ -52,7 +52,7 @@ class RelationalObject implements \JsonSerializable {
* @throws \Exception * @throws \Exception
*/ */
public function getObjectSerialization() { public function getObjectSerialization() {
if($this->object instanceof \JsonSerializable) { if ($this->object instanceof \JsonSerializable) {
$this->object->jsonSerialize(); $this->object->jsonSerialize();
} else { } else {
throw new \Exception('jsonSerialize is not implemented on ' . get_class($this)); throw new \Exception('jsonSerialize is not implemented on ' . get_class($this));

View File

@@ -60,7 +60,7 @@ class SharingMiddleware extends Middleware {
*/ */
public function afterException($controller, $methodName, \Exception $exception) { public function afterException($controller, $methodName, \Exception $exception) {
if ($exception instanceof StatusException) { if ($exception instanceof StatusException) {
if($this->config->getSystemValue('loglevel', Util::WARN) === Util::DEBUG) { if ($this->config->getSystemValue('loglevel', Util::WARN) === Util::DEBUG) {
$this->logger->logException($exception); $this->logger->logException($exception);
} }
return new JSONResponse([ return new JSONResponse([

View File

@@ -64,15 +64,15 @@ class UnknownUsers implements IRepairStep {
$acls = $this->aclMapper->findAll($board->getId()); $acls = $this->aclMapper->findAll($board->getId());
/** @var Acl $acl */ /** @var Acl $acl */
foreach ($acls as $acl) { foreach ($acls as $acl) {
if($acl->getType() === Acl::PERMISSION_TYPE_USER) { if ($acl->getType() === Acl::PERMISSION_TYPE_USER) {
$user = $this->userManager->get($acl->getParticipant()); $user = $this->userManager->get($acl->getParticipant());
if($user === null) { if ($user === null) {
$this->aclMapper->delete($acl); $this->aclMapper->delete($acl);
} }
} }
if($acl->getType() === Acl::PERMISSION_TYPE_GROUP) { if ($acl->getType() === Acl::PERMISSION_TYPE_GROUP) {
$group = $this->groupManager->get($acl->getParticipant()); $group = $this->groupManager->get($acl->getParticipant());
if($group === null) { if ($group === null) {
$this->aclMapper->delete($acl); $this->aclMapper->delete($acl);
} }
} }

View File

@@ -83,7 +83,7 @@ class NotificationHelper {
$notification = $this->notificationManager->createNotification(); $notification = $this->notificationManager->createNotification();
$notification $notification
->setApp('deck') ->setApp('deck')
->setUser((string)$user->getUID()) ->setUser((string) $user->getUID())
->setObject('card', $card->getId()) ->setObject('card', $card->getId())
->setSubject('card-overdue', [ ->setSubject('card-overdue', [
$card->getTitle(), $board->getTitle() $card->getTitle(), $board->getTitle()
@@ -98,7 +98,7 @@ class NotificationHelper {
* Send notifications that a board was shared with a user/group * Send notifications that a board was shared with a user/group
* *
* @param $boardId * @param $boardId
* @param $acl * @param Acl $acl
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */
public function sendBoardShared($boardId, $acl) { public function sendBoardShared($boardId, $acl) {
@@ -128,11 +128,14 @@ class NotificationHelper {
return $this->boards[$boardId]; return $this->boards[$boardId];
} }
/**
* @param Board $board
*/
private function generateBoardShared($board, $userId) { private function generateBoardShared($board, $userId) {
$notification = $this->notificationManager->createNotification(); $notification = $this->notificationManager->createNotification();
$notification $notification
->setApp('deck') ->setApp('deck')
->setUser((string)$userId) ->setUser((string) $userId)
->setDateTime(new DateTime()) ->setDateTime(new DateTime())
->setObject('board', $board->getId()) ->setObject('board', $board->getId())
->setSubject('board-shared', [$board->getTitle(), $this->currentUser]); ->setSubject('board-shared', [$board->getTitle(), $this->currentUser]);

View File

@@ -66,25 +66,25 @@ class Notifier implements INotifier {
*/ */
public function prepare(INotification $notification, $languageCode) { public function prepare(INotification $notification, $languageCode) {
$l = $this->l10nFactory->get('deck', $languageCode); $l = $this->l10nFactory->get('deck', $languageCode);
if($notification->getApp() !== 'deck') { if ($notification->getApp() !== 'deck') {
throw new \InvalidArgumentException(); throw new \InvalidArgumentException();
} }
$notification->setIcon($this->url->getAbsoluteURL($this->url->imagePath('deck', 'deck-dark.svg'))); $notification->setIcon($this->url->getAbsoluteURL($this->url->imagePath('deck', 'deck-dark.svg')));
$params = $notification->getSubjectParameters(); $params = $notification->getSubjectParameters();
switch($notification->getSubject()) { switch ($notification->getSubject()) {
case 'card-overdue': case 'card-overdue':
$cardId = $notification->getObjectId(); $cardId = $notification->getObjectId();
$boardId = $this->cardMapper->findBoardId($cardId); $boardId = $this->cardMapper->findBoardId($cardId);
$notification->setParsedSubject( $notification->setParsedSubject(
(string) $l->t('The card "%s" on "%s" has reached its due date.', $params) (string) $l->t('The card "%s" on "%s" has reached its due date.', $params)
); );
$notification->setLink($this->url->linkToRouteAbsolute('deck.page.index') . '#!/board/'.$boardId.'//card/'.$cardId.''); $notification->setLink($this->url->linkToRouteAbsolute('deck.page.index') . '#!/board/' . $boardId . '//card/' . $cardId . '');
break; break;
case 'board-shared': case 'board-shared':
$boardId = $notification->getObjectId(); $boardId = $notification->getObjectId();
$initiator = $this->userManager->get($params[1]); $initiator = $this->userManager->get($params[1]);
if($initiator !== null) { if ($initiator !== null) {
$dn = $initiator->getDisplayName(); $dn = $initiator->getDisplayName();
} else { } else {
$dn = $params[1]; $dn = $params[1];
@@ -102,7 +102,7 @@ class Notifier implements INotifier {
] ]
] ]
); );
$notification->setLink($this->url->linkToRouteAbsolute('deck.page.index') . '#!/board/'.$boardId.'/'); $notification->setLink($this->url->linkToRouteAbsolute('deck.page.index') . '#!/board/' . $boardId . '/');
break; break;
} }
return $notification; return $notification;

View File

@@ -69,10 +69,10 @@ class BoardService {
$groupBoards = $this->boardMapper->findAllByGroups($userInfo['user'], $userInfo['groups']); $groupBoards = $this->boardMapper->findAllByGroups($userInfo['user'], $userInfo['groups']);
$complete = array_merge($userBoards, $groupBoards); $complete = array_merge($userBoards, $groupBoards);
$result = []; $result = [];
foreach($complete as &$item) { foreach ($complete as &$item) {
if(!array_key_exists($item->getId(), $result)) { if (!array_key_exists($item->getId(), $result)) {
$this->boardMapper->mapOwner($item); $this->boardMapper->mapOwner($item);
if($item->getAcl() !== null) { if ($item->getAcl() !== null) {
foreach ($item->getAcl() as &$acl) { foreach ($item->getAcl() as &$acl) {
$this->boardMapper->mapAcl($acl); $this->boardMapper->mapAcl($acl);
} }
@@ -96,7 +96,7 @@ class BoardService {
$board = $this->boardMapper->find($boardId, true, true); $board = $this->boardMapper->find($boardId, true, true);
$this->boardMapper->mapOwner($board); $this->boardMapper->mapOwner($board);
foreach ($board->getAcl() as &$acl) { foreach ($board->getAcl() as &$acl) {
if($acl !== null) { if ($acl !== null) {
$this->boardMapper->mapAcl($acl); $this->boardMapper->mapAcl($acl);
} }
} }
@@ -249,7 +249,7 @@ class BoardService {
$this->boardMapper->mapAcl($acl); $this->boardMapper->mapAcl($acl);
if ($acl->getType() === Acl::PERMISSION_TYPE_USER) { if ($acl->getType() === Acl::PERMISSION_TYPE_USER) {
$assignements = $this->assignedUsersMapper->findByUserId($acl->getParticipant()); $assignements = $this->assignedUsersMapper->findByUserId($acl->getParticipant());
foreach($assignements as $assignement) { foreach ($assignements as $assignement) {
$this->assignedUsersMapper->delete($assignement); $this->assignedUsersMapper->delete($assignement);
} }
} }

View File

@@ -57,9 +57,12 @@ class CardService {
return $card; return $card;
} }
/**
* @param integer $order
*/
public function create($title, $stackId, $type, $order, $owner) { public function create($title, $stackId, $type, $order, $owner) {
$this->permissionService->checkPermission($this->stackMapper, $stackId, Acl::PERMISSION_EDIT); $this->permissionService->checkPermission($this->stackMapper, $stackId, Acl::PERMISSION_EDIT);
if($this->boardService->isArchived($this->stackMapper, $stackId)) { if ($this->boardService->isArchived($this->stackMapper, $stackId)) {
throw new StatusException('Operation not allowed. This board is archived.'); throw new StatusException('Operation not allowed. This board is archived.');
} }
$card = new Card(); $card = new Card();
@@ -74,7 +77,7 @@ class CardService {
public function delete($id) { public function delete($id) {
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT); $this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
if($this->boardService->isArchived($this->cardMapper, $id)) { if ($this->boardService->isArchived($this->cardMapper, $id)) {
throw new StatusException('Operation not allowed. This board is archived.'); throw new StatusException('Operation not allowed. This board is archived.');
} }
return $this->cardMapper->delete($this->cardMapper->find($id)); return $this->cardMapper->delete($this->cardMapper->find($id));
@@ -82,7 +85,7 @@ class CardService {
public function update($id, $title, $stackId, $type, $order, $description, $owner, $duedate) { public function update($id, $title, $stackId, $type, $order, $description, $owner, $duedate) {
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT); $this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
if($this->boardService->isArchived($this->cardMapper, $id)) { if ($this->boardService->isArchived($this->cardMapper, $id)) {
throw new StatusException('Operation not allowed. This board is archived.'); throw new StatusException('Operation not allowed. This board is archived.');
} }
$card = $this->cardMapper->find($id); $card = $this->cardMapper->find($id);
@@ -101,7 +104,7 @@ class CardService {
public function rename($id, $title) { public function rename($id, $title) {
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT); $this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
if($this->boardService->isArchived($this->cardMapper, $id)) { if ($this->boardService->isArchived($this->cardMapper, $id)) {
throw new StatusException('Operation not allowed. This board is archived.'); throw new StatusException('Operation not allowed. This board is archived.');
} }
$card = $this->cardMapper->find($id); $card = $this->cardMapper->find($id);
@@ -114,7 +117,7 @@ class CardService {
public function reorder($id, $stackId, $order) { public function reorder($id, $stackId, $order) {
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT); $this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
if($this->boardService->isArchived($this->cardMapper, $id)) { if ($this->boardService->isArchived($this->cardMapper, $id)) {
throw new StatusException('Operation not allowed. This board is archived.'); throw new StatusException('Operation not allowed. This board is archived.');
} }
$cards = $this->cardMapper->findAll($stackId); $cards = $this->cardMapper->findAll($stackId);
@@ -145,7 +148,7 @@ class CardService {
public function archive($id) { public function archive($id) {
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT); $this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
if($this->boardService->isArchived($this->cardMapper, $id)) { if ($this->boardService->isArchived($this->cardMapper, $id)) {
throw new StatusException('Operation not allowed. This board is archived.'); throw new StatusException('Operation not allowed. This board is archived.');
} }
$card = $this->cardMapper->find($id); $card = $this->cardMapper->find($id);
@@ -155,7 +158,7 @@ class CardService {
public function unarchive($id) { public function unarchive($id) {
$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT); $this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
if($this->boardService->isArchived($this->cardMapper, $id)) { if ($this->boardService->isArchived($this->cardMapper, $id)) {
throw new StatusException('Operation not allowed. This board is archived.'); throw new StatusException('Operation not allowed. This board is archived.');
} }
$card = $this->cardMapper->find($id); $card = $this->cardMapper->find($id);
@@ -165,7 +168,7 @@ class CardService {
public function assignLabel($cardId, $labelId) { public function assignLabel($cardId, $labelId) {
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT); $this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT);
if($this->boardService->isArchived($this->cardMapper, $cardId)) { if ($this->boardService->isArchived($this->cardMapper, $cardId)) {
throw new StatusException('Operation not allowed. This board is archived.'); throw new StatusException('Operation not allowed. This board is archived.');
} }
$card = $this->cardMapper->find($cardId); $card = $this->cardMapper->find($cardId);
@@ -177,7 +180,7 @@ class CardService {
public function removeLabel($cardId, $labelId) { public function removeLabel($cardId, $labelId) {
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT); $this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT);
if($this->boardService->isArchived($this->cardMapper, $cardId)) { if ($this->boardService->isArchived($this->cardMapper, $cardId)) {
throw new StatusException('Operation not allowed. This board is archived.'); throw new StatusException('Operation not allowed. This board is archived.');
} }
$card = $this->cardMapper->find($cardId); $card = $this->cardMapper->find($cardId);
@@ -194,7 +197,7 @@ class CardService {
return false; return false;
} }
} }
$assignment = new AssignedUsers(); $assignment = new AssignedUsers();
$assignment->setCardId($cardId); $assignment->setCardId($cardId);
$assignment->setParticipant($userId); $assignment->setParticipant($userId);
return $this->assignedUsersMapper->insert($assignment); return $this->assignedUsersMapper->insert($assignment);

View File

@@ -51,7 +51,7 @@ class LabelService {
public function create($title, $color, $boardId) { public function create($title, $color, $boardId) {
$this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_MANAGE); $this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_MANAGE);
if($this->boardService->isArchived(null, $boardId)) { if ($this->boardService->isArchived(null, $boardId)) {
throw new StatusException('Operation not allowed. This board is archived.'); throw new StatusException('Operation not allowed. This board is archived.');
} }
$label = new Label(); $label = new Label();
@@ -63,7 +63,7 @@ class LabelService {
public function delete($id) { public function delete($id) {
$this->permissionService->checkPermission($this->labelMapper, $id, Acl::PERMISSION_MANAGE); $this->permissionService->checkPermission($this->labelMapper, $id, Acl::PERMISSION_MANAGE);
if($this->boardService->isArchived($this->labelMapper, $id)) { if ($this->boardService->isArchived($this->labelMapper, $id)) {
throw new StatusException('Operation not allowed. This board is archived.'); throw new StatusException('Operation not allowed. This board is archived.');
} }
return $this->labelMapper->delete($this->find($id)); return $this->labelMapper->delete($this->find($id));
@@ -71,7 +71,7 @@ class LabelService {
public function update($id, $title, $color) { public function update($id, $title, $color) {
$this->permissionService->checkPermission($this->labelMapper, $id, Acl::PERMISSION_MANAGE); $this->permissionService->checkPermission($this->labelMapper, $id, Acl::PERMISSION_MANAGE);
if($this->boardService->isArchived($this->labelMapper, $id)) { if ($this->boardService->isArchived($this->labelMapper, $id)) {
throw new StatusException('Operation not allowed. This board is archived.'); throw new StatusException('Operation not allowed. This board is archived.');
} }
$label = $this->find($id); $label = $this->find($id);

View File

@@ -185,8 +185,8 @@ class PermissionService {
*/ */
public function findUsers($boardId) { public function findUsers($boardId) {
// cache users of a board so we don't query them for every cards // cache users of a board so we don't query them for every cards
if (array_key_exists((string)$boardId, $this->users)) { if (array_key_exists((string) $boardId, $this->users)) {
return $this->users[(string)$boardId]; return $this->users[(string) $boardId];
} }
try { try {
$board = $this->boardMapper->find($boardId); $board = $this->boardMapper->find($boardId);
@@ -203,14 +203,14 @@ class PermissionService {
$user = $this->userManager->get($acl->getParticipant()); $user = $this->userManager->get($acl->getParticipant());
$users[$user->getUID()] = new User($user); $users[$user->getUID()] = new User($user);
} }
if($acl->getType() === Acl::PERMISSION_TYPE_GROUP) { if ($acl->getType() === Acl::PERMISSION_TYPE_GROUP) {
$group = $this->groupManager->get($acl->getParticipant()); $group = $this->groupManager->get($acl->getParticipant());
foreach ($group->getUsers() as $user) { foreach ($group->getUsers() as $user) {
$users[$user->getUID()] = new User($user); $users[$user->getUID()] = new User($user);
} }
} }
} }
$this->users[(string)$boardId] = $users; $this->users[(string) $boardId] = $users;
return $this->users[(string)$boardId]; return $this->users[(string) $boardId];
} }
} }

View File

@@ -27,9 +27,7 @@ use OCA\Deck\Db\Acl;
use OCA\Deck\Db\CardMapper; use OCA\Deck\Db\CardMapper;
use OCA\Deck\Db\LabelMapper; use OCA\Deck\Db\LabelMapper;
use OCA\Deck\Db\AssignedUsersMapper; use OCA\Deck\Db\AssignedUsersMapper;
use OCA\Deck\Db\Stack; use OCA\Deck\Db\Stack;
use OCA\Deck\Db\StackMapper; use OCA\Deck\Db\StackMapper;
use OCA\Deck\StatusException; use OCA\Deck\StatusException;
@@ -93,9 +91,12 @@ class StackService {
return $stacks; return $stacks;
} }
/**
* @param integer $order
*/
public function create($title, $boardId, $order) { public function create($title, $boardId, $order) {
$this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_MANAGE); $this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_MANAGE);
if($this->boardService->isArchived(null, $boardId)) { if ($this->boardService->isArchived(null, $boardId)) {
throw new StatusException('Operation not allowed. This board is archived.'); throw new StatusException('Operation not allowed. This board is archived.');
} }
$stack = new Stack(); $stack = new Stack();
@@ -113,7 +114,7 @@ class StackService {
public function update($id, $title, $boardId, $order) { public function update($id, $title, $boardId, $order) {
$this->permissionService->checkPermission($this->stackMapper, $id, Acl::PERMISSION_MANAGE); $this->permissionService->checkPermission($this->stackMapper, $id, Acl::PERMISSION_MANAGE);
if($this->boardService->isArchived($this->stackMapper, $id)) { if ($this->boardService->isArchived($this->stackMapper, $id)) {
throw new StatusException('Operation not allowed. This board is archived.'); throw new StatusException('Operation not allowed. This board is archived.');
} }
$stack = $this->stackMapper->find($id); $stack = $this->stackMapper->find($id);

View File

@@ -6,8 +6,8 @@
</div> </div>
<div id="sidebar-header"> <div id="sidebar-header">
<a class="icon-close" ui-sref="board" ng-click="sidebar.show=!sidebar.show" title="<?php p($l->t('Close')); ?>"> &nbsp;<?php <a class="icon-close" ui-sref="board" ng-click="sidebar.show=!sidebar.show" title="<?php p($l->t('Close')); ?>"> &nbsp;<?php
?><span class="hidden-visually"><?php p($l->t('Close')); ?></span><?php ?><span class="hidden-visually"><?php p($l->t('Close')); ?></span><?php
?></a> ?></a>
<h3>{{ boardservice.getCurrent().title }}</h3> <h3>{{ boardservice.getCurrent().title }}</h3>
</div> </div>