From 255aca8536921bf1a7e618001ae8dadad27c48b0 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 5 Jun 2021 11:01:03 +0200 Subject: [PATCH] bug fixes --- Admin/Install/db.json | 27 +++++++++++++++++++++++++++ Controller/ApiController.php | 6 +++--- Models/Account.php | 8 ++++++++ Models/AccountMapper.php | 6 ++++++ 4 files changed, 44 insertions(+), 3 deletions(-) diff --git a/Admin/Install/db.json b/Admin/Install/db.json index 67170a3..3719f15 100755 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -718,6 +718,33 @@ } } }, + "account_account_rel": { + "description": "Accounts can belong to other accounts. E.g. a user can belong to a company account", + "name": "account_account_rel", + "fields": { + "account_account_rel_id": { + "name": "account_account_rel_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "account_account_rel_root": { + "name": "account_account_rel_root", + "type": "INT", + "null": false, + "foreignTable": "account", + "foreignKey": "account_id" + }, + "account_account_rel_child": { + "name": "account_account_rel_child", + "type": "INT", + "null": false, + "foreignTable": "account", + "foreignKey": "account_id" + } + } + }, "account_group": { "name": "account_group", "fields": { diff --git a/Controller/ApiController.php b/Controller/ApiController.php index dc374b0..69e2211 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -445,7 +445,7 @@ final class ApiController extends Controller * * @since 1.0.0 */ - public function apiInstallApplication(RequestAbstract $request, ResponseAbstract $response, $data = null) : void + public static function apiInstallApplication(RequestAbstract $request, ResponseAbstract $response, $data = null) : void { $appManager = new ApplicationManager($this->app->moduleManager); @@ -461,7 +461,7 @@ final class ApiController extends Controller $request->getData('theme') ?? 'Default' ); - $this->apiActivateTheme($request, $response); + self::apiActivateTheme($request, $response); } /** @@ -477,7 +477,7 @@ final class ApiController extends Controller * * @since 1.0.0 */ - public function apiActivateTheme(RequestAbstract $request, ResponseAbstract $response, $data = null) : void + public static function apiActivateTheme(RequestAbstract $request, ResponseAbstract $response, $data = null) : void { if (\is_dir(__DIR__ . '/../../../' . $request->getData('appDest') . '/css')) { Directory::delete(__DIR__ . '/../../../' . $request->getData('appDest') . '/css'); diff --git a/Models/Account.php b/Models/Account.php index a29e3c6..ead5df0 100755 --- a/Models/Account.php +++ b/Models/Account.php @@ -40,6 +40,14 @@ class Account extends \phpOMS\Account\Account */ public string $tempPassword = ''; + /** + * Parents. + * + * @var Account[] + * @since 1.0.0 + */ + public array $parents = []; + /** * Remaining login tries. * diff --git a/Models/AccountMapper.php b/Models/AccountMapper.php index 4c24343..cecd4cc 100755 --- a/Models/AccountMapper.php +++ b/Models/AccountMapper.php @@ -80,6 +80,12 @@ final class AccountMapper extends DataMapperAbstract 'external' => 'account_group_group', 'self' => 'account_group_account', ], + 'parents' => [ + 'mapper' => self::class, + 'table' => 'account_account_rel', + 'external' => 'account_account_rel_root', + 'self' => 'account_account_rel_child', + ], ]; /**