diff --git a/appinfo/app.php b/appinfo/app.php
deleted file mode 100644
index f06f832..0000000
--- a/appinfo/app.php
+++ /dev/null
@@ -1,19 +0,0 @@
-getContainer();
- $jobList = $container->query(IJobList::class);
- $jobList->add(CheckOverdueCards::class);
- }
-}
\ No newline at end of file
diff --git a/appinfo/cron.php b/appinfo/cron.php
new file mode 100644
index 0000000..969ceb5
--- /dev/null
+++ b/appinfo/cron.php
@@ -0,0 +1,9 @@
+query('OCA\Deckflow\Cron\MoveOverdueCardsJob');
+
+// Führe den Cronjob aus
+$job->execute();
diff --git a/appinfo/info.xml b/appinfo/info.xml
index 110f642..c7b055f 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -1,9 +1,14 @@
-
- deckflow
- Deck Flow
- Automatisches Verschieben von überfälligen Karten in Nextcloud Deck
- 1.0.0
- OCA\DeckFlow
- automation
-
\ No newline at end of file
+
+ deckflow
+ Deckflow
+ Automatisiere Deck-Karten mit Cronjobs und Workflows
+ Diese App automatisiert die Bewegung von Karten basierend auf Workflows und Überprüfungen von überfälligen Karten.
+ 0.1.0
+ deckflow
+
+ 21
+ workflow
+ deck
+
+
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
new file mode 100644
index 0000000..3b42e54
--- /dev/null
+++ b/lib/AppInfo/Application.php
@@ -0,0 +1,31 @@
+getContainer();
+
+ // Routen für das Backend
+ $container->registerService('SettingsController', function(IContainer $c) {
+ return new SettingsController(
+ $c->query('OCP\IRequest'),
+ $c->query('OCP\IUserSession'),
+ $c->query('OCA\Deckflow\Service\WorkflowService')
+ );
+ });
+
+ // CronJob registrieren
+ $container->registerService('MoveOverdueCardsJob', function(IContainer $c) {
+ return new MoveOverdueCardsJob(
+ $c->query('OCA\Deckflow\Service\WorkflowService')
+ );
+ });
+ }
+}
diff --git a/lib/Cron/MoveOverdueCardsJob.php b/lib/Cron/MoveOverdueCardsJob.php
new file mode 100644
index 0000000..1882ca1
--- /dev/null
+++ b/lib/Cron/MoveOverdueCardsJob.php
@@ -0,0 +1,27 @@
+workflowService = $workflowService;
+ }
+
+ /**
+ * Ausführen des Cronjobs
+ */
+ protected function run($argument) {
+ try {
+ // Überfällige Karten verschieben
+ $this->workflowService->moveOverdueCards();
+ } catch (\Exception $e) {
+ \OCP\Util::writeLog('deckflow', 'Fehler beim Ausführen des Cronjobs: ' . $e->getMessage(), \OCP\Util::ERROR);
+ }
+ }
+}
diff --git a/lib/Service/WorkflowService.php b/lib/Service/WorkflowService.php
new file mode 100644
index 0000000..0def7d2
--- /dev/null
+++ b/lib/Service/WorkflowService.php
@@ -0,0 +1,52 @@
+userSession = $userSession;
+ $this->deckService = $deckService;
+ $this->logger = $logger;
+ }
+
+ public function moveOverdueCards() {
+ $user = $this->userSession->getUser();
+ if ($user === null) {
+ return;
+ }
+
+ // Hole alle Decks für den User
+ $decks = $this->deckService->getDecksByUser($user->getUID());
+
+ foreach ($decks as $deck) {
+ // Hole die Quell- und Zielstapel
+ $sourceStack = $deck->getStackById('sourceStackId'); // Ersetze durch die Konfiguration
+ $targetStack = $deck->getStackById('targetStackId'); // Ersetze durch die Konfiguration
+
+ // Überprüfe alle Karten im Quellstapel auf Überfälligkeit
+ foreach ($sourceStack->getCards() as $card) {
+ if ($this->isCardOverdue($card)) {
+ $this->moveCardToTargetStack($card, $targetStack);
+ }
+ }
+ }
+ }
+
+ private function isCardOverdue($card) {
+ $dueDate = $card->getDueDate();
+ return $dueDate && $dueDate < time();
+ }
+
+ private function moveCardToTargetStack($card, $targetStack) {
+ $this->deckService->moveCardToStack($card, $targetStack);
+ $this->logger->info("Card moved to target stack.");
+ }
+}
diff --git a/lib/Settings/BackgroundJobs/CheckOverdueCards.php b/lib/Settings/BackgroundJobs/CheckOverdueCards.php
deleted file mode 100644
index 253cf5f..0000000
--- a/lib/Settings/BackgroundJobs/CheckOverdueCards.php
+++ /dev/null
@@ -1,47 +0,0 @@
-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
deleted file mode 100644
index 16cb36f..0000000
--- a/lib/Settings/Personal.php
+++ /dev/null
@@ -1,44 +0,0 @@
-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
deleted file mode 100644
index e37cd35..0000000
--- a/templates/personal.php
+++ /dev/null
@@ -1,49 +0,0 @@
-
-
-
diff --git a/templates/settings.php b/templates/settings.php
new file mode 100644
index 0000000..0ce46b3
--- /dev/null
+++ b/templates/settings.php
@@ -0,0 +1,19 @@
+Deckflow Settings
+