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
Родитель 08d9d51bea
Коммит b633d82c5e
17 изменённых файлов: 77 добавлений и 71 удалений

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -140,7 +140,7 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
public function findToDelete() {
// 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` ' .
'WHERE `deleted_at` > 0 AND `deleted_at` < ?';
return $this->findEntities($sql, [$timeLimit]);
@ -181,17 +181,17 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
$userManager = $this->userManager;
$groupManager = $this->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);
if($user !== null) {
if ($user !== null) {
return new User($user);
}
\OC::$server->getLogger()->debug('User ' . $acl->getId() . ' not found when mapping acl ' . $acl->getParticipant());
return null;
}
if($acl->getType() === Acl::PERMISSION_TYPE_GROUP) {
if ($acl->getType() === Acl::PERMISSION_TYPE_GROUP) {
$group = $groupManager->get($participant);
if($group !== null) {
if ($group !== null) {
return new Group($group);
}
\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;
$board->resolveRelation('owner', function($owner) use (&$userManager) {
$user = $userManager->get($owner);
if($user !== null) {
if ($user !== null) {
return new User($user);
}
return null;

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -32,7 +32,7 @@ class RelationalEntity extends Entity implements \JsonSerializable {
/**
* 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) {
if (!in_array($property, $this->_relations, true)) {
@ -42,7 +42,7 @@ class RelationalEntity extends Entity implements \JsonSerializable {
/**
* 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) {
$this->_resolvedProperties[$property] = null;
@ -77,7 +77,7 @@ class RelationalEntity extends Entity implements \JsonSerializable {
}
}
foreach ($this->_resolvedProperties as $property => $value) {
if($value !== null) {
if ($value !== null) {
$json[$property] = $value;
}
}
@ -107,29 +107,29 @@ class RelationalEntity extends Entity implements \JsonSerializable {
*/
public function resolveRelation($property, $resolver) {
$result = null;
if($property !== null && $this->$property !== null) {
if ($property !== null && $this->$property !== null) {
$result = $resolver($this->$property);
}
if($result instanceof RelationalObject || $result === null) {
if ($result instanceof RelationalObject || $result === null) {
$this->_resolvedProperties[$property] = $result;
} else {
throw new \Exception('resolver must return an instance of RelationalObject');
}
}
public function __call($methodName, $args){
$attr = lcfirst( substr($methodName, 7) );
if(array_key_exists($attr, $this->_resolvedProperties) && strpos($methodName, 'resolve') === 0) {
if($this->_resolvedProperties[$attr] !== null) {
public function __call($methodName, $args) {
$attr = lcfirst(substr($methodName, 7));
if (array_key_exists($attr, $this->_resolvedProperties) && strpos($methodName, 'resolve') === 0) {
if ($this->_resolvedProperties[$attr] !== null) {
return $this->_resolvedProperties[$attr];
}
return $this->getter($attr);
}
$attr = lcfirst( substr($methodName, 3) );
if(array_key_exists($attr, $this->_resolvedProperties) && strpos($methodName, 'set') === 0) {
if(!is_scalar($args[0])) {
$attr = lcfirst(substr($methodName, 3));
if (array_key_exists($attr, $this->_resolvedProperties) && strpos($methodName, 'set') === 0) {
if (!is_scalar($args[0])) {
$args[0] = $args[0]['primaryKey'];
}
parent::setter($attr, $args);

Просмотреть файл

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

Просмотреть файл

@ -60,7 +60,7 @@ class SharingMiddleware extends Middleware {
*/
public function afterException($controller, $methodName, \Exception $exception) {
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);
}
return new JSONResponse([

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -66,25 +66,25 @@ class Notifier implements INotifier {
*/
public function prepare(INotification $notification, $languageCode) {
$l = $this->l10nFactory->get('deck', $languageCode);
if($notification->getApp() !== 'deck') {
if ($notification->getApp() !== 'deck') {
throw new \InvalidArgumentException();
}
$notification->setIcon($this->url->getAbsoluteURL($this->url->imagePath('deck', 'deck-dark.svg')));
$params = $notification->getSubjectParameters();
switch($notification->getSubject()) {
switch ($notification->getSubject()) {
case 'card-overdue':
$cardId = $notification->getObjectId();
$boardId = $this->cardMapper->findBoardId($cardId);
$notification->setParsedSubject(
(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;
case 'board-shared':
$boardId = $notification->getObjectId();
$initiator = $this->userManager->get($params[1]);
if($initiator !== null) {
if ($initiator !== null) {
$dn = $initiator->getDisplayName();
} else {
$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;
}
return $notification;

Просмотреть файл

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

Просмотреть файл

@ -57,9 +57,12 @@ class CardService {
return $card;
}
/**
* @param integer $order
*/
public function create($title, $stackId, $type, $order, $owner) {
$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.');
}
$card = new Card();
@ -74,7 +77,7 @@ class CardService {
public function delete($id) {
$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.');
}
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) {
$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.');
}
$card = $this->cardMapper->find($id);
@ -101,7 +104,7 @@ class CardService {
public function rename($id, $title) {
$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.');
}
$card = $this->cardMapper->find($id);
@ -114,7 +117,7 @@ class CardService {
public function reorder($id, $stackId, $order) {
$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.');
}
$cards = $this->cardMapper->findAll($stackId);
@ -145,7 +148,7 @@ class CardService {
public function archive($id) {
$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.');
}
$card = $this->cardMapper->find($id);
@ -155,7 +158,7 @@ class CardService {
public function unarchive($id) {
$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.');
}
$card = $this->cardMapper->find($id);
@ -165,7 +168,7 @@ class CardService {
public function assignLabel($cardId, $labelId) {
$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.');
}
$card = $this->cardMapper->find($cardId);
@ -177,7 +180,7 @@ class CardService {
public function removeLabel($cardId, $labelId) {
$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.');
}
$card = $this->cardMapper->find($cardId);
@ -194,7 +197,7 @@ class CardService {
return false;
}
}
$assignment = new AssignedUsers();
$assignment = new AssignedUsers();
$assignment->setCardId($cardId);
$assignment->setParticipant($userId);
return $this->assignedUsersMapper->insert($assignment);

Просмотреть файл

@ -51,7 +51,7 @@ class LabelService {
public function create($title, $color, $boardId) {
$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.');
}
$label = new Label();
@ -63,7 +63,7 @@ class LabelService {
public function delete($id) {
$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.');
}
return $this->labelMapper->delete($this->find($id));
@ -71,7 +71,7 @@ class LabelService {
public function update($id, $title, $color) {
$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.');
}
$label = $this->find($id);

Просмотреть файл

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

Просмотреть файл

@ -27,9 +27,7 @@ use OCA\Deck\Db\Acl;
use OCA\Deck\Db\CardMapper;
use OCA\Deck\Db\LabelMapper;
use OCA\Deck\Db\AssignedUsersMapper;
use OCA\Deck\Db\Stack;
use OCA\Deck\Db\StackMapper;
use OCA\Deck\StatusException;
@ -93,9 +91,12 @@ class StackService {
return $stacks;
}
/**
* @param integer $order
*/
public function create($title, $boardId, $order) {
$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.');
}
$stack = new Stack();
@ -113,7 +114,7 @@ class StackService {
public function update($id, $title, $boardId, $order) {
$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.');
}
$stack = $this->stackMapper->find($id);

Просмотреть файл

@ -6,8 +6,8 @@
</div>
<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
?><span class="hidden-visually"><?php p($l->t('Close')); ?></span><?php
?></a>
?><span class="hidden-visually"><?php p($l->t('Close')); ?></span><?php
?></a>
<h3>{{ boardservice.getCurrent().title }}</h3>
</div>