@@ -101,19 +101,18 @@ class Card extends RelationalEntity {
|
|||||||
public function jsonSerialize(): array {
|
public function jsonSerialize(): array {
|
||||||
$json = parent::jsonSerialize();
|
$json = parent::jsonSerialize();
|
||||||
$json['overdue'] = self::DUEDATE_FUTURE;
|
$json['overdue'] = self::DUEDATE_FUTURE;
|
||||||
$due = strtotime($this->duedate);
|
$due = $this->duedate ? strtotime($this->duedate) : 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 ($due !== 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) {
|
if ($diffDays === 1) {
|
||||||
$json['overdue'] = self::DUEDATE_NEXT;
|
$json['overdue'] = self::DUEDATE_NEXT;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -551,7 +551,7 @@ class CardMapper extends QBMapper implements IPermissionMapper {
|
|||||||
public function isOwner($userId, $cardId): bool {
|
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 = ?))';
|
$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 = $this->db->prepare($sql);
|
||||||
$stmt->bindParam(1, $cardId, \PDO::PARAM_INT);
|
$stmt->bindParam(1, $cardId, \PDO::PARAM_INT, 0);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$row = $stmt->fetch();
|
$row = $stmt->fetch();
|
||||||
return ($row['owner'] === $userId);
|
return ($row['owner'] === $userId);
|
||||||
|
|||||||
@@ -83,14 +83,14 @@ class LabelMapper extends DeckMapper implements IPermissionMapper {
|
|||||||
public function deleteLabelAssignments($labelId) {
|
public function deleteLabelAssignments($labelId) {
|
||||||
$sql = 'DELETE FROM `*PREFIX*deck_assigned_labels` WHERE label_id = ?';
|
$sql = 'DELETE FROM `*PREFIX*deck_assigned_labels` WHERE label_id = ?';
|
||||||
$stmt = $this->db->prepare($sql);
|
$stmt = $this->db->prepare($sql);
|
||||||
$stmt->bindParam(1, $labelId, \PDO::PARAM_INT);
|
$stmt->bindParam(1, $labelId, \PDO::PARAM_INT, 0);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteLabelAssignmentsForCard($cardId) {
|
public function deleteLabelAssignmentsForCard($cardId) {
|
||||||
$sql = 'DELETE FROM `*PREFIX*deck_assigned_labels` WHERE card_id = ?';
|
$sql = 'DELETE FROM `*PREFIX*deck_assigned_labels` WHERE card_id = ?';
|
||||||
$stmt = $this->db->prepare($sql);
|
$stmt = $this->db->prepare($sql);
|
||||||
$stmt->bindParam(1, $cardId, \PDO::PARAM_INT);
|
$stmt->bindParam(1, $cardId, \PDO::PARAM_INT, 0);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ class CardService {
|
|||||||
$countComments = $this->commentsManager->getNumberOfCommentsForObject('deckCard', (string)$card->getId());
|
$countComments = $this->commentsManager->getNumberOfCommentsForObject('deckCard', (string)$card->getId());
|
||||||
$card->setCommentsUnread($countUnreadComments);
|
$card->setCommentsUnread($countUnreadComments);
|
||||||
$card->setCommentsCount($countComments);
|
$card->setCommentsCount($countComments);
|
||||||
|
|
||||||
$stack = $this->stackMapper->find($card->getStackId());
|
$stack = $this->stackMapper->find($card->getStackId());
|
||||||
$board = $this->boardService->find($stack->getBoardId());
|
$board = $this->boardService->find($stack->getBoardId());
|
||||||
$card->setRelatedStack($stack);
|
$card->setRelatedStack($stack);
|
||||||
@@ -224,7 +224,7 @@ class CardService {
|
|||||||
$card->setDescription($description);
|
$card->setDescription($description);
|
||||||
$card->setDuedate($duedate);
|
$card->setDuedate($duedate);
|
||||||
$card = $this->cardMapper->insert($card);
|
$card = $this->cardMapper->insert($card);
|
||||||
|
|
||||||
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_CARD, $card, ActivityManager::SUBJECT_CARD_CREATE);
|
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_CARD, $card, ActivityManager::SUBJECT_CARD_CREATE);
|
||||||
$this->changeHelper->cardChanged($card->getId(), false);
|
$this->changeHelper->cardChanged($card->getId(), false);
|
||||||
$this->eventDispatcher->dispatchTyped(new CardCreatedEvent($card));
|
$this->eventDispatcher->dispatchTyped(new CardCreatedEvent($card));
|
||||||
@@ -253,7 +253,7 @@ class CardService {
|
|||||||
$card = $this->cardMapper->find($id);
|
$card = $this->cardMapper->find($id);
|
||||||
$card->setDeletedAt(time());
|
$card->setDeletedAt(time());
|
||||||
$this->cardMapper->update($card);
|
$this->cardMapper->update($card);
|
||||||
|
|
||||||
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_CARD, $card, ActivityManager::SUBJECT_CARD_DELETE);
|
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_CARD, $card, ActivityManager::SUBJECT_CARD_DELETE);
|
||||||
$this->notificationHelper->markDuedateAsRead($card);
|
$this->notificationHelper->markDuedateAsRead($card);
|
||||||
$this->changeHelper->cardChanged($card->getId(), false);
|
$this->changeHelper->cardChanged($card->getId(), false);
|
||||||
@@ -338,7 +338,7 @@ class CardService {
|
|||||||
$resetDuedateNotification = false;
|
$resetDuedateNotification = false;
|
||||||
if (
|
if (
|
||||||
$card->getDuedate() === null ||
|
$card->getDuedate() === null ||
|
||||||
(new \DateTime($card->getDuedate())) != (new \DateTime($changes->getBefore()->getDuedate()))
|
(new \DateTime($card->getDuedate())) != (new \DateTime($changes->getBefore()->getDuedate() ?? ''))
|
||||||
) {
|
) {
|
||||||
$card->setNotified(false);
|
$card->setNotified(false);
|
||||||
$resetDuedateNotification = true;
|
$resetDuedateNotification = true;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace OCA\Deck;
|
|||||||
*/
|
*/
|
||||||
class StatusException extends \Exception {
|
class StatusException extends \Exception {
|
||||||
public function __construct($message) {
|
public function __construct($message) {
|
||||||
parent::__construct($message);
|
parent::__construct($message ?? '');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStatus() {
|
public function getStatus() {
|
||||||
|
|||||||
@@ -103,15 +103,13 @@ class ActivityManagerTest extends TestCase {
|
|||||||
if ($format !== '') {
|
if ($format !== '') {
|
||||||
$this->assertStringContainsString('{user}', $format);
|
$this->assertStringContainsString('{user}', $format);
|
||||||
} else {
|
} else {
|
||||||
/** @noinspection ForgottenDebugOutputInspection */
|
self::addWarning('No activity string found for '. $constant);
|
||||||
print_r('No activity string found for '. $constant . PHP_EOL);
|
|
||||||
}
|
}
|
||||||
$format = $this->activityManager->getActivityFormat('cz', $value, [], true);
|
$format = $this->activityManager->getActivityFormat('cz', $value, [], true);
|
||||||
if ($format !== '') {
|
if ($format !== '') {
|
||||||
$this->assertStringStartsWith('You', $format);
|
$this->assertStringStartsWith('You', $format);
|
||||||
} else {
|
} else {
|
||||||
/** @noinspection ForgottenDebugOutputInspection */
|
self::addWarning('No own activity string found for '. $constant);
|
||||||
print_r('No own activity string found for '. $constant . PHP_EOL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user