Merge branch 'master' into bugfix/deck_mapper/use_qb_mapper
This commit is contained in:
@@ -69,15 +69,7 @@ class ChangeSet implements \JsonSerializable {
|
||||
return $this->after;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify data which should be serialized to JSON
|
||||
*
|
||||
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
|
||||
* @return mixed data which can be serialized by <b>json_encode</b>,
|
||||
* which is a value of any type other than a resource.
|
||||
* @since 5.4.0
|
||||
*/
|
||||
public function jsonSerialize() {
|
||||
public function jsonSerialize(): array {
|
||||
return [
|
||||
'before' => $this->getBefore(),
|
||||
'after' => $this->getAfter(),
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
namespace OCA\Deck\Cron;
|
||||
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\BackgroundJob\Job;
|
||||
use OCA\Deck\Activity\ActivityManager;
|
||||
use OCA\Deck\Db\CardMapper;
|
||||
@@ -35,7 +36,8 @@ class CardDescriptionActivity extends Job {
|
||||
/** @var CardMapper */
|
||||
private $cardMapper;
|
||||
|
||||
public function __construct(ActivityManager $activityManager, CardMapper $cardMapper) {
|
||||
public function __construct(ITimeFactory $time, ActivityManager $activityManager, CardMapper $cardMapper) {
|
||||
parent::__construct($time);
|
||||
$this->activityManager = $activityManager;
|
||||
$this->cardMapper = $cardMapper;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
namespace OCA\Deck\Cron;
|
||||
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\BackgroundJob\TimedJob;
|
||||
use OCA\Deck\Db\AttachmentMapper;
|
||||
use OCA\Deck\Db\BoardMapper;
|
||||
@@ -40,7 +41,8 @@ class DeleteCron extends TimedJob {
|
||||
/** @var AttachmentMapper */
|
||||
private $attachmentMapper;
|
||||
|
||||
public function __construct(BoardMapper $boardMapper, AttachmentService $attachmentService, AttachmentMapper $attachmentMapper) {
|
||||
public function __construct(ITimeFactory $time, BoardMapper $boardMapper, AttachmentService $attachmentService, AttachmentMapper $attachmentMapper) {
|
||||
parent::__construct($time);
|
||||
$this->boardMapper = $boardMapper;
|
||||
$this->attachmentService = $attachmentService;
|
||||
$this->attachmentMapper = $attachmentMapper;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
namespace OCA\Deck\Cron;
|
||||
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\BackgroundJob\Job;
|
||||
use OCA\Deck\Db\Card;
|
||||
use OCA\Deck\Db\CardMapper;
|
||||
@@ -40,10 +41,12 @@ class ScheduledNotifications extends Job {
|
||||
protected $logger;
|
||||
|
||||
public function __construct(
|
||||
ITimeFactory $time,
|
||||
CardMapper $cardMapper,
|
||||
NotificationHelper $notificationHelper,
|
||||
ILogger $logger
|
||||
) {
|
||||
parent::__construct($time);
|
||||
$this->cardMapper = $cardMapper;
|
||||
$this->notificationHelper = $notificationHelper;
|
||||
$this->logger = $logger;
|
||||
|
||||
@@ -58,7 +58,7 @@ class Board extends RelationalEntity {
|
||||
$this->shared = -1;
|
||||
}
|
||||
|
||||
public function jsonSerialize() {
|
||||
public function jsonSerialize(): array {
|
||||
$json = parent::jsonSerialize();
|
||||
if ($this->shared === -1) {
|
||||
unset($json['shared']);
|
||||
|
||||
@@ -50,7 +50,7 @@ class Card extends RelationalEntity {
|
||||
protected $deletedAt = 0;
|
||||
protected $commentsUnread = 0;
|
||||
protected $commentsCount = 0;
|
||||
|
||||
|
||||
protected $relatedStack = null;
|
||||
protected $relatedBoard = null;
|
||||
|
||||
@@ -78,7 +78,7 @@ class Card extends RelationalEntity {
|
||||
$this->addRelation('commentsUnread');
|
||||
$this->addRelation('commentsCount');
|
||||
$this->addResolvable('owner');
|
||||
|
||||
|
||||
$this->addRelation('relatedStack');
|
||||
$this->addRelation('relatedBoard');
|
||||
}
|
||||
@@ -98,22 +98,21 @@ class Card extends RelationalEntity {
|
||||
return $dt->format('c');
|
||||
}
|
||||
|
||||
public function jsonSerialize() {
|
||||
public function jsonSerialize(): array {
|
||||
$json = parent::jsonSerialize();
|
||||
$json['overdue'] = self::DUEDATE_FUTURE;
|
||||
$due = strtotime($this->duedate);
|
||||
|
||||
$today = new DateTime();
|
||||
$today->setTime(0, 0);
|
||||
|
||||
$match_date = new DateTime($this->duedate);
|
||||
|
||||
$match_date->setTime(0, 0);
|
||||
|
||||
$diff = $today->diff($match_date);
|
||||
$diffDays = (integer) $diff->format('%R%a'); // Extract days count in interval
|
||||
|
||||
$due = $this->duedate ? strtotime($this->duedate) : false;
|
||||
if ($due !== false) {
|
||||
$today = new DateTime();
|
||||
$today->setTime(0, 0);
|
||||
|
||||
$match_date = new DateTime($this->duedate);
|
||||
|
||||
$match_date->setTime(0, 0);
|
||||
|
||||
$diff = $today->diff($match_date);
|
||||
$diffDays = (integer) $diff->format('%R%a'); // Extract days count in interval
|
||||
|
||||
if ($diffDays === 1) {
|
||||
$json['overdue'] = self::DUEDATE_NEXT;
|
||||
}
|
||||
|
||||
@@ -551,7 +551,7 @@ class CardMapper extends QBMapper implements IPermissionMapper {
|
||||
public function isOwner($userId, $cardId): bool {
|
||||
$sql = 'SELECT owner FROM `*PREFIX*deck_boards` WHERE `id` IN (SELECT board_id FROM `*PREFIX*deck_stacks` WHERE id IN (SELECT stack_id FROM `*PREFIX*deck_cards` WHERE id = ?))';
|
||||
$stmt = $this->db->prepare($sql);
|
||||
$stmt->bindParam(1, $cardId, \PDO::PARAM_INT);
|
||||
$stmt->bindParam(1, $cardId, \PDO::PARAM_INT, 0);
|
||||
$stmt->execute();
|
||||
$row = $stmt->fetch();
|
||||
return ($row['owner'] === $userId);
|
||||
|
||||
@@ -63,7 +63,7 @@ class RelationalEntity extends Entity implements \JsonSerializable {
|
||||
* @return array serialized data
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public function jsonSerialize() {
|
||||
public function jsonSerialize(): array {
|
||||
$properties = get_object_vars($this);
|
||||
$reflection = new \ReflectionClass($this);
|
||||
$json = [];
|
||||
|
||||
@@ -23,7 +23,9 @@
|
||||
|
||||
namespace OCA\Deck\Db;
|
||||
|
||||
class RelationalObject implements \JsonSerializable {
|
||||
use JsonSerializable;
|
||||
|
||||
class RelationalObject implements JsonSerializable {
|
||||
protected $primaryKey;
|
||||
protected $object;
|
||||
|
||||
@@ -38,7 +40,7 @@ class RelationalObject implements \JsonSerializable {
|
||||
$this->object = $object;
|
||||
}
|
||||
|
||||
public function jsonSerialize() {
|
||||
public function jsonSerialize(): array {
|
||||
return array_merge(
|
||||
['primaryKey' => $this->primaryKey],
|
||||
$this->getObjectSerialization()
|
||||
@@ -51,8 +53,8 @@ class RelationalObject implements \JsonSerializable {
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function getObjectSerialization() {
|
||||
if ($this->object instanceof \JsonSerializable) {
|
||||
$this->object->jsonSerialize();
|
||||
if ($this->object instanceof JsonSerializable) {
|
||||
return $this->object->jsonSerialize();
|
||||
} else {
|
||||
throw new \Exception('jsonSerialize is not implemented on ' . get_class($this));
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ class Stack extends RelationalEntity {
|
||||
$this->cards = $cards;
|
||||
}
|
||||
|
||||
public function jsonSerialize() {
|
||||
public function jsonSerialize(): array {
|
||||
$json = parent::jsonSerialize();
|
||||
if (empty($this->cards)) {
|
||||
unset($json['cards']);
|
||||
|
||||
@@ -114,7 +114,7 @@ class CardService {
|
||||
$countComments = $this->commentsManager->getNumberOfCommentsForObject('deckCard', (string)$card->getId());
|
||||
$card->setCommentsUnread($countUnreadComments);
|
||||
$card->setCommentsCount($countComments);
|
||||
|
||||
|
||||
$stack = $this->stackMapper->find($card->getStackId());
|
||||
$board = $this->boardService->find($stack->getBoardId());
|
||||
$card->setRelatedStack($stack);
|
||||
@@ -224,7 +224,7 @@ class CardService {
|
||||
$card->setDescription($description);
|
||||
$card->setDuedate($duedate);
|
||||
$card = $this->cardMapper->insert($card);
|
||||
|
||||
|
||||
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_CARD, $card, ActivityManager::SUBJECT_CARD_CREATE);
|
||||
$this->changeHelper->cardChanged($card->getId(), false);
|
||||
$this->eventDispatcher->dispatchTyped(new CardCreatedEvent($card));
|
||||
@@ -253,7 +253,7 @@ class CardService {
|
||||
$card = $this->cardMapper->find($id);
|
||||
$card->setDeletedAt(time());
|
||||
$this->cardMapper->update($card);
|
||||
|
||||
|
||||
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_CARD, $card, ActivityManager::SUBJECT_CARD_DELETE);
|
||||
$this->notificationHelper->markDuedateAsRead($card);
|
||||
$this->changeHelper->cardChanged($card->getId(), false);
|
||||
@@ -338,7 +338,7 @@ class CardService {
|
||||
$resetDuedateNotification = false;
|
||||
if (
|
||||
$card->getDuedate() === null ||
|
||||
(new \DateTime($card->getDuedate())) != (new \DateTime($changes->getBefore()->getDuedate()))
|
||||
(new \DateTime($card->getDuedate())) != (new \DateTime($changes->getBefore()->getDuedate() ?? ''))
|
||||
) {
|
||||
$card->setNotified(false);
|
||||
$resetDuedateNotification = true;
|
||||
|
||||
@@ -213,7 +213,9 @@ class PermissionService {
|
||||
|
||||
if ($this->circlesService->isCirclesEnabled() && $acl->getType() === Acl::PERMISSION_TYPE_CIRCLE) {
|
||||
try {
|
||||
return $this->circlesService->isUserInCircle($acl->getParticipant(), $userId) && $acl->getPermission($permission);
|
||||
if ($this->circlesService->isUserInCircle($acl->getParticipant(), $userId) && $acl->getPermission($permission)) {
|
||||
return true;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->info('Member not found in circle that was accessed. This should not happen.');
|
||||
}
|
||||
|
||||
@@ -290,10 +290,13 @@ class StackService {
|
||||
throw new BadRequestException('order must be a number');
|
||||
}
|
||||
|
||||
$this->permissionService->checkPermission($this->stackMapper, $boardId, Acl::PERMISSION_MANAGE);
|
||||
if ($this->boardService->isArchived($this->stackMapper, $boardId)) {
|
||||
$this->permissionService->checkPermission($this->stackMapper, $id, Acl::PERMISSION_MANAGE);
|
||||
$this->permissionService->checkPermission($this->boardMapper, $boardId, Acl::PERMISSION_MANAGE);
|
||||
|
||||
if ($this->boardService->isArchived($this->stackMapper, $id)) {
|
||||
throw new StatusException('Operation not allowed. This board is archived.');
|
||||
}
|
||||
|
||||
$stack = $this->stackMapper->find($id);
|
||||
$changes = new ChangeSet($stack);
|
||||
$stack->setTitle($title);
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace OCA\Deck;
|
||||
*/
|
||||
class StatusException extends \Exception {
|
||||
public function __construct($message) {
|
||||
parent::__construct($message);
|
||||
parent::__construct($message ?? '');
|
||||
}
|
||||
|
||||
public function getStatus() {
|
||||
|
||||
Reference in New Issue
Block a user