From 92e280d8ffc580c654c3c62919fe990fbeeffed4 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 6 May 2023 11:42:05 +0000 Subject: [PATCH] make id public, organigram impl. media password/encryption, settings bug fix, Money->FloatInt change, ... --- Admin/Install/Workflow.install.json | 41 ++++++++++++++++++++++++ Admin/Install/Workflow.php | 43 ++++++++++++++++++++++++++ Controller/CliController.php | 19 ++++++------ Models/Audit.php | 4 ++- Theme/Backend/audit-list.tpl.php | 6 ++-- Theme/Backend/audit-single.tpl.php | 2 +- info.json | 3 +- tests/Controller/ApiControllerTest.php | 6 ++-- tests/Models/AuditMapperTest.php | 6 ++-- tests/Models/AuditTest.php | 6 ++-- tests/Models/NullAuditTest.php | 2 +- 11 files changed, 112 insertions(+), 26 deletions(-) create mode 100755 Admin/Install/Workflow.install.json create mode 100755 Admin/Install/Workflow.php diff --git a/Admin/Install/Workflow.install.json b/Admin/Install/Workflow.install.json new file mode 100755 index 0000000..ac88d9a --- /dev/null +++ b/Admin/Install/Workflow.install.json @@ -0,0 +1,41 @@ +{ + "triggers": [ + ], + "actions": { + "1006200001": { + "name": "Create blockchain", + "description": { + "en": "Create audit blockchain", + "de": "Erstelle Audit Blockchain" + }, + "function_type": "Cli", + "function": "cliGenerateBlockchain", + "module": "Auditor", + "inputs": [ + ], + "outputs": [ + ], + "settings": { + } + } + }, + "workflows": { + "Blockchain audit": [ + { + "id": "1005500005", + "settings": { + "interval": "* 2 * * *" + }, + "children": [ + { + "id": "1006200001", + "comment": "Create blockchain", + "settings": {}, + "children": [ + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/Admin/Install/Workflow.php b/Admin/Install/Workflow.php new file mode 100755 index 0000000..4ca287c --- /dev/null +++ b/Admin/Install/Workflow.php @@ -0,0 +1,43 @@ + __DIR__ . '/Workflow.install.json']); + } +} diff --git a/Controller/CliController.php b/Controller/CliController.php index 07241ac..5e4cb9d 100755 --- a/Controller/CliController.php +++ b/Controller/CliController.php @@ -15,7 +15,6 @@ declare(strict_types=1); namespace Modules\Auditor\Controller; use Modules\Auditor\Models\AuditMapper; -use Modules\Auditor\Models\NullAudit; use phpOMS\Contract\RenderableInterface; use phpOMS\DataStorage\Database\Query\OrderType; use phpOMS\Message\RequestAbstract; @@ -61,15 +60,15 @@ final class CliController extends Controller ->limit(1) ->execute(); - if ($first->getId() === 1) { + if ($first->id === 1) { /** @var \Modules\Auditor\Models\Audit $first */ $first = AuditMapper::get() - ->where('id', $first->getId() + 1) + ->where('id', $first->id + 1) ->execute(); } $count = 0; - if (!($first instanceof NullAudit)) { + if ($first->id > 0) { /** @var \Modules\Auditor\Models\Audit $last */ $last = AuditMapper::get() ->sort('id', OrderType::DESC) @@ -78,13 +77,13 @@ final class CliController extends Controller /** @var \Modules\Auditor\Models\Audit $previous */ $previous = AuditMapper::get() - ->where('id', $first->getId() - 1) + ->where('id', $first->id - 1) ->execute(); $current = $first; - $endLastBatchId = $first->getId() - 1; + $endLastBatchId = $first->id - 1; - while ($current->getId() !== 0 && $current->getId() <= $last->getId()) { + while ($current->id !== 0 && $current->id <= $last->id) { /** @var \Modules\Auditor\Models\Audit[] $batch */ $batch = AuditMapper::getAll() ->where('id', $endLastBatchId, '>') @@ -97,8 +96,8 @@ final class CliController extends Controller $current->blockchain = \md5( $previous->blockchain - . $current->getId() - . $current->createdBy->getId() + . $current->id + . $current->createdBy->id . $current->createdAt->format('Y-m-d H:i:s') . $current->type . $current->trigger @@ -115,7 +114,7 @@ final class CliController extends Controller $previous = $current; } - $endLastBatchId = $current->getId(); + $endLastBatchId = $current->id; } } diff --git a/Models/Audit.php b/Models/Audit.php index c7780f5..a4f3d99 100755 --- a/Models/Audit.php +++ b/Models/Audit.php @@ -24,6 +24,8 @@ use phpOMS\Account\Account; * @license OMS License 2.0 * @link https://jingga.app * @since 1.0.0 + * + * @todo: Add application id */ class Audit { @@ -33,7 +35,7 @@ class Audit * @var int * @since 1.0.0 */ - protected int $id = 0; + public int $id = 0; /** * Audit type. diff --git a/Theme/Backend/audit-list.tpl.php b/Theme/Backend/audit-list.tpl.php index 4f8fcbd..9ee34dd 100755 --- a/Theme/Backend/audit-list.tpl.php +++ b/Theme/Backend/audit-list.tpl.php @@ -66,9 +66,9 @@ echo $this->getData('nav')->render(); ?> $audit) : ++$count; - $url = UriFactory::build('{/base}/admin/audit/single?id=' . $audit->getId()); ?> + $url = UriFactory::build('{/base}/admin/audit/single?id=' . $audit->id); ?> - getId(); ?> + id; ?> printHtml($audit->module); ?> old === null) : echo $this->getHtml('CREATE'); ?> old !== null && $audit->new !== null) : echo $this->getHtml('UPDATE'); ?> @@ -77,7 +77,7 @@ echo $this->getData('nav')->render(); ?> printHtml((string) $audit->type); ?> printHtml($audit->trigger); ?> - printHtml( + printHtml( $this->renderUserName('%3$s %2$s %1$s', [$audit->createdBy->name1, $audit->createdBy->name2, $audit->createdBy->name3, $audit->createdBy->login]) ); ?> printHtml((string) $audit->ref); ?> diff --git a/Theme/Backend/audit-single.tpl.php b/Theme/Backend/audit-single.tpl.php index 16e2ce8..0d9e290 100755 --- a/Theme/Backend/audit-single.tpl.php +++ b/Theme/Backend/audit-single.tpl.php @@ -53,7 +53,7 @@ echo $this->getData('nav')->render(); type; ?> getHtml('By'); ?> - createdBy->name1; ?> createdBy->name2; ?> + createdBy->name1; ?> createdBy->name2; ?> getHtml('Ref'); ?> printHtml((string) $audit->ref); ?> diff --git a/info.json b/info.json index 9fd7630..f0610cd 100755 --- a/info.json +++ b/info.json @@ -20,7 +20,8 @@ "Admin": "1.0.0" }, "providing": { - "Navigation": "*" + "Navigation": "*", + "Workflow": "*" }, "load": [ { diff --git a/tests/Controller/ApiControllerTest.php b/tests/Controller/ApiControllerTest.php index 05a3d99..5d2bf23 100755 --- a/tests/Controller/ApiControllerTest.php +++ b/tests/Controller/ApiControllerTest.php @@ -98,7 +98,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase $logs = AuditMapper::getAll()->execute(); foreach($logs as $log) { - if ($log->getId() > 0 + if ($log->id > 0 && $log->type === 1 && $log->trigger === 'test-trigger' && $log->module === 'Auditor' @@ -127,7 +127,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase $found = false; foreach($logs as $log) { - if ($log->getId() > 0 + if ($log->id > 0 && $log->type === 1 && $log->trigger === 'test-trigger' && $log->module === 'Auditor' @@ -169,7 +169,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase $logs = AuditMapper::getAll()->execute(); foreach($logs as $log) { - if ($log->getId() > 0 + if ($log->id > 0 && $log->type === 1 && $log->trigger === 'test-trigger' && $log->module === 'Auditor' diff --git a/tests/Models/AuditMapperTest.php b/tests/Models/AuditMapperTest.php index 183250d..b812cfc 100755 --- a/tests/Models/AuditMapperTest.php +++ b/tests/Models/AuditMapperTest.php @@ -42,11 +42,11 @@ final class AuditMapperTest extends \PHPUnit\Framework\TestCase ); $id = AuditMapper::create()->execute($audit); - self::assertGreaterThan(0, $audit->getId()); - self::assertEquals($id, $audit->getId()); + self::assertGreaterThan(0, $audit->id); + self::assertEquals($id, $audit->id); $auditR = AuditMapper::get() - ->where('id', $audit->getId()) + ->where('id', $audit->id) ->execute(); self::assertEquals($audit->type, $auditR->type); diff --git a/tests/Models/AuditTest.php b/tests/Models/AuditTest.php index 66f3d4e..d8b22ed 100755 --- a/tests/Models/AuditTest.php +++ b/tests/Models/AuditTest.php @@ -32,7 +32,7 @@ final class AuditTest extends \PHPUnit\Framework\TestCase public function testDefault() : void { $audit = new Audit(); - self::assertEquals(0, $audit->getId()); + self::assertEquals(0, $audit->id); self::assertEquals(0, $audit->type); self::assertEquals('', $audit->trigger); self::assertNull($audit->module); @@ -41,7 +41,7 @@ final class AuditTest extends \PHPUnit\Framework\TestCase self::assertNull($audit->old); self::assertNull($audit->new); self::assertEquals(0, $audit->ip); - self::assertEquals(0, $audit->createdBy->getId()); + self::assertEquals(0, $audit->createdBy->id); self::assertInstanceOf('\DateTimeImmutable', $audit->createdAt); } @@ -70,6 +70,6 @@ final class AuditTest extends \PHPUnit\Framework\TestCase self::assertEquals('old', $audit->old); self::assertEquals('new', $audit->new); self::assertEquals(\ip2long('127.0.0.1'), $audit->ip); - self::assertEquals(0, $audit->createdBy->getId()); + self::assertEquals(0, $audit->createdBy->id); } } diff --git a/tests/Models/NullAuditTest.php b/tests/Models/NullAuditTest.php index f2dc869..6e1f589 100755 --- a/tests/Models/NullAuditTest.php +++ b/tests/Models/NullAuditTest.php @@ -37,6 +37,6 @@ final class NullAuditTest extends \PHPUnit\Framework\TestCase public function testId() : void { $null = new NullAudit(2); - self::assertEquals(2, $null->getId()); + self::assertEquals(2, $null->id); } }