commit 05f50ea0683aa873fcfad3e82d0d0674132e691f Author: Patrick Niebeling Date: Wed Mar 12 10:33:41 2025 +0100 First commit diff --git a/appinfo/app.php b/appinfo/app.php new file mode 100644 index 0000000..f06f832 --- /dev/null +++ b/appinfo/app.php @@ -0,0 +1,19 @@ +getContainer(); + $jobList = $container->query(IJobList::class); + $jobList->add(CheckOverdueCards::class); + } +} \ No newline at end of file diff --git a/appinfo/info.xml b/appinfo/info.xml new file mode 100644 index 0000000..110f642 --- /dev/null +++ b/appinfo/info.xml @@ -0,0 +1,9 @@ + + + deckflow + Deck Flow + Automatisches Verschieben von überfälligen Karten in Nextcloud Deck + 1.0.0 + OCA\DeckFlow + automation + \ No newline at end of file diff --git a/lib/Settings/BackgroundJobs/CheckOverdueCards.php b/lib/Settings/BackgroundJobs/CheckOverdueCards.php new file mode 100644 index 0000000..253cf5f --- /dev/null +++ b/lib/Settings/BackgroundJobs/CheckOverdueCards.php @@ -0,0 +1,47 @@ +cardService = $cardService; + $this->config = $config; + $this->userManager = $userManager; + $this->logger = $logger; + $this->setInterval(3600); + } + + protected function run($argument) { + $users = $this->userManager->search(''); + foreach ($users as $user) { + $userId = $user->getUID(); + $rules = json_decode($this->config->getUserValue($userId, 'deckflow', 'rules', '[]'), true); + foreach ($rules as $rule) { + $sourceStack = $rule['source_stack']; + $targetStack = $rule['target_stack']; + $cards = $this->cardService->findAllCardsInStack($sourceStack); + $now = new DateTime('now', new DateTimeZone('UTC')); + + foreach ($cards as $card) { + if (isset($card['duedate']) && new DateTime($card['duedate'], new DateTimeZone('UTC')) < $now) { + $this->cardService->updateCard($card['id'], ['stackId' => $targetStack]); + } + } + } + } + } +} diff --git a/lib/Settings/Personal.php b/lib/Settings/Personal.php new file mode 100644 index 0000000..16cb36f --- /dev/null +++ b/lib/Settings/Personal.php @@ -0,0 +1,44 @@ +config = $config; + $this->userSession = $userSession; + $this->boardService = $boardService; + $this->stackService = $stackService; + } + + public function getForm() { + $userId = $this->userSession->getUser()->getUID(); + $rules = json_decode($this->config->getUserValue($userId, 'deckflow', 'rules', '[]'), true); + $boards = $this->boardService->findAllBoards(); + $stacks = []; + + foreach ($boards as $board) { + $stacks[$board['id']] = $this->stackService->findAllStacksInBoard($board['id']); + } + + return new TemplateResponse('deckflow', 'personal', [ + 'rules' => $rules, + 'boards' => $boards, + 'stacks' => $stacks + ]); + } + + public function getSection() { return 'deckflow'; } + public function getPriority() { return 50; } +} diff --git a/templates/personal.php b/templates/personal.php new file mode 100644 index 0000000..e37cd35 --- /dev/null +++ b/templates/personal.php @@ -0,0 +1,49 @@ +
+

Deck Flow Regeln

+ + + + + + + + + + +
+ +